From 801ef2d5200a31e8a801a5d6b0faf0aec18be7ef Mon Sep 17 00:00:00 2001 From: Silvan Fuhrer Date: Thu, 7 Oct 2021 17:49:26 +0200 Subject: [PATCH] VTOL main: add local variable for int(vehicle_command.param1 + 0.5) Signed-off-by: Silvan Fuhrer --- src/modules/vtol_att_control/vtol_att_control_main.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/modules/vtol_att_control/vtol_att_control_main.cpp b/src/modules/vtol_att_control/vtol_att_control_main.cpp index bedce885a0..ce03d7e15e 100644 --- a/src/modules/vtol_att_control/vtol_att_control_main.cpp +++ b/src/modules/vtol_att_control/vtol_att_control_main.cpp @@ -150,8 +150,10 @@ void VtolAttitudeControl::vehicle_cmd_poll() uint8_t result = vehicle_command_ack_s::VEHICLE_RESULT_ACCEPTED; + const int transition_command_param1 = int(vehicle_command.param1 + 0.5f); + // deny transition from MC to FW in Takeoff, Land, RTL and Orbit - if (int(vehicle_command.param1 + 0.5f) == vtol_vehicle_status_s::VEHICLE_VTOL_STATE_FW && + if (transition_command_param1 == vtol_vehicle_status_s::VEHICLE_VTOL_STATE_FW && (vehicle_status.nav_state == vehicle_status_s::NAVIGATION_STATE_AUTO_TAKEOFF || vehicle_status.nav_state == vehicle_status_s::NAVIGATION_STATE_AUTO_LAND || vehicle_status.nav_state == vehicle_status_s::NAVIGATION_STATE_AUTO_RTL @@ -160,7 +162,7 @@ void VtolAttitudeControl::vehicle_cmd_poll() result = vehicle_command_ack_s::VEHICLE_RESULT_TEMPORARILY_REJECTED; } else { - _transition_command = int(vehicle_command.param1 + 0.5f); + _transition_command = transition_command_param1; _immediate_transition = (PX4_ISFINITE(vehicle_command.param2)) ? int(vehicle_command.param2 + 0.5f) : false; }