navigator mission: simplify reset logic

This can be simplified because we now only activate Mission while armed.
This commit is contained in:
Beat Küng
2020-01-23 13:45:15 +01:00
committed by Lorenz Meier
parent 92aa341c18
commit 5cacf17e47
2 changed files with 6 additions and 16 deletions
+4 -14
View File
@@ -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;
+2 -2
View File
@@ -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.