mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-19 04:10:34 +08:00
navigator mission: simplify reset logic
This can be simplified because we now only activate Mission while armed.
This commit is contained in:
@@ -88,7 +88,7 @@ Mission::on_inactive()
|
||||
}
|
||||
|
||||
/* reset the current mission if needed */
|
||||
if (need_to_reset_mission(false)) {
|
||||
if (need_to_reset_mission()) {
|
||||
reset_mission(_mission);
|
||||
update_mission();
|
||||
_navigator->reset_cruising_speed();
|
||||
@@ -195,14 +195,8 @@ Mission::on_active()
|
||||
update_mission();
|
||||
}
|
||||
|
||||
/* reset the current mission if needed */
|
||||
if (need_to_reset_mission(true)) {
|
||||
reset_mission(_mission);
|
||||
_navigator->reset_triplets();
|
||||
update_mission();
|
||||
_navigator->reset_cruising_speed();
|
||||
mission_sub_updated = true;
|
||||
}
|
||||
/* mission is running (and we are armed), need reset after disarm */
|
||||
_need_mission_reset = true;
|
||||
|
||||
_mission_changed = false;
|
||||
|
||||
@@ -1723,16 +1717,12 @@ Mission::reset_mission(struct mission_s &mission)
|
||||
}
|
||||
|
||||
bool
|
||||
Mission::need_to_reset_mission(bool active)
|
||||
Mission::need_to_reset_mission()
|
||||
{
|
||||
/* reset mission state when disarmed */
|
||||
if (_navigator->get_vstatus()->arming_state != vehicle_status_s::ARMING_STATE_ARMED && _need_mission_reset) {
|
||||
_need_mission_reset = false;
|
||||
return true;
|
||||
|
||||
} else if (_navigator->get_vstatus()->arming_state == vehicle_status_s::ARMING_STATE_ARMED && active) {
|
||||
/* mission is running, need reset after disarm */
|
||||
_need_mission_reset = true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -218,9 +218,9 @@ private:
|
||||
void reset_mission(struct mission_s &mission);
|
||||
|
||||
/**
|
||||
* Returns true if we need to reset the mission
|
||||
* Returns true if we need to reset the mission (call this only when inactive)
|
||||
*/
|
||||
bool need_to_reset_mission(bool active);
|
||||
bool need_to_reset_mission();
|
||||
|
||||
/**
|
||||
* Project current location with heading to far away location and fill setpoint.
|
||||
|
||||
Reference in New Issue
Block a user