FlightModeManager/FixedwingPositionControl: robustify vehicle command parameter casting

This commit is contained in:
Matthias Grob
2022-04-13 12:23:27 +03:00
committed by Roman Bapst
parent 6ce3e88f9d
commit f892a624b7
3 changed files with 7 additions and 5 deletions
@@ -444,8 +444,9 @@ void FlightModeManager::handleCommand()
} else if (_current_task.task) {
// check for other commands not related to task switching
if (command.command == vehicle_command_s::VEHICLE_CMD_DO_CHANGE_SPEED && command.param2 >= 0
&& (uint8_t)command.param1 == vehicle_command_s::SPEED_TYPE_GROUNDSPEED) {
if ((command.command == vehicle_command_s::VEHICLE_CMD_DO_CHANGE_SPEED)
&& (static_cast<uint8_t>(command.param1 + .5f) == vehicle_command_s::SPEED_TYPE_GROUNDSPEED)
&& (command.param2 > 0.f)) {
_current_task.task->setCruisingSpeed(command.param2);
}
}