From 46d79d3050d65cc0e2fe8e2f67256a70c2ee7f16 Mon Sep 17 00:00:00 2001 From: JaeyoungLim Date: Thu, 22 Oct 2020 10:37:03 +0200 Subject: [PATCH] Remove exception of actuator scaling for airships (#16011) This removes the exception handling of airship type vehicles when scaling actuators for the simulator --- src/modules/simulator/simulator_mavlink.cpp | 23 +++------------------ 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/src/modules/simulator/simulator_mavlink.cpp b/src/modules/simulator/simulator_mavlink.cpp index 2021d4bacf..7951b1a8a5 100644 --- a/src/modules/simulator/simulator_mavlink.cpp +++ b/src/modules/simulator/simulator_mavlink.cpp @@ -89,7 +89,8 @@ mavlink_hil_actuator_controls_t Simulator::actuator_controls_from_outputs() int _system_type = _param_mav_type.get(); /* scale outputs depending on system type */ - if (_system_type == MAV_TYPE_QUADROTOR || + if (_system_type == MAV_TYPE_AIRSHIP || + _system_type == MAV_TYPE_QUADROTOR || _system_type == MAV_TYPE_HEXAROTOR || _system_type == MAV_TYPE_OCTOROTOR || _system_type == MAV_TYPE_VTOL_DUOROTOR || @@ -102,6 +103,7 @@ mavlink_hil_actuator_controls_t Simulator::actuator_controls_from_outputs() unsigned n; switch (_system_type) { + case MAV_TYPE_AIRSHIP: case MAV_TYPE_VTOL_DUOROTOR: n = 2; break; @@ -143,25 +145,6 @@ mavlink_hil_actuator_controls_t Simulator::actuator_controls_from_outputs() } } - } else if (_system_type == MAV_TYPE_AIRSHIP) { - /* airship: scale starboard and port throttle to 0..1 and other channels (tilt, tail thruster) to -1..1 */ - for (unsigned i = 0; i < 16; i++) { - if (armed) { - if (i < 2) { - /* scale PWM out PWM_DEFAULT_MIN..PWM_DEFAULT_MAX us to 0..1 for rotors */ - msg.controls[i] = (_actuator_outputs.output[i] - PWM_DEFAULT_MIN) / (PWM_DEFAULT_MAX - PWM_DEFAULT_MIN); - - } else { - /* scale PWM out PWM_DEFAULT_MIN..PWM_DEFAULT_MAX us to -1..1 for other channels */ - msg.controls[i] = (_actuator_outputs.output[i] - pwm_center) / ((PWM_DEFAULT_MAX - PWM_DEFAULT_MIN) / 2); - } - - } else { - /* set 0 for disabled channels */ - msg.controls[i] = 0.0f; - } - } - } else { /* fixed wing: scale throttle to 0..1 and other channels to -1..1 */