diff --git a/Tools/module_config/generate_actuators_metadata.py b/Tools/module_config/generate_actuators_metadata.py index d18a2db34c..91714d9327 100755 --- a/Tools/module_config/generate_actuators_metadata.py +++ b/Tools/module_config/generate_actuators_metadata.py @@ -237,7 +237,7 @@ def get_actuator_output(yaml_config, output_functions, timer_config_file, verbos ( 'function', 'Function', 'FUNC', False ), ( 'disarmed', 'Disarmed', 'DIS', False ), ( 'min', 'Minimum', 'MIN', False ), - ( 'trim', 'Trim', 'TRIM', False ), + ( 'center', 'Center', 'CENT', False ), ( 'max', 'Maximum', 'MAX', False ), ( 'failsafe', 'Failsafe', 'FAIL', True ), ] diff --git a/Tools/module_config/generate_params.py b/Tools/module_config/generate_params.py index e05781b0da..d4d59b64d9 100755 --- a/Tools/module_config/generate_params.py +++ b/Tools/module_config/generate_params.py @@ -285,8 +285,8 @@ Note that non-motor outputs might already be active in prearm state if COM_PREAR minimum_description = \ '''Minimum output value (when not disarmed). ''' - trim_description = \ -'''Trim output value (when not disarmed). + center_description = \ +'''Center output value (when not disarmed). ''' maximum_description = \ '''Maxmimum output value (when not disarmed). @@ -299,7 +299,7 @@ When set to -1 (default), the value depends on the function (see {:}). standard_params_array = [ ( 'disarmed', 'Disarmed', 'DIS', disarmed_description ), ( 'min', 'Minimum', 'MIN', minimum_description ), - ( 'trim', 'Trim', 'TRIM', trim_description ), + ( 'center', 'Center', 'CENT', center_description ), ( 'max', 'Maximum', 'MAX', maximum_description ), ( 'failsafe', 'Failsafe', 'FAIL', failsafe_description ), ] diff --git a/docs/en/config/actuators.md b/docs/en/config/actuators.md index e4346ce059..80e0f49488 100644 --- a/docs/en/config/actuators.md +++ b/docs/en/config/actuators.md @@ -537,7 +537,7 @@ If a high rate servo is _really_ needed, DShot offers better value. ##### PWM: Control surfaces that move both directions about a neutral point -To facilitate setting the neutral point of the servos, a bilinear curve function can be defined using the following parameters `PWM_MAIM_TRIMx` / `PWM_AUX_TRIMx` for each servo. This allows for unequal deflections in the positive and negative direction: +To facilitate setting the neutral point of the servos, a bilinear curve function can be defined using the following parameters `PWM_MAIM_CENTx` / `PWM_AUX_CENTx` for each servo. This allows for unequal deflections in the positive and negative direction: ![Asymetric Servo Deflections](../../assets/config/actuators/servo_pwm_trim.png) To set this up: @@ -546,7 +546,7 @@ To set this up: ![PWM Trimming](../../assets/config/actuators/trim_GS.png) -1. Set the `PWM_MAIN_TRIMx` / `PWM_AUX_TRIMx` value so that the surface will stay at the neutral position. +1. Set the `PWM_MAIN_CENTx` / `PWM_AUX_CENTx` value so that the surface will stay at the neutral position. This is usually around `1500` for PWM servos (near the center of the servo range). ![Control Surface Trimming](../../assets/config/actuators/control_surface_trim.png) @@ -616,7 +616,7 @@ One approach for setting these up is: - If the value was increased towards `Max`, then set `Max` to match `Disarmed`. 4. The value that you did _not_ set to match `Disarmed` controls the maximum amount that the control surface can extend. Set the slider to the top of the control, then change the value (`Max` or `Min`) so that the control surface is fully extended when the slider is at top. -5. (Only PWM servos) Set the `Trim` value to the middle between `Min` and `Max`. +5. (Only PWM servos) Set the `Center` value to the middle between `Min` and `Max`. ::: info Special note for flaps In some vehicle builds, flaps may be configured such that both flaps are controlled from a single output. @@ -656,7 +656,7 @@ For each of the tilt servos: - Tailsitters do not turn off any motors in fixed-wing flight - The following formula can be used to migrate from surface trim to PWM trim: - `PWM_MAIN_TRIMx = ((PWM_MAX - PWM_MIN) / 2) * CA_SV_CSx_TRIM + TRIM_MIN + ((PWM_MAX - PWM_MIN) / 2)` + `PWM_MAIN_CENTx = ((PWM_MAX - PWM_MIN) / 2) * CA_SV_CSx_TRIM + PWM_MIN + ((PWM_MAX - PWM_MIN) / 2)` ### Reversing Motors diff --git a/src/drivers/pwm_out/module.yaml b/src/drivers/pwm_out/module.yaml index 0fccc39f88..3f63358800 100644 --- a/src/drivers/pwm_out/module.yaml +++ b/src/drivers/pwm_out/module.yaml @@ -7,7 +7,7 @@ actuator_output: standard_params: disarmed: { min: 800, max: 2200, default: 1000 } min: { min: 800, max: 1400, default: 1000 } - trim: { min: 800, max: 2200, default: 1500 } + center: { min: 800, max: 2200, default: 1500 } max: { min: 1600, max: 2200, default: 2000 } failsafe: { min: 800, max: 2200 } extra_function_groups: [ pwm_fmu ] diff --git a/src/lib/mixer_module/mixer_module.cpp b/src/lib/mixer_module/mixer_module.cpp index b7784f7377..176948f474 100644 --- a/src/lib/mixer_module/mixer_module.cpp +++ b/src/lib/mixer_module/mixer_module.cpp @@ -120,8 +120,8 @@ void MixingOutput::initParamHandles(const uint8_t instance_start) _param_handles[i].disarmed = param_find(param_name); snprintf(param_name, sizeof(param_name), "%s_%s%d", _param_prefix, "MIN", i + instance_start); _param_handles[i].min = param_find(param_name); - snprintf(param_name, sizeof(param_name), "%s_%s%d", _param_prefix, "TRIM", i + instance_start); - _param_handles[i].trim = param_find(param_name); + snprintf(param_name, sizeof(param_name), "%s_%s%d", _param_prefix, "CENT", i + instance_start); + _param_handles[i].center = param_find(param_name); snprintf(param_name, sizeof(param_name), "%s_%s%d", _param_prefix, "MAX", i + instance_start); _param_handles[i].max = param_find(param_name); snprintf(param_name, sizeof(param_name), "%s_%s%d", _param_prefix, "FAIL", i + instance_start); @@ -144,9 +144,9 @@ void MixingOutput::printStatus() const PX4_INFO_RAW("Channel Configuration:\n"); for (unsigned i = 0; i < _max_num_outputs; i++) { - PX4_INFO_RAW("Channel %i: func: %3i, value: %i, failsafe: %d, disarmed: %d, min: %d, max: %d, trim: %d\n", i, + PX4_INFO_RAW("Channel %i: func: %3i, value: %i, failsafe: %d, disarmed: %d, min: %d, max: %d, center: %d\n", i, (int)_function_assignment[i], _current_output_value[i], - actualFailsafeValue(i), _disarmed_value[i], _min_value[i], _max_value[i], _trim_value[i]); + actualFailsafeValue(i), _disarmed_value[i], _min_value[i], _max_value[i], _center_value[i]); } } @@ -175,8 +175,8 @@ void MixingOutput::updateParams() _min_value[i] = val; } - if (_param_handles[i].trim != PARAM_INVALID && param_get(_param_handles[i].trim, &val) == 0) { - _trim_value[i] = val; + if (_param_handles[i].center != PARAM_INVALID && param_get(_param_handles[i].center, &val) == 0) { + _center_value[i] = val; } if (_param_handles[i].max != PARAM_INVALID && param_get(_param_handles[i].max, &val) == 0) { @@ -189,8 +189,8 @@ void MixingOutput::updateParams() _max_value[i] = tmp; } - // Trim needs to be clamped to min/max - _trim_value[i] = math::constrain(_trim_value[i], _min_value[i], _max_value[i]); + // Center needs to be clamped to min/max + _center_value[i] = math::constrain(_center_value[i], _min_value[i], _max_value[i]); if (_param_handles[i].failsafe != PARAM_INVALID && param_get(_param_handles[i].failsafe, &val) == 0) { _failsafe_value[i] = val; @@ -381,11 +381,11 @@ void MixingOutput::setAllMinValues(uint16_t value) } } -void MixingOutput::setAllTrimValues(uint16_t value) +void MixingOutput::setAllCenterValues(uint16_t value) { for (unsigned i = 0; i < MAX_ACTUATORS; i++) { - _param_handles[i].trim = PARAM_INVALID; - _trim_value[i] = value; + _param_handles[i].center = PARAM_INVALID; + _center_value[i] = value; } } @@ -549,16 +549,16 @@ uint16_t MixingOutput::output_limit_calc_single(int i, float value) const if (_function_assignment[i] >= OutputFunction::Servo1 && _function_assignment[i] <= OutputFunction::ServoMax - && _param_handles[i].trim != PARAM_INVALID) { + && _param_handles[i].center != PARAM_INVALID) { /* bi-linear interpolation */ if (value < 0.0f) { output = math::interpolate(value, -1.f, 0.0f, - static_cast(_min_value[i]), static_cast(_trim_value[i])); + static_cast(_min_value[i]), static_cast(_center_value[i])); } else { output = math::interpolate(value, 0.0f, 1.0f, - static_cast(_trim_value[i]), static_cast(_max_value[i])); + static_cast(_center_value[i]), static_cast(_max_value[i])); } } else { diff --git a/src/lib/mixer_module/mixer_module.hpp b/src/lib/mixer_module/mixer_module.hpp index 75616ec606..4fdc0f2904 100644 --- a/src/lib/mixer_module/mixer_module.hpp +++ b/src/lib/mixer_module/mixer_module.hpp @@ -167,19 +167,19 @@ public: void setAllFailsafeValues(uint16_t value); void setAllDisarmedValues(uint16_t value); void setAllMinValues(uint16_t value); - void setAllTrimValues(uint16_t value); + void setAllCenterValues(uint16_t value); void setAllMaxValues(uint16_t value); /** Disarmed values: disarmedValue < minValue needs to hold */ uint16_t &disarmedValue(int index) { return _disarmed_value[index]; } uint16_t &minValue(int index) { return _min_value[index]; } - uint16_t &trimValue(int index) { return _trim_value[index]; } + uint16_t ¢erValue(int index) { return _center_value[index]; } uint16_t &maxValue(int index) { return _max_value[index]; } param_t functionParamHandle(int index) const { return _param_handles[index].function; } param_t disarmedParamHandle(int index) const { return _param_handles[index].disarmed; } param_t minParamHandle(int index) const { return _param_handles[index].min; } - param_t trimParamHandle(int index) const { return _param_handles[index].trim; } + param_t centerParamHandle(int index) const { return _param_handles[index].center; } param_t maxParamHandle(int index) const { return _param_handles[index].max; } /** @@ -231,7 +231,7 @@ private: param_t function{PARAM_INVALID}; param_t disarmed{PARAM_INVALID}; param_t min{PARAM_INVALID}; - param_t trim{PARAM_INVALID}; + param_t center{PARAM_INVALID}; param_t max{PARAM_INVALID}; param_t failsafe{PARAM_INVALID}; }; @@ -244,7 +244,7 @@ private: uint16_t _failsafe_value[MAX_ACTUATORS] {}; uint16_t _disarmed_value[MAX_ACTUATORS] {}; uint16_t _min_value[MAX_ACTUATORS] {}; - uint16_t _trim_value[MAX_ACTUATORS] {}; + uint16_t _center_value[MAX_ACTUATORS] {}; uint16_t _max_value[MAX_ACTUATORS] {}; uint16_t _current_output_value[MAX_ACTUATORS] {}; ///< current output values (reordered) uint16_t _reverse_output_mask{0}; ///< reverses the interval [min, max] -> [max, min], NOT motor direction diff --git a/src/lib/mixer_module/mixer_module_tests.cpp b/src/lib/mixer_module/mixer_module_tests.cpp index d6d5f07930..7f3a6feede 100644 --- a/src/lib/mixer_module/mixer_module_tests.cpp +++ b/src/lib/mixer_module/mixer_module_tests.cpp @@ -54,7 +54,7 @@ static constexpr int MAX_NUM_OUTPUTS = 8; static constexpr int DISARMED_VALUE = 900; static constexpr int FAILSAFE_VALUE = 800; static constexpr int MIN_VALUE = 1000; -static constexpr int TRIM_VALUE = 1500; +static constexpr int CENTER_VALUE = 1500; static constexpr int MAX_VALUE = 2000; class MixerModuleTest : public ::testing::Test @@ -189,7 +189,7 @@ TEST_F(MixerModuleTest, basic) mixing_output.setAllDisarmedValues(DISARMED_VALUE); mixing_output.setAllFailsafeValues(FAILSAFE_VALUE); mixing_output.setAllMinValues(MIN_VALUE); - mixing_output.setAllTrimValues(TRIM_VALUE); + mixing_output.setAllCenterValues(CENTER_VALUE); mixing_output.setAllMaxValues(MAX_VALUE); EXPECT_EQ(test_module.num_updates, 0); @@ -283,7 +283,7 @@ TEST_F(MixerModuleTest, arming) mixing_output.setAllDisarmedValues(DISARMED_VALUE); mixing_output.setAllFailsafeValues(FAILSAFE_VALUE); mixing_output.setAllMinValues(MIN_VALUE); - mixing_output.setAllTrimValues(TRIM_VALUE); + mixing_output.setAllCenterValues(CENTER_VALUE); mixing_output.setAllMaxValues(MAX_VALUE); test_module.sendMotors({1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f, 1.f}); @@ -491,7 +491,7 @@ TEST_F(MixerModuleTest, OutputLimitCalcSingle) mixing_output.setAllMinValues(MIN_VALUE); // default range [1000,2000] mixing_output.setAllMaxValues(MAX_VALUE); - mixing_output.setAllTrimValues(1500); // Set trim to middle value + mixing_output.setAllCenterValues(CENTER_VALUE); // Set center to middle value EXPECT_EQ(mixing_output.output_limit_calc_single(0, -1.f), 1000); // In range EXPECT_EQ(mixing_output.output_limit_calc_single(0, -.5f), 1250); EXPECT_EQ(mixing_output.output_limit_calc_single(0, 0.f), 1500); @@ -507,7 +507,7 @@ TEST_F(MixerModuleTest, OutputLimitCalcSingle) mixing_output.setAllMinValues(0); // lower range [0,20] mixing_output.setAllMaxValues(20); - mixing_output.setAllTrimValues(10); // Set trim to middle value + mixing_output.setAllCenterValues(10); // Set center to middle value EXPECT_EQ(mixing_output.output_limit_calc_single(0, -1.f), 0); // In range EXPECT_EQ(mixing_output.output_limit_calc_single(0, -.5f), 5); EXPECT_EQ(mixing_output.output_limit_calc_single(0, 0.f), 10); @@ -523,7 +523,7 @@ TEST_F(MixerModuleTest, OutputLimitCalcSingle) mixing_output.setAllMinValues(20); // inverted range [20,0] mixing_output.setAllMaxValues(0); - mixing_output.setAllTrimValues(10); // Set trim to middle value + mixing_output.setAllCenterValues(10); // Set center to middle value EXPECT_EQ(mixing_output.output_limit_calc_single(0, -1.f), 20); // In range EXPECT_EQ(mixing_output.output_limit_calc_single(0, -.5f), 15); EXPECT_EQ(mixing_output.output_limit_calc_single(0, 0.f), 10); diff --git a/src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessControlSurfaces.cpp b/src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessControlSurfaces.cpp index f552f7b132..5a35dea886 100644 --- a/src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessControlSurfaces.cpp +++ b/src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessControlSurfaces.cpp @@ -74,10 +74,10 @@ void ActuatorEffectivenessControlSurfaces::updateParams() return; } - // Helper to check if a PWM trim parameter is set to non-default value (1500 µs) - auto check_pwm_trim = [](const char *prefix, int channel) -> bool { + // Helper to check if a PWM center parameter is set to non-default value (1500 µs) + auto check_pwm_center = [](const char *prefix, int channel) -> bool { char param_name[20]; - snprintf(param_name, sizeof(param_name), "%s_TRIM%d", prefix, channel); + snprintf(param_name, sizeof(param_name), "%s_CENT%d", prefix, channel); param_t param = param_find(param_name); if (param != PARAM_INVALID) @@ -89,11 +89,11 @@ void ActuatorEffectivenessControlSurfaces::updateParams() return false; }; - // Check if any PWM_MAIN or PWM_AUX trim is configured - bool pwm_trim_set = false; + // Check if any PWM_MAIN or PWM_AUX center is configured + bool pwm_center_set = false; - for (int i = 1; i <= 8 && !pwm_trim_set; i++) { - pwm_trim_set = check_pwm_trim("PWM_MAIN", i) || check_pwm_trim("PWM_AUX", i); + for (int i = 1; i <= 8 && !pwm_center_set; i++) { + pwm_center_set = check_pwm_center("PWM_MAIN", i) || check_pwm_center("PWM_AUX", i); } for (int i = 0; i < _count; i++) { @@ -107,9 +107,9 @@ void ActuatorEffectivenessControlSurfaces::updateParams() param_get(_param_handles[i].trim, &_params[i].trim); - // If PWM trim is set and CA_SV_CS trim is non-zero, warn and reset to 0 - if (pwm_trim_set && fabsf(_params[i].trim) > 0.001f) { - PX4_WARN("CA_SV_CS%d_TRIM (%.3f) should be 0 when PWM TRIM is used. Resetting to 0.", + // If PWM center is set and CA_SV_CS trim is non-zero, warn and reset to 0 + if (pwm_center_set && fabsf(_params[i].trim) > 0.001f) { + PX4_WARN("CA_SV_CS%d_TRIM (%.3f) should be 0 when PWM CENTER is used. Resetting to 0.", i, (double)_params[i].trim); _params[i].trim = 0.0f; // Update the parameter storage diff --git a/src/modules/control_allocator/module.yaml b/src/modules/control_allocator/module.yaml index 4dffb7649f..dd36a2d070 100644 --- a/src/modules/control_allocator/module.yaml +++ b/src/modules/control_allocator/module.yaml @@ -315,8 +315,8 @@ parameters: long: | Can be used to add an offset to the servo control. - NOTE: Do not use for PWM servos. Use the PWM TRIM parameters instead (e.g., PWM_MAIN_TRIM, PWM_AUX_TRIM) instead. - This parameter can only be set if all PWM Trim parameters are set to default. + NOTE: Do not use for PWM servos. Use the PWM CENTER parameters instead (e.g., PWM_MAIN_CENT, PWM_AUX_CENT) instead. + This parameter can only be set if all PWM Center parameters are set to default. type: float decimal: 2 min: -1.0