mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-02 23:31:36 +08:00
Apply suggestions from code review
Co-authored-by: Mathieu Bresciani <brescianimathieu@gmail.com>
This commit is contained in:
committed by
Matthias Grob
co-authored by
Mathieu Bresciani
parent
f13718d482
commit
49fbcb2153
+6
-7
@@ -106,11 +106,11 @@ void ActuatorEffectivenessHelicopter::updateParams()
|
|||||||
int32_t linearize_servos = 0;
|
int32_t linearize_servos = 0;
|
||||||
param_get(_param_handles.linearize_servos, &linearize_servos);
|
param_get(_param_handles.linearize_servos, &linearize_servos);
|
||||||
_geometry.linearize_servos = (linearize_servos != 0);
|
_geometry.linearize_servos = (linearize_servos != 0);
|
||||||
float max_sevo_throw = 0.f;
|
float max_servo_throw_deg = 0.f;
|
||||||
param_get(_param_handles.max_sevo_throw, &max_sevo_throw);
|
param_get(_param_handles.max_servo_throw, &max_servo_throw_deg);
|
||||||
max_sevo_throw *= M_PI_F / 180.0f; //converting deg to rad
|
const float max_servo_throw = math::radians(max_servo_throw)
|
||||||
_geometry.max_sevo_height = sinf(max_sevo_throw);
|
_geometry.max_servo_height = sinf(max_servo_throw);
|
||||||
_geometry.inverse_max_servo_throw = 1/max_sevo_throw;
|
_geometry.inverse_max_servo_throw = 1.f / max_servo_throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ActuatorEffectivenessHelicopter::getEffectivenessMatrix(Configuration &configuration,
|
bool ActuatorEffectivenessHelicopter::getEffectivenessMatrix(Configuration &configuration,
|
||||||
@@ -197,13 +197,12 @@ void ActuatorEffectivenessHelicopter::updateSetpoint(const matrix::Vector<float,
|
|||||||
|
|
||||||
float ActuatorEffectivenessHelicopter::getLinearServoOutput(float input) const
|
float ActuatorEffectivenessHelicopter::getLinearServoOutput(float input) const
|
||||||
{
|
{
|
||||||
|
|
||||||
input = math::constrain(input, -1.0f, 1.0f);
|
input = math::constrain(input, -1.0f, 1.0f);
|
||||||
|
|
||||||
//servo output is calculated by normalizing input to arm rotation of CA_MAX_SVO_THROW degrees as full input for a linear throw
|
//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_sevo_height * input;
|
float svo_height = _geometry.max_sevo_height * input;
|
||||||
|
|
||||||
if (std::isnan(svo_height)) {
|
if (!PX4_ISFINITE(svo_height)) {
|
||||||
svo_height = 0.0f;
|
svo_height = 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -67,7 +67,7 @@ public:
|
|||||||
float yaw_sign;
|
float yaw_sign;
|
||||||
float spoolup_time;
|
float spoolup_time;
|
||||||
int linearize_servos;
|
int linearize_servos;
|
||||||
float max_sevo_height;
|
float max_servo_height;
|
||||||
float inverse_max_servo_throw;
|
float inverse_max_servo_throw;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ private:
|
|||||||
param_t yaw_ccw;
|
param_t yaw_ccw;
|
||||||
param_t spoolup_time;
|
param_t spoolup_time;
|
||||||
param_t linearize_servos;
|
param_t linearize_servos;
|
||||||
param_t max_sevo_throw;
|
param_t max_servo_throw;
|
||||||
param_t inverse_max_servo_throw;
|
param_t inverse_max_servo_throw;
|
||||||
};
|
};
|
||||||
ParamHandles _param_handles{};
|
ParamHandles _param_handles{};
|
||||||
|
|||||||
@@ -575,7 +575,7 @@ parameters:
|
|||||||
description:
|
description:
|
||||||
short: Defines max/min throw of servo.
|
short: Defines max/min throw of servo.
|
||||||
long: |
|
long: |
|
||||||
Defines max/min throw of servo when linearizing servo output. Only used when CA_LIN_SERVO is enabled.
|
Defines min/max throw of servo when linearizing servo output. Only used when CA_LIN_SERVO is enabled.
|
||||||
type: float
|
type: float
|
||||||
decimal: 3
|
decimal: 3
|
||||||
unit: deg
|
unit: deg
|
||||||
@@ -1147,9 +1147,9 @@ mixer:
|
|||||||
name: CA_HELI_YAW_CCW
|
name: CA_HELI_YAW_CCW
|
||||||
- label: 'Throttle spoolup time'
|
- label: 'Throttle spoolup time'
|
||||||
name: COM_SPOOLUP_TIME
|
name: COM_SPOOLUP_TIME
|
||||||
- label: 'linearize servos'
|
- label: 'Linearize servos'
|
||||||
name: CA_LIN_SERVO
|
name: CA_LIN_SERVO
|
||||||
- label: 'max/min throw of servo in degrees'
|
- label: 'Min/max servo throw in degrees'
|
||||||
name: CA_MAX_SVO_THROW
|
name: CA_MAX_SVO_THROW
|
||||||
|
|
||||||
11: # Helicopter (tail Servo)
|
11: # Helicopter (tail Servo)
|
||||||
@@ -1180,9 +1180,9 @@ mixer:
|
|||||||
name: CA_HELI_YAW_CCW
|
name: CA_HELI_YAW_CCW
|
||||||
- label: 'Throttle spoolup time'
|
- label: 'Throttle spoolup time'
|
||||||
name: COM_SPOOLUP_TIME
|
name: COM_SPOOLUP_TIME
|
||||||
- label: 'linearize servos'
|
- label: 'Linearize servos'
|
||||||
name: CA_LIN_SERVO
|
name: CA_LIN_SERVO
|
||||||
- label: 'max/min throw of servo in degrees'
|
- label: 'Min/max servo throw in degrees'
|
||||||
name: CA_MAX_SVO_THROW
|
name: CA_MAX_SVO_THROW
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user