ActuatorEffectivenessHelicopter: clarfification suggestions for servo linearization feature

This commit is contained in:
Matthias Grob
2025-02-20 19:50:08 +01:00
parent 642ea5b7f7
commit 05851a89d1
2 changed files with 15 additions and 14 deletions
@@ -106,17 +106,16 @@ void ActuatorEffectivenessHelicopter::updateParams()
param_get(_param_handles.max_servo_throw, &max_servo_throw_deg);
if (max_servo_throw_deg > 0.f) {
//linearization feature enabled
// linearization feature enabled
_geometry.linearize_servos = 1;
const float max_servo_throw = math::radians(max_servo_throw_deg);
_geometry.max_servo_height = sinf(max_servo_throw);
_geometry.inverse_max_servo_throw = 1.f / max_servo_throw;
_geometry.linearize_servos = 1;
} else {
} else {
// handle any undefined behaviour if disabled
_geometry.max_servo_height = 0.f;
_geometry.inverse_max_servo_throw = 0.f;
_geometry.linearize_servos = 0;
_geometry.max_servo_height = _geometry.inverse_max_servo_throw = 0.f;
}
}
@@ -204,17 +203,17 @@ void ActuatorEffectivenessHelicopter::updateSetpoint(const matrix::Vector<float,
float ActuatorEffectivenessHelicopter::getLinearServoOutput(float input) const
{
input = math::constrain(input, -1.0f, 1.0f);
input = math::constrain(input, -1.f, 1.f);
//servo output is calculated by normalizing input to arm rotation of CA_MAX_SVO_THROW degrees as full input for a linear throw
float svo_height = _geometry.max_servo_height * input;
// make sure a the maximal input of [-1,1] maps to the maximal vertical deflection the servo can reach of sin(CA_MAX_SVO_THROW)
float servo_height = _geometry.max_servo_height * input;
if (!PX4_ISFINITE(svo_height)) {
svo_height = 0.0f;
if (!PX4_ISFINITE(servo_height)) {
servo_height = 0.f;
}
// mulitply by 1 over max arm roation in radians to normalise
return _geometry.inverse_max_servo_throw * asinf(svo_height);
return _geometry.inverse_max_servo_throw * asinf(servo_height);
}
bool ActuatorEffectivenessHelicopter::mainMotorEnaged()
+5 -3
View File
@@ -566,11 +566,13 @@ parameters:
default: 0.0
CA_MAX_SVO_THROW:
description:
short: Defines max/min throw of servo for linearization
short: Throw angle of swashplate servo at maximum commands for linearization
long: |
Defines min/max throw of servo. Used to linearize mechanical output of servo attached to a 4-servo swashplate. Setting to zero disables feature.
Used to linearize mechanical output of swashplate servos to avoid axis coupling and binding with 4 servo redundancy.
This requires a symmetric setup where the servo horn is exactly centered with a 0 command.
Setting to zero disables feature.
type: float
decimal: 3
decimal: 1
unit: deg
increment: 0.1
min: 0