mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-13 11:29:58 +03:00
Fix angle mode rate profile change bug (#13862)
fix angle mode rate profile change bug
This commit is contained in:
parent
ac384cf34c
commit
cfe41ac022
3 changed files with 4 additions and 4 deletions
|
@ -436,15 +436,17 @@ STATIC_UNIT_TESTED FAST_CODE_NOINLINE float pidLevel(int axis, const pidProfile_
|
|||
// We now use Acro Rates, transformed into the range +/- 1, to provide setpoints
|
||||
const float angleLimit = pidProfile->angle_limit;
|
||||
float angleFeedforward = 0.0f;
|
||||
// if user changes rates profile, update the max setpoint for angle mode
|
||||
const float maxSetpointRateInv = 1.0f / getMaxRcRate(axis);
|
||||
|
||||
#ifdef USE_FEEDFORWARD
|
||||
angleFeedforward = angleLimit * getFeedforward(axis) * pidRuntime.angleFeedforwardGain * pidRuntime.maxRcRateInv[axis];
|
||||
angleFeedforward = angleLimit * getFeedforward(axis) * pidRuntime.angleFeedforwardGain * maxSetpointRateInv;
|
||||
// angle feedforward must be heavily filtered, at the PID loop rate, with limited user control over time constant
|
||||
// it MUST be very delayed to avoid early overshoot and being too aggressive
|
||||
angleFeedforward = pt3FilterApply(&pidRuntime.angleFeedforwardPt3[axis], angleFeedforward);
|
||||
#endif
|
||||
|
||||
float angleTarget = angleLimit * currentPidSetpoint * pidRuntime.maxRcRateInv[axis];
|
||||
float angleTarget = angleLimit * currentPidSetpoint * maxSetpointRateInv;
|
||||
// use acro rates for the angle target in both horizon and angle modes, converted to -1 to +1 range using maxRate
|
||||
|
||||
#ifdef USE_GPS_RESCUE
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue