mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 07:23:35 +08:00
fix orbit for mc: handle VEHICLE_CMD_DO_ORBIT command and avoid race condition
Fixes a regression from 8bae4e5c0e, where
the orbit flight task wasn't an extra task (flight_tasks_to_add) anymore
and therefore the command handling wasn't generated.
There was a race condition that could cause several outcomes. The most severe
was that flight_mode_manager gets the command, switches to orbit and then
in the next iteration switches back because commander did not change
nav_state yet. When commander then switches, flight_mode_manager would still
be in the old mode.
This is prevented by storing the command (allowing it to arrive before or
after mode switch), and then apply it after the switch happens.
This commit is contained in:
@@ -75,23 +75,3 @@ int FlightModeManager::_initTask(FlightTaskIndex task_index)
|
||||
_current_task.index = task_index;
|
||||
return 0;
|
||||
}
|
||||
|
||||
FlightTaskIndex FlightModeManager::switchVehicleCommand(const int command)
|
||||
{
|
||||
switch (command) {
|
||||
@# loop through all additional tasks
|
||||
@[if tasks_add]@
|
||||
@[for task in tasks_add]@
|
||||
@{
|
||||
upperCase = lambda s: s[:].upper() if s else ''
|
||||
}@
|
||||
case vehicle_command_s::VEHICLE_CMD_DO_@(upperCase(task)) :
|
||||
return FlightTaskIndex::@(task);
|
||||
break;
|
||||
|
||||
@[end for]@
|
||||
@[end if]@
|
||||
// ignore all unknown commands
|
||||
default : return FlightTaskIndex::None;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user