mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-26 01:00:36 +08:00
fix(mavlink): don't miss mission current updates
When a mission is finished we need to make sure to send the mission current message and not drop it. Otherwise, MAVSDK tests might not get the update that the mission has been finished.
This commit is contained in:
1 parent
c772b23067
commit
43131d474c
2 files changed
+14
-1
No files matched your search
@@ -548,6 +548,8 @@ MavlinkMissionManager::send()
|
||||
if (_mission_result_sub.update()) {
|
||||
const mission_result_s &mission_result = _mission_result_sub.get();
|
||||
|
||||
bool send_current = false;
|
||||
|
||||
if (_current_seq != mission_result.seq_current) {
|
||||
|
||||
_current_seq = mission_result.seq_current;
|
||||
@@ -556,7 +558,7 @@ MavlinkMissionManager::send()
|
||||
|
||||
if (mission_result.seq_total > 0) {
|
||||
if (mission_result.seq_current < mission_result.seq_total) {
|
||||
send_mission_current(_current_seq);
|
||||
send_current = true;
|
||||
|
||||
} else {
|
||||
_mavlink.send_statustext_critical("ERROR: wp index out of bounds\t");
|
||||
@@ -566,6 +568,16 @@ MavlinkMissionManager::send()
|
||||
}
|
||||
}
|
||||
|
||||
// Send MISSION_CURRENT when finished state changes (to notify MISSION_STATE_COMPLETE)
|
||||
if (_last_finished != mission_result.finished) {
|
||||
_last_finished = mission_result.finished;
|
||||
send_current = true;
|
||||
}
|
||||
|
||||
if (send_current) {
|
||||
send_mission_current(_current_seq);
|
||||
}
|
||||
|
||||
if (_last_reached != mission_result.seq_reached) {
|
||||
|
||||
_last_reached = mission_result.seq_reached;
|
||||
|
||||
@@ -140,6 +140,7 @@ public:
|
||||
private:
|
||||
|
||||
int32_t _last_reached{-1}; ///< Last reached waypoint in active mission (-1 means nothing reached)
|
||||
bool _last_finished{false}; ///< Last mission finished state
|
||||
|
||||
dm_item_t _transfer_dataman_id{DM_KEY_WAYPOINTS_OFFBOARD_1}; ///< Dataman storage ID for current transmission
|
||||
|
||||
|
||||
Reference in new issue
Block a user