From 0a153efb9d6725d9e52545a962b8881bfe30ac59 Mon Sep 17 00:00:00 2001 From: Konrad Date: Wed, 13 Dec 2023 14:15:07 +0100 Subject: [PATCH] mission_base: make sure to always update state on mission topic update --- src/modules/navigator/mission_base.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/modules/navigator/mission_base.cpp b/src/modules/navigator/mission_base.cpp index e60a2b1698..c085f7ca94 100644 --- a/src/modules/navigator/mission_base.cpp +++ b/src/modules/navigator/mission_base.cpp @@ -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); + const bool mission_items_changed = (new_mission.mission_id != _mission.mission_id); + const bool mission_data_changed = checkMissionDataChanged(new_mission); - if (new_mission.current_seq < 0) { - new_mission.current_seq = math::max(math::min(_mission.current_seq, static_cast(new_mission.count) - 1), - INT32_C(0)); - } + if (new_mission.current_seq < 0) { + new_mission.current_seq = math::max(math::min(_mission.current_seq, static_cast(new_mission.count) - 1), + INT32_C(0)); + } - _mission = new_mission; + _mission = new_mission; - onMissionUpdate(mission_items_changed); - } + _is_current_planned_mission_item_valid = isMissionValid(_mission); + + /* Relevant mission items updated externally*/ + if (mission_data_changed) { + + onMissionUpdate(mission_items_changed); } } }