From f32d931117486e84f073e57b59e16264a288dcda Mon Sep 17 00:00:00 2001 From: Matthias Grob Date: Tue, 16 Aug 2022 17:04:10 +0200 Subject: [PATCH] helicopter: add yaw sign parameter & expose settings in UI --- .../ActuatorEffectivenessHelicopter.cpp | 58 ++++++++++++++----- .../ActuatorEffectivenessHelicopter.hpp | 4 ++ src/modules/control_allocator/module.yaml | 21 ++++++- 3 files changed, 67 insertions(+), 16 deletions(-) diff --git a/src/modules/control_allocator/ActuatorEffectiveness/ActuatorEffectivenessHelicopter.cpp b/src/modules/control_allocator/ActuatorEffectiveness/ActuatorEffectivenessHelicopter.cpp index ccc7e7eeb1..dfb17578d6 100644 --- a/src/modules/control_allocator/ActuatorEffectiveness/ActuatorEffectivenessHelicopter.cpp +++ b/src/modules/control_allocator/ActuatorEffectiveness/ActuatorEffectivenessHelicopter.cpp @@ -60,6 +60,7 @@ ActuatorEffectivenessHelicopter::ActuatorEffectivenessHelicopter(ModuleParams *p _param_handles.yaw_collective_pitch_scale = param_find("CA_HELI_YAW_CP_S"); _param_handles.yaw_throttle_scale = param_find("CA_HELI_YAW_TH_S"); + _param_handles.yaw_ccw = param_find("CA_HELI_YAW_CCW"); _param_handles.spoolup_time = param_find("COM_SPOOLUP_TIME"); updateParams(); @@ -93,6 +94,9 @@ void ActuatorEffectivenessHelicopter::updateParams() param_get(_param_handles.yaw_collective_pitch_scale, &_geometry.yaw_collective_pitch_scale); param_get(_param_handles.yaw_throttle_scale, &_geometry.yaw_throttle_scale); param_get(_param_handles.spoolup_time, &_geometry.spoolup_time); + int32_t yaw_ccw = 0; + param_get(_param_handles.yaw_ccw, &yaw_ccw); + _geometry.yaw_sign = (yaw_ccw == 1) ? -1.f : 1.f; } bool @@ -127,7 +131,24 @@ void ActuatorEffectivenessHelicopter::updateSetpoint(const matrix::Vector &control_sp, int matrix_index, ActuatorVector &actuator_sp) override; private: + float throttleSpoolupProgress(); + void updateParams() override; struct ParamHandlesSwashPlate { @@ -88,6 +91,7 @@ private: param_t pitch_curve[NUM_CURVE_POINTS]; param_t yaw_collective_pitch_scale; param_t yaw_throttle_scale; + param_t yaw_ccw; param_t spoolup_time; }; ParamHandles _param_handles{}; diff --git a/src/modules/control_allocator/module.yaml b/src/modules/control_allocator/module.yaml index 3f05a0b73a..d3c11d911b 100644 --- a/src/modules/control_allocator/module.yaml +++ b/src/modules/control_allocator/module.yaml @@ -435,11 +435,13 @@ parameters: short: Collective pitch curve at position ${i} long: | Defines the collective pitch at the interval position ${i} for a given thrust setpoint. + + Use negative values if the swash plate needs to move down to provide upwards thrust. type: float decimal: 3 increment: 0.1 num_instances: 5 - min: 0 + min: -1 max: 1 default: [0.05, 0.15, 0.25, 0.35, 0.45] CA_HELI_YAW_CP_S: @@ -468,6 +470,13 @@ parameters: min: -2 max: 2 default: 0.0 + CA_HELI_YAW_CCW: + description: + short: Change yaw direction + long: | + By default, positive thrust of the tail rotor is expected to rotate the vehicle clockwise. Set this parameter to true if the tail rotor provides thrust in the other direciton. + type: boolean + default: 0 # Others CA_FAILURE_MODE: @@ -916,3 +925,13 @@ mixer: label: 'Angle' - name: 'CA_SP0_ARM_L${i}' label: 'Arm Length (relative)' + parameters: + - label: 'Yaw compensation scale based on collective pitch' + name: CA_HELI_YAW_CP_S + - label: 'Yaw compensation scale based on throttle' + name: CA_HELI_YAW_TH_S + - label: 'Yaw direction is CCW' + name: CA_HELI_YAW_CCW + - label: 'Throttle spoolup time' + name: COM_SPOOLUP_TIME +