mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-23 08:15:26 +03:00
Merge pull request #4841 from yarreg/bugfix/pid-type-cast
Type casting in pid.c
This commit is contained in:
commit
c06fa5fb19
1 changed files with 2 additions and 2 deletions
|
@ -400,7 +400,7 @@ static float calculateMultirotorTPAFactor(void)
|
||||||
if (currentControlRateProfile->throttle.dynPID == 0 || rcCommand[THROTTLE] < currentControlRateProfile->throttle.pa_breakpoint) {
|
if (currentControlRateProfile->throttle.dynPID == 0 || rcCommand[THROTTLE] < currentControlRateProfile->throttle.pa_breakpoint) {
|
||||||
tpaFactor = 1.0f;
|
tpaFactor = 1.0f;
|
||||||
} else if (rcCommand[THROTTLE] < motorConfig()->maxthrottle) {
|
} else if (rcCommand[THROTTLE] < motorConfig()->maxthrottle) {
|
||||||
tpaFactor = (100 - (uint16_t)currentControlRateProfile->throttle.dynPID * (rcCommand[THROTTLE] - currentControlRateProfile->throttle.pa_breakpoint) / (motorConfig()->maxthrottle - currentControlRateProfile->throttle.pa_breakpoint)) / 100.0f;
|
tpaFactor = (100 - (uint16_t)currentControlRateProfile->throttle.dynPID * (rcCommand[THROTTLE] - currentControlRateProfile->throttle.pa_breakpoint) / (float)(motorConfig()->maxthrottle - currentControlRateProfile->throttle.pa_breakpoint)) / 100.0f;
|
||||||
} else {
|
} else {
|
||||||
tpaFactor = (100 - currentControlRateProfile->throttle.dynPID) / 100.0f;
|
tpaFactor = (100 - currentControlRateProfile->throttle.dynPID) / 100.0f;
|
||||||
}
|
}
|
||||||
|
@ -830,7 +830,7 @@ float pidHeadingHold(void)
|
||||||
New controller for 2deg error requires 2,6dps. 4dps for 3deg and so on up until mag_hold_rate_limit is reached.
|
New controller for 2deg error requires 2,6dps. 4dps for 3deg and so on up until mag_hold_rate_limit is reached.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
headingHoldRate = error * pidBank()->pid[PID_HEADING].P / 30;
|
headingHoldRate = error * pidBank()->pid[PID_HEADING].P / 30.0f;
|
||||||
headingHoldRate = constrainf(headingHoldRate, -pidProfile()->heading_hold_rate_limit, pidProfile()->heading_hold_rate_limit);
|
headingHoldRate = constrainf(headingHoldRate, -pidProfile()->heading_hold_rate_limit, pidProfile()->heading_hold_rate_limit);
|
||||||
headingHoldRate = pt1FilterApply4(&headingHoldRateFilter, headingHoldRate, HEADING_HOLD_ERROR_LPF_FREQ, dT);
|
headingHoldRate = pt1FilterApply4(&headingHoldRateFilter, headingHoldRate, HEADING_HOLD_ERROR_LPF_FREQ, dT);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue