From a92e7a8796b64af18b138a5da0c79ee419a4d365 Mon Sep 17 00:00:00 2001 From: Konrad Date: Sat, 11 Nov 2023 17:21:14 +0100 Subject: [PATCH] missionResult: remove unnecessary constants and rename instance_count to mission_update_counter --- msg/MissionResult.msg | 5 +---- src/modules/commander/Commander.cpp | 6 +++--- .../commander/HealthAndArmingChecks/checks/missionCheck.cpp | 2 +- src/modules/navigator/mission_base.cpp | 4 ++-- src/modules/navigator/navigator.h | 2 +- 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/msg/MissionResult.msg b/msg/MissionResult.msg index 26dfbcecb1..e4bfed129f 100644 --- a/msg/MissionResult.msg +++ b/msg/MissionResult.msg @@ -1,9 +1,6 @@ uint64 timestamp # time since system start (microseconds) -uint8 MISSION_EXECUTION_MODE_NORMAL = 0 # Execute the mission according to the planned items -uint8 MISSION_EXECUTION_MODE_REVERSE = 1 # Execute the mission in reverse order, ignoring commands and converting all waypoints to normal ones -uint8 MISSION_EXECUTION_MODE_FAST_FORWARD = 2 # Execute the mission as fast as possible, for example converting loiter waypoints to normal ones -uint32 instance_count # Instance count of this mission. Increments monotonically whenever the mission is modified +uint16 mission_update_counter # Counter for the mission for which the result was generated int32 seq_reached # Sequence of the mission item which has been reached, default -1 uint16 seq_current # Sequence of the current mission item diff --git a/src/modules/commander/Commander.cpp b/src/modules/commander/Commander.cpp index 371858ce06..1511b011e6 100644 --- a/src/modules/commander/Commander.cpp +++ b/src/modules/commander/Commander.cpp @@ -1935,19 +1935,19 @@ void Commander::checkForMissionUpdate() if (_mission_result_sub.updated()) { const mission_result_s &mission_result = _mission_result_sub.get(); - const auto prev_mission_instance_count = mission_result.instance_count; + const auto prev_mission_mission_update_counter = mission_result.mission_update_counter; _mission_result_sub.update(); // if mission_result is valid for the current mission const bool mission_result_ok = (mission_result.timestamp > _boot_timestamp) - && (mission_result.instance_count > 0); + && (mission_result.mission_update_counter > 0); bool auto_mission_available = mission_result_ok && mission_result.valid; if (mission_result_ok) { /* Only evaluate mission state if home is set */ if (!_failsafe_flags.home_position_invalid && - (prev_mission_instance_count != mission_result.instance_count)) { + (prev_mission_mission_update_counter != mission_result.mission_update_counter)) { if (!auto_mission_available) { /* the mission is invalid */ diff --git a/src/modules/commander/HealthAndArmingChecks/checks/missionCheck.cpp b/src/modules/commander/HealthAndArmingChecks/checks/missionCheck.cpp index fd94fdbf58..12bbc817a7 100644 --- a/src/modules/commander/HealthAndArmingChecks/checks/missionCheck.cpp +++ b/src/modules/commander/HealthAndArmingChecks/checks/missionCheck.cpp @@ -56,6 +56,6 @@ void MissionChecks::checkAndReport(const Context &context, Report &reporter) } // This is a mode requirement, no need to report - reporter.failsafeFlags().auto_mission_missing = mission_result.instance_count <= 0; + reporter.failsafeFlags().auto_mission_missing = mission_result.mission_update_counter <= 0; } } diff --git a/src/modules/navigator/mission_base.cpp b/src/modules/navigator/mission_base.cpp index 6575ae196c..63a49888a8 100644 --- a/src/modules/navigator/mission_base.cpp +++ b/src/modules/navigator/mission_base.cpp @@ -690,14 +690,14 @@ MissionBase::checkMissionRestart() void MissionBase::check_mission_valid() { - if (_navigator->get_mission_result()->instance_count != _mission.mission_update_counter) { + if (_navigator->get_mission_result()->mission_update_counter != _mission.mission_update_counter) { MissionFeasibilityChecker missionFeasibilityChecker(_navigator, _dataman_client); bool is_mission_valid = missionFeasibilityChecker.checkMissionFeasible(_mission); _navigator->get_mission_result()->valid = is_mission_valid; - _navigator->get_mission_result()->instance_count = _mission.mission_update_counter; + _navigator->get_mission_result()->mission_update_counter = _mission.mission_update_counter; _navigator->get_mission_result()->seq_total = _mission.count; _navigator->get_mission_result()->seq_reached = -1; _navigator->get_mission_result()->failure = false; diff --git a/src/modules/navigator/navigator.h b/src/modules/navigator/navigator.h index 834aeec395..672c92dc3d 100644 --- a/src/modules/navigator/navigator.h +++ b/src/modules/navigator/navigator.h @@ -249,7 +249,7 @@ public: orb_advert_t *get_mavlink_log_pub() { return &_mavlink_log_pub; } - int mission_instance_count() const { return _mission_result.instance_count; } + int mission_instance_count() const { return _mission_result.mission_update_counter; } void set_mission_failure_heading_timeout();