mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-08 12:20:35 +08:00
mc_att_control: add gradual3 function to cover hover thrust rescaling
This commit is contained in:
@@ -107,7 +107,7 @@ MulticopterAttitudeControl::parameters_updated()
|
||||
float
|
||||
MulticopterAttitudeControl::throttle_curve(float throttle_stick_input)
|
||||
{
|
||||
float throttle_min = _vehicle_land_detected.landed ? 0.0f : _param_mpc_manthr_min.get();
|
||||
const float throttle_min = _vehicle_land_detected.landed ? 0.0f : _param_mpc_manthr_min.get();
|
||||
|
||||
// throttle_stick_input is in range [0, 1]
|
||||
switch (_param_mpc_thr_curve.get()) {
|
||||
@@ -115,14 +115,9 @@ MulticopterAttitudeControl::throttle_curve(float throttle_stick_input)
|
||||
return throttle_min + throttle_stick_input * (_param_mpc_thr_max.get() - throttle_min);
|
||||
|
||||
default: // 0 or other: rescale to hover throttle at 0.5 stick
|
||||
if (throttle_stick_input < 0.5f) {
|
||||
return (_param_mpc_thr_hover.get() - throttle_min) / 0.5f * throttle_stick_input +
|
||||
throttle_min;
|
||||
|
||||
} else {
|
||||
return (_param_mpc_thr_max.get() - _param_mpc_thr_hover.get()) / 0.5f * (throttle_stick_input - 1.0f) +
|
||||
_param_mpc_thr_max.get();
|
||||
}
|
||||
return math::gradual3(throttle_stick_input,
|
||||
0.f, .5f, 1.f,
|
||||
throttle_min, _param_mpc_thr_hover.get(), _param_mpc_thr_max.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user