Browse Source

navigator mission: simplify reset logic

This can be simplified because we now only activate Mission while armed.
sbg
Beat Küng 5 years ago committed by Lorenz Meier
parent
commit
5cacf17e47
  1. 18
      src/modules/navigator/mission.cpp
  2. 4
      src/modules/navigator/mission.h

18
src/modules/navigator/mission.cpp

@ -88,7 +88,7 @@ Mission::on_inactive() @@ -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() @@ -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) @@ -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;

4
src/modules/navigator/mission.h

@ -218,9 +218,9 @@ private: @@ -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.

Loading…
Cancel
Save