mirror of
https://github.com/iNavFlight/inav.git
synced 2025-07-12 19:10:27 +03:00
cleanup + change PID FF
This commit is contained in:
parent
b71547a03b
commit
4d63f88b5c
4 changed files with 4 additions and 6 deletions
|
@ -3628,7 +3628,7 @@ FF gain of altitude PID controller. Not used if nav_fw_alt_use_position is set O
|
||||||
|
|
||||||
| Default | Min | Max |
|
| Default | Min | Max |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| 10 | 0 | 255 |
|
| 30 | 0 | 255 |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
@ -2149,7 +2149,7 @@ groups:
|
||||||
max: 255
|
max: 255
|
||||||
- name: nav_fw_pos_z_ff
|
- name: nav_fw_pos_z_ff
|
||||||
description: "FF gain of altitude PID controller. Not used if nav_fw_alt_use_position is set ON (Fixedwing)"
|
description: "FF gain of altitude PID controller. Not used if nav_fw_alt_use_position is set ON (Fixedwing)"
|
||||||
default_value: 10
|
default_value: 30
|
||||||
field: bank_fw.pid[PID_POS_Z].FF
|
field: bank_fw.pid[PID_POS_Z].FF
|
||||||
min: 0
|
min: 0
|
||||||
max: 255
|
max: 255
|
||||||
|
|
|
@ -179,7 +179,7 @@ static EXTENDED_FASTRAM bool angleHoldIsLevel = false;
|
||||||
static EXTENDED_FASTRAM float fixedWingLevelTrim;
|
static EXTENDED_FASTRAM float fixedWingLevelTrim;
|
||||||
static EXTENDED_FASTRAM pidController_t fixedWingLevelTrimController;
|
static EXTENDED_FASTRAM pidController_t fixedWingLevelTrimController;
|
||||||
|
|
||||||
PG_REGISTER_PROFILE_WITH_RESET_TEMPLATE(pidProfile_t, pidProfile, PG_PID_PROFILE, 10);
|
PG_REGISTER_PROFILE_WITH_RESET_TEMPLATE(pidProfile_t, pidProfile, PG_PID_PROFILE, 11);
|
||||||
|
|
||||||
PG_RESET_TEMPLATE(pidProfile_t, pidProfile,
|
PG_RESET_TEMPLATE(pidProfile_t, pidProfile,
|
||||||
.bank_mc = {
|
.bank_mc = {
|
||||||
|
|
|
@ -147,7 +147,6 @@ static void updateAltitudeVelocityAndPitchController_FW(timeDelta_t deltaMicros)
|
||||||
// Default control based on climb rate (velocity)
|
// Default control based on climb rate (velocity)
|
||||||
float targetValue = desiredClimbRate;
|
float targetValue = desiredClimbRate;
|
||||||
float measuredValue = navGetCurrentActualPositionAndVelocity()->vel.z;
|
float measuredValue = navGetCurrentActualPositionAndVelocity()->vel.z;
|
||||||
pidControllerFlags_e pidFlags = 0; // PID_DTERM_FROM_ERROR;
|
|
||||||
|
|
||||||
// Optional control based on altitude (position)
|
// Optional control based on altitude (position)
|
||||||
if (pidProfile()->fwAltControlUsePos) {
|
if (pidProfile()->fwAltControlUsePos) {
|
||||||
|
@ -193,11 +192,10 @@ static void updateAltitudeVelocityAndPitchController_FW(timeDelta_t deltaMicros)
|
||||||
|
|
||||||
targetValue = desiredAltitude;
|
targetValue = desiredAltitude;
|
||||||
measuredValue = currentAltitude;
|
measuredValue = currentAltitude;
|
||||||
pidFlags = 0; // use measurement for D term
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// PID controller to translate desired target error (velocity or position) into pitch angle [decideg]
|
// PID controller to translate desired target error (velocity or position) into pitch angle [decideg]
|
||||||
float targetPitchAngle = navPidApply2(&posControl.pids.fw_alt, targetValue, measuredValue, US2S(deltaMicros), minDiveDeciDeg, maxClimbDeciDeg, pidFlags);
|
float targetPitchAngle = navPidApply2(&posControl.pids.fw_alt, targetValue, measuredValue, US2S(deltaMicros), minDiveDeciDeg, maxClimbDeciDeg, 0);
|
||||||
|
|
||||||
// Apply low-pass filter to prevent rapid correction
|
// Apply low-pass filter to prevent rapid correction
|
||||||
targetPitchAngle = pt1FilterApply4(&pitchFilterState, targetPitchAngle, getSmoothnessCutoffFreq(NAV_FW_BASE_PITCH_CUTOFF_FREQUENCY_HZ), US2S(deltaMicros));
|
targetPitchAngle = pt1FilterApply4(&pitchFilterState, targetPitchAngle, getSmoothnessCutoffFreq(NAV_FW_BASE_PITCH_CUTOFF_FREQUENCY_HZ), US2S(deltaMicros));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue