Plane: remove guided roll flag, handle it with timer=0

This commit is contained in:
Tom Pittenger 2016-06-30 07:48:37 -07:00
parent 8ac433f991
commit 85afd9e245
4 changed files with 18 additions and 23 deletions

View File

@ -532,9 +532,9 @@ void Plane::calc_nav_roll()
int32_t commanded_roll = nav_controller->nav_roll_cd();
// Received an external msg that guides roll in the last 3 seconds?
if(plane.guided_state.guiding_roll &&
AP_HAL::millis() - plane.guided_state.last_guided_ms < 3000) {
commanded_roll = plane.guided_state.guided_roll_cd;
if (plane.guided_state.last_roll_ms > 0 &&
AP_HAL::millis() - plane.guided_state.last_roll_ms < 3000) {
commanded_roll = plane.guided_state.roll_cd;
}
nav_roll_cd = constrain_int32(commanded_roll, -roll_limit_cd, roll_limit_cd);

View File

@ -2127,13 +2127,10 @@ void GCS_MAVLINK_Plane::handleMessage(mavlink_message_t* msg)
att_target.q[2], att_target.q[3]);
float roll_rad = q.get_euler_roll();
plane.guided_state.guided_roll_cd = degrees(roll_rad) * 100.f;
// Set the flag for external roll to the nav control
plane.guided_state.guiding_roll = true;
// Update timer:
plane.guided_state.last_guided_ms = AP_HAL::millis();
plane.guided_state.roll_cd = degrees(roll_rad) * 100.0f;
// Update timer for external roll to the nav control
plane.guided_state.last_roll_ms = AP_HAL::millis();
}
break;
}

View File

@ -527,13 +527,11 @@ private:
} auto_state;
struct {
// guiding roll from an external controller? (e.g., companion computer)
bool guiding_roll:1;
// roll commanded from external controller in centidegrees
int32_t guided_roll_cd;
int32_t roll_cd;
// last time we heard from the external controller
uint32_t last_guided_ms;
uint32_t last_roll_ms;
} guided_state;
struct {

View File

@ -337,7 +337,7 @@ void Plane::set_mode(enum FlightMode mode)
crash_state.impact_detected = false;
// reset external attitude guidance
guided_state.guiding_roll = false;
guided_state.last_roll_ms = 0;
// always reset this because we don't know who called set_mode. In evasion
// behavior you should set this flag after set_mode so you know the evasion