mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-14 00:20:35 +08:00
commander: prevent race condition after mission
When a mission finishes with an RTL command, there's a race condition between: 1. RTL command setting user_mode_intention RTL 2. Mission completion logic forcing LOITER The auto-loiter transition was checking current nav_state (which is still AUTO_MISSION) instead of any pending user_mode_intention, causing it to override the RTL request. Fix: Only auto-transition to loiter if no mode change is already pending.
This commit is contained in:
@@ -2016,7 +2016,11 @@ void Commander::checkForMissionUpdate()
|
||||
|
||||
} else if (_vehicle_status.nav_state == vehicle_status_s::NAVIGATION_STATE_AUTO_MISSION) {
|
||||
// Transition to loiter when the mission is cleared and/or finished, and we are still in mission mode.
|
||||
_user_mode_intention.change(vehicle_status_s::NAVIGATION_STATE_AUTO_LOITER);
|
||||
|
||||
// However, only do so if there's no pending mode change, so there isn't already a pending change (like RTL).
|
||||
if (_user_mode_intention.get() == vehicle_status_s::NAVIGATION_STATE_AUTO_MISSION) {
|
||||
_user_mode_intention.change(vehicle_status_s::NAVIGATION_STATE_AUTO_LOITER);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user