Skip to content

Commit

Permalink
mavlink-mission: Add support for opaque ids and replace update counte…
Browse files Browse the repository at this point in the history
…r with it
  • Loading branch information
KonradRudin authored and dagar committed Nov 29, 2023
1 parent 120e7fe commit 36f0c0f
Show file tree
Hide file tree
Showing 17 changed files with 194 additions and 101 deletions.
6 changes: 3 additions & 3 deletions msg/Mission.msg
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ int32 current_seq # default -1, start at the one changed latest
int32 land_start_index # Index of the land start marker, if unavailable index of the land item, -1 otherwise
int32 land_index # Index of the land item, -1 otherwise

uint16 mission_update_counter # indicates updates to the mission, reload from dataman if increased
uint16 geofence_update_counter # indicates updates to the geofence, reload from dataman if increased
uint16 safe_points_update_counter # indicates updates to the safe points, reload from dataman if increased
uint32 mission_id # indicates updates to the mission, reload from dataman if changed
uint32 geofence_id # indicates updates to the geofence, reload from dataman if changed
uint32 safe_points_id # indicates updates to the safe points, reload from dataman if changed
6 changes: 3 additions & 3 deletions msg/MissionResult.msg
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
uint64 timestamp # time since system start (microseconds)
uint64 timestamp # time since system start (microseconds)

uint16 mission_update_counter # Counter for the mission for which the result was generated
uint16 geofence_update_counter # Counter for the corresponding geofence for which the result was generated (used for mission feasibility)
uint16 mission_id # Id for the mission for which the result was generated
uint16 geofence_id # Id for the corresponding geofence for which the result was generated (used for mission feasibility)
uint64 home_position_counter # Counter of the home position for which the result was generated (used for mission feasibility)

int32 seq_reached # Sequence of the mission item which has been reached, default -1
Expand Down
6 changes: 3 additions & 3 deletions src/modules/commander/Commander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_mission_update_counter = mission_result.mission_update_counter;
const auto prev_mission_mission_id = mission_result.mission_id;
_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.mission_update_counter > 0);
&& (mission_result.mission_id > 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_mission_update_counter != mission_result.mission_update_counter)) {
(prev_mission_mission_id != mission_result.mission_id)) {

if (!auto_mission_available) {
/* the mission is invalid */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.mission_update_counter <= 0;
reporter.failsafeFlags().auto_mission_missing = mission_result.mission_id <= 0;
}
}
5 changes: 4 additions & 1 deletion src/modules/dataman/dataman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,10 +574,13 @@ _file_initialize(unsigned max_offset)
mission.dataman_id = DM_KEY_WAYPOINTS_OFFBOARD_0;
mission.count = 0;
mission.current_seq = 0;
mission.mission_id = 0u;
mission.geofence_id = 0u;
mission.safe_points_id = 0u;

mission_stats_entry_s stats;
stats.num_items = 0;
stats.update_counter = 1;
stats.opaque_id = 0;

g_dm_ops->write(DM_KEY_MISSION_STATE, 0, reinterpret_cast<uint8_t *>(&mission), sizeof(mission_s));
g_dm_ops->write(DM_KEY_FENCE_POINTS, 0, reinterpret_cast<uint8_t *>(&stats), sizeof(mission_stats_entry_s));
Expand Down
Loading

0 comments on commit 36f0c0f

Please sign in to comment.