mc pos control: add MPC_THR_CURVE param

The hover thrust param also changed the thrust scaling in Stabilized mode.
However if the hover thrust is very low (e.g. below 20%), the throttle
stick input becomes very distorted.
This commit is contained in:
Beat Küng
2018-10-09 12:09:07 +02:00
parent a9def8be93
commit 48f5f8faa5
3 changed files with 36 additions and 7 deletions
@@ -145,16 +145,22 @@ void FlightTaskManualStabilized::_updateSetpoints()
float FlightTaskManualStabilized::_throttleCurve()
{
/* Scale stick z from [-1,1] to [min thrust, max thrust]
* with hover throttle at 0.5 stick */
// Scale stick z from [-1,1] to [min thrust, max thrust]
float throttle = -((_sticks(2) - 1.0f) * 0.5f);
if (throttle < 0.5f) {
return (_throttle_hover.get() - _throttle_min_stabilized.get()) / 0.5f * throttle + _throttle_min_stabilized.get();
switch (_throttle_curve.get()) {
case 1: // no rescaling
return throttle;
} else {
return (_throttle_max.get() - _throttle_hover.get()) / 0.5f * (throttle - 1.0f) + _throttle_max.get();
default: // 0 or other: rescale to hover throttle at 0.5 stick
if (throttle < 0.5f) {
return (_throttle_hover.get() - _throttle_min_stabilized.get()) / 0.5f * throttle + _throttle_min_stabilized.get();
} else {
return (_throttle_max.get() - _throttle_hover.get()) / 0.5f * (throttle - 1.0f) + _throttle_max.get();
}
}
}
bool FlightTaskManualStabilized::update()
@@ -77,6 +77,7 @@ private:
(ParamFloat<px4::params::MPC_MAN_TILT_MAX>) _tilt_max_man, /**< maximum tilt allowed for manual flight */
(ParamFloat<px4::params::MPC_MANTHR_MIN>) _throttle_min_stabilized, /**< minimum throttle for stabilized */
(ParamFloat<px4::params::MPC_THR_MAX>) _throttle_max, /**< maximum throttle that always has to be satisfied in flight*/
(ParamFloat<px4::params::MPC_THR_HOVER>) _throttle_hover /**< throttle value at which vehicle is at hover equilibrium */
(ParamFloat<px4::params::MPC_THR_HOVER>) _throttle_hover, /**< throttle at which vehicle is at hover equilibrium */
(ParamInt<px4::params::MPC_THR_CURVE>) _throttle_curve /**< throttle curve behavior */
)
};