Skip to content

Commit

Permalink
Changed name to attitude rate
Browse files Browse the repository at this point in the history
  • Loading branch information
salauddinaliahmed authored Dec 10, 2018
1 parent b10d726 commit a121fd6
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions plugins/offboard/offboard_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,22 +160,22 @@ void OffboardImpl::set_velocity_body(Offboard::VelocityBodyYawspeed velocity_bod
send_velocity_body();
}

void OffboardImpl::set_attitude_target(Offboard::SetAttitude set_attitude)
void OffboardImpl::set_attitude_rate(Offboard::AttitudeRate attitude_rate)
{
_mutex.lock();
_set_attitude = set_attitude;
_attitude_rate = attitude_rate;

if (_mode != Mode::ATTITUDE_TARGET) {
if (_mode != Mode::ATTITUDE_RATE) {
if (_call_every_cookie) {
// If we're already sending other setpoints, stop that now.
_parent->remove_call_every(_call_every_cookie);
_call_every_cookie = nullptr;
}
// We automatically send body setpoints from now on.
_parent->add_call_every(
[this]() { send_attitude_target(); }, SEND_INTERVAL_S, &_call_every_cookie);
[this]() { send_attitude_rate(); }, SEND_INTERVAL_S, &_call_every_cookie);

_mode = Mode::ATTITUDE_TARGET;
_mode = Mode::ATTITUDE_RATE;
} else {
// We're already sending these kind of setpoints. Since the setpoint change, let's
// reschedule the next call, so we don't send setpoints too often.
Expand All @@ -184,7 +184,7 @@ void OffboardImpl::set_attitude_target(Offboard::SetAttitude set_attitude)
_mutex.unlock();

// also send it right now to reduce latency
send_attitude_target();
send_attitude_rate();
}

void OffboardImpl::send_velocity_ned()
Expand Down Expand Up @@ -293,7 +293,7 @@ void OffboardImpl::send_velocity_body()
_parent->send_message(message);
}

void OffboardImpl::send_attitude_target()
void OffboardImpl::send_attitude_rate()
{
//const static uint8_t IGNORE_BODY_ROLL_RATE = (1 << 0);
//const static uint8_t IGNORE_BODY_PITCH_RATE = (1 << 1);
Expand All @@ -305,10 +305,10 @@ void OffboardImpl::send_attitude_target()
const static uint8_t IGNORE_ATTITUDE = (1 << 7);

_mutex.lock();
const float thrust = _set_attitude.thrust_value;
const float body_roll_rate = to_rad_from_deg(_set_attitude.roll_deg_s);
const float body_pitch_rate = to_rad_from_deg(_set_attitude.pitch_deg_s);
const float body_yaw_rate = to_rad_from_deg(_set_attitude.yaw_deg_s);
const float thrust = _attitude_rate.thrust_value;
const float body_roll_rate = to_rad_from_deg(_attitude_rate.roll_deg_s);
const float body_pitch_rate = to_rad_from_deg(_attitude_rate.pitch_deg_s);
const float body_yaw_rate = to_rad_from_deg(_attitude_rate.yaw_deg_s);
_mutex.unlock();

mavlink_message_t message;
Expand Down

0 comments on commit a121fd6

Please sign in to comment.