Skip to content

Commit 96db1da

Browse files
committed
autotune: update README with fixed-wing rate tuning instructions
1 parent 239aadc commit 96db1da

1 file changed

Lines changed: 81 additions & 8 deletions

File tree

autotune/README.md

Lines changed: 81 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,93 @@ python3 autotune.py
2929

3030
![image](https://github.com/user-attachments/assets/fcdf5c25-d92d-4487-9736-e77f6576d180)
3131

32+
# Tuning Worflow
33+
34+
## Fixed-Wing Rate Tuning
35+
36+
**Prerequisites**:
37+
38+
- Requires valid airspeed measurement on vehicle
39+
- Correctly set FW_AIRSPD_TRIM
40+
41+
### Flight Maneuvers
42+
43+
Using default PX4 gains. Perform these maneuvers separately for each axis: roll, pitch, and yaw.
44+
45+
1. Requires valid airspeed measurement, and a correctly set FW_AIRSPD_TRIM.
46+
2. Fly in stabilized mode and start from level flight.
47+
3. Apply a manual sine chirp input (sine wave with increasing frequency) on the selected axis. Avoid any other control inputs simultaneously.
48+
4. For pitch and yaw: The amplitude of the input should not be too high, but should be enough to overcome noise.
49+
5. Repeat the maneuver a few times if necessary to capture good data.
50+
51+
### Using the Tool
52+
53+
#### Load the flight log and select the relevant tuning loop (roll, pitch, or yaw):
54+
3255
![image](https://github.com/user-attachments/assets/f962a004-eae8-433f-9b7e-adc618dcbeae)
3356

57+
#### Window selection:
58+
59+
1. Select the portion of the log where the maneuver occurred.
60+
2. Ensure the window starts from level flight and covers the full maneuver.
61+
3. (Experimental) Use the coherence plot to check whether your input-output data have a strong enough relationship for frequency response identification. For fixed-wings:
62+
i. We are interested in frequencies between 0.5-10Hz
63+
ii. Values > 0.6 are sufficient
64+
iii. If the coherence function is oscillating dramatically, the frequency response identification may not be reliable.
65+
4. Once you have identified the window, load the selection into the tool.
66+
67+
<table>
68+
<tr>
69+
<td align="center"><b>Good window selection</b><br>
70+
<img src="https://github.com/user-attachments/assets/25c30295-6825-4cb4-828e-47eaa17e1557" width="400"/>
71+
</td>
72+
<td align="center"><b>Bad window selection</b><br>
73+
<img src="https://github.com/user-attachments/assets/1e05d411-37cf-42ab-8d6f-0cbbbb00921c" width="400"/>
74+
</td>
75+
</tr>
76+
</table>
77+
78+
#### Model Verification
79+
80+
1. Check that the estimated dynamic model correctly tracks the actual aircraft output (a).
81+
2. If not, adjust the system order (number of poles and zeros) and/or delay parameters (b).
82+
3. Verify that the system is minimum-phase (i.e., zeroes lie inside the unit circle) (c).
83+
84+
TODO: update this image to include numbers and make the boxes the same colour
85+
![image](https://github.com/user-attachments/assets/1172f4a1-7d76-4ef5-8ad9-b0eb05b85a35)
86+
87+
#### Tuning Gains
88+
89+
1. Set all gains to zero
90+
2. Increase the P-gain until the step response shows oscillations. Then reduce the P-gain by approximately 50%.
91+
92+
<table>
93+
<tr>
94+
<td align="center"><b>Increase P-gain </b><br>
95+
<img src="https://github.com/user-attachments/assets/db05a018-f9fb-4b3c-9f55-a4d7a577251f" width="400"/>
96+
</td>
97+
<td align="center"><b>Decrease by 50%</b><br>
98+
<img src="https://github.com/user-attachments/assets/77dc38aa-f829-4878-a58e-32d775fa542c" width="400"/>
99+
</td>
100+
</tr>
101+
</table>
102+
103+
3. Adjust the I-gain to achieve a good step response with acceptable steady-state error.
104+
105+
![image](https://github.com/user-attachments/assets/78f3bca5-2642-44e2-b3f2-7444fc4ffa40)
106+
107+
4. Fine-tune both gains as needed. At the 1 second mark, a disturbance is injected into the system. The tuned response to this disturbance is visible in the step response plot.
34108

35-
<img width="822" height="796" alt="Screenshot from 2025-08-20 15-21-50" src="https://github.com/user-attachments/assets/25c30295-6825-4cb4-828e-47eaa17e1557" />
109+
5. Use the Bode plot to confirm that the resonant frequency peak remains below 0dB.
36110

37-
<img width="822" height="796" alt="Screenshot from 2025-08-20 15-22-15" src="https://github.com/user-attachments/assets/1e05d411-37cf-42ab-8d6f-0cbbbb00921c" />
111+
![image](https://github.com/user-attachments/assets/86d99295-43a8-47a9-b052-324ab5ac3082)
38112

113+
### Applying the Gains
39114

40-
<img width="1247" height="427" alt="Screenshot from 2025-08-20 15-36-18" src="https://github.com/user-attachments/assets/77dc38aa-f829-4878-a58e-32d775fa542c" />
41-
<img width="1247" height="427" alt="Screenshot from 2025-08-20 15-37-08" src="https://github.com/user-attachments/assets/78f3bca5-2642-44e2-b3f2-7444fc4ffa40" />
42-
<img width="1365" height="427" alt="Screenshot from 2025-08-20 15-39-30" src="https://github.com/user-attachments/assets/86d99295-43a8-47a9-b052-324ab5ac3082" />
43-
<img width="1720" height="538" alt="Screenshot from 2025-08-21 15-08-04" src="https://github.com/user-attachments/assets/2db77238-bd33-4454-af1f-a38901571e88" />
44-
<img width="877" height="756" alt="Screenshot from 2025-08-20 15-32-47" src="https://github.com/user-attachments/assets/1172f4a1-7d76-4ef5-8ad9-b0eb05b85a35" />
115+
1. The gains shown in the parallel form correspond to the PX4 rate controller parameters.
116+
![image](https://github.com/user-attachments/assets/2db77238-bd33-4454-af1f-a38901571e88)
45117

46-
<img width="1247" height="427" alt="Screenshot from 2025-08-20 15-35-47" src="https://github.com/user-attachments/assets/db05a018-f9fb-4b3c-9f55-a4d7a577251f" />
118+
2. If the identified parameters are strongly different to the currently set ones (more than 30% for multiple axes), an incremental application while flying is recommended (not prior to takeoff, during takeoff, or during landing).
47119

120+
3. For all loops tuned with the strategy outlined in this guide: increase the respective integrator limit parameters to 1 (FW_RR_IMAX, FW_PR_IMAX, FW_YR_IMAX)
48121

0 commit comments

Comments
 (0)