Skip to content

Commit dbf5147

Browse files
authored
Merge pull request #4624 from iNavFlight/dzikuvx-nav-pids-to-pidff
Convert all NAV P-controllers to PIDFF
2 parents d9644e0 + b8ba10b commit dbf5147

File tree

5 files changed

+17
-29
lines changed

5 files changed

+17
-29
lines changed

docs/Cli.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,7 @@ After restoring it's always a good idea to `dump` or `diff` the settings once ag
318318
| accgain_z | 4096 | Calculated value after '6 position avanced calibration'. Uncalibrated value is 4096. See Wiki page. |
319319
| nav_mc_pos_z_p | 50 | P gain of altitude PID controller (Multirotor) |
320320
| nav_fw_pos_z_p | 50 | P gain of altitude PID controller (Fixedwing) |
321-
| nav_mc_pos_z_i | 0 | I gain of altitude PID controller (Multirotor) |
322321
| nav_fw_pos_z_i | 0 | I gain of altitude PID controller (Fixedwing) |
323-
| nav_mc_pos_z_d | 0 | D gain of altitude PID controller (Multirotor) |
324322
| nav_fw_pos_z_d | 0 | D gain of altitude PID controller (Fixedwing) |
325323
| nav_mc_vel_z_p | 100 | P gain of velocity PID controller |
326324
| nav_mc_vel_z_i | 50 | I gain of velocity PID controller |

src/main/fc/settings.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,16 +1023,6 @@ groups:
10231023
condition: USE_NAV
10241024
min: 0
10251025
max: 255
1026-
- name: nav_mc_pos_z_i
1027-
field: bank_mc.pid[PID_POS_Z].I
1028-
condition: USE_NAV
1029-
min: 0
1030-
max: 255
1031-
- name: nav_mc_pos_z_d
1032-
field: bank_mc.pid[PID_POS_Z].D
1033-
condition: USE_NAV
1034-
min: 0
1035-
max: 255
10361026
- name: nav_mc_vel_z_p
10371027
field: bank_mc.pid[PID_VEL_Z].P
10381028
condition: USE_NAV

src/main/navigation/navigation.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1737,14 +1737,6 @@ void navPidInit(pidController_t *pid, float _kP, float _kI, float _kD, float _kF
17371737
navPidReset(pid);
17381738
}
17391739

1740-
/*-----------------------------------------------------------
1741-
* Float point P-controller implementation
1742-
*-----------------------------------------------------------*/
1743-
void navPInit(pController_t *p, float _kP)
1744-
{
1745-
p->param.kP = _kP;
1746-
}
1747-
17481740
/*-----------------------------------------------------------
17491741
* Detects if thrust vector is facing downwards
17501742
*-----------------------------------------------------------*/
@@ -3036,7 +3028,14 @@ void navigationUsePIDs(void)
30363028

30373029
// Initialize position hold P-controller
30383030
for (int axis = 0; axis < 2; axis++) {
3039-
navPInit(&posControl.pids.pos[axis], (float)pidProfile()->bank_mc.pid[PID_POS_XY].P / 100.0f);
3031+
navPidInit(
3032+
&posControl.pids.pos[axis],
3033+
(float)pidProfile()->bank_mc.pid[PID_POS_XY].P / 100.0f,
3034+
0.0f,
3035+
0.0f,
3036+
0.0f,
3037+
NAV_DTERM_CUT_HZ
3038+
);
30403039

30413040
navPidInit(&posControl.pids.vel[axis], (float)pidProfile()->bank_mc.pid[PID_VEL_XY].P / 20.0f,
30423041
(float)pidProfile()->bank_mc.pid[PID_VEL_XY].I / 100.0f,
@@ -3047,7 +3046,14 @@ void navigationUsePIDs(void)
30473046
}
30483047

30493048
// Initialize altitude hold PID-controllers (pos_z, vel_z, acc_z
3050-
navPInit(&posControl.pids.pos[Z], (float)pidProfile()->bank_mc.pid[PID_POS_Z].P / 100.0f);
3049+
navPidInit(
3050+
&posControl.pids.pos[Z],
3051+
(float)pidProfile()->bank_mc.pid[PID_POS_Z].P / 100.0f,
3052+
0.0f,
3053+
0.0f,
3054+
0.0f,
3055+
NAV_DTERM_CUT_HZ
3056+
);
30513057

30523058
navPidInit(&posControl.pids.vel[Z], (float)pidProfile()->bank_mc.pid[PID_VEL_Z].P / 66.7f,
30533059
(float)pidProfile()->bank_mc.pid[PID_VEL_Z].I / 20.0f,

src/main/navigation/navigation.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -266,14 +266,9 @@ typedef struct {
266266
float output_constrained; // controller output constrained
267267
} pidController_t;
268268

269-
typedef struct {
270-
pControllerParam_t param;
271-
float output_constrained;
272-
} pController_t;
273-
274269
typedef struct navigationPIDControllers_s {
275270
/* Multicopter PIDs */
276-
pController_t pos[XYZ_AXIS_COUNT];
271+
pidController_t pos[XYZ_AXIS_COUNT];
277272
pidController_t vel[XYZ_AXIS_COUNT];
278273
pidController_t surface;
279274

src/main/navigation/navigation_private.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,6 @@ float navPidApply2(pidController_t *pid, const float setpoint, const float measu
357357
float navPidApply3(pidController_t *pid, const float setpoint, const float measurement, const float dt, const float outMin, const float outMax, const pidControllerFlags_e pidFlags, const float gainScaler);
358358
void navPidReset(pidController_t *pid);
359359
void navPidInit(pidController_t *pid, float _kP, float _kI, float _kD, float _kFF, float _dTermLpfHz);
360-
void navPInit(pController_t *p, float _kP);
361360

362361
bool isThrustFacingDownwards(void);
363362
uint32_t calculateDistanceToDestination(const fpVector3_t * destinationPos);

0 commit comments

Comments
 (0)