Skip to content

Commit

Permalink
mission_base: make sure to always update state on mission topic update
Browse files Browse the repository at this point in the history
  • Loading branch information
KonradRudin authored and dagar committed Jan 30, 2024
1 parent 97ce599 commit 0a153ef
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/modules/navigator/mission_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,22 @@ void MissionBase::updateMavlinkMission()
mission_s new_mission;
_mission_sub.update(&new_mission);

if (isMissionValid(new_mission)) {
/* Relevant mission items updated externally*/
if (checkMissionDataChanged(new_mission)) {
bool mission_items_changed = (new_mission.mission_id != _mission.mission_id);

if (new_mission.current_seq < 0) {
new_mission.current_seq = math::max(math::min(_mission.current_seq, static_cast<int32_t>(new_mission.count) - 1),
INT32_C(0));
}
const bool mission_items_changed = (new_mission.mission_id != _mission.mission_id);
const bool mission_data_changed = checkMissionDataChanged(new_mission);

_mission = new_mission;
if (new_mission.current_seq < 0) {
new_mission.current_seq = math::max(math::min(_mission.current_seq, static_cast<int32_t>(new_mission.count) - 1),
INT32_C(0));
}

onMissionUpdate(mission_items_changed);
}
_mission = new_mission;

_is_current_planned_mission_item_valid = isMissionValid(_mission);

/* Relevant mission items updated externally*/
if (mission_data_changed) {

onMissionUpdate(mission_items_changed);
}
}
}
Expand Down

0 comments on commit 0a153ef

Please sign in to comment.