Skip to content

Commit 1a2a065

Browse files
mahima-yogabresch
andauthored
Autotune: Update README with fixed-wing rate tuning instructions (#42)
* autotune: update README with fixed-wing rate tuning instructions * Apply suggestions from code review Co-authored-by: Mathieu Bresciani <brescianimathieu@gmail.com> * Add new line delim in nested list * Update autotune/README.md * Apply suggestions from code review --------- Co-authored-by: Mathieu Bresciani <brescianimathieu@gmail.com>
1 parent 7b96392 commit 1a2a065

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

autotune/README.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,90 @@ 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+
55+
![image](https://github.com/user-attachments/assets/f962a004-eae8-433f-9b7e-adc618dcbeae)
56+
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 linear relationship at the desired frequencies. 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 identified model may be unreliable at those frequencies.
65+
4. Once you have identified the window, load the selection into the tool.
66+
67+
<table>
68+
<tr>
69+
<td align="center">
70+
<b>Good window selection</b><br>
71+
<img src="https://github.com/user-attachments/assets/25c30295-6825-4cb4-828e-47eaa17e1557" width="400"/><br>
72+
<i>Starts from level flight and covers the full maneuver. Coherence is sufficient.</i>
73+
</td>
74+
<td align="center">
75+
<b>Bad window selection</b><br>
76+
<img src="https://github.com/user-attachments/assets/1e05d411-37cf-42ab-8d6f-0cbbbb00921c" width="400"/><br>
77+
<i>Does not isolate the maneuver. Coherence is insufficient. </i>
78+
</td>
79+
</tr>
80+
</table>
81+
82+
#### Model Verification
83+
84+
1. Check that the estimated dynamic model correctly tracks the actual aircraft output.
85+
2. If not, adjust the system order (number of poles and zeros) and/or delay parameters.
86+
3. Verify that the system is minimum-phase (i.e., zeroes lie inside the unit circle).
87+
88+
<img src="https://github.com/user-attachments/assets/87168b77-1b52-4d6f-bb4d-ace3f76fe4ee" width="700"/>
89+
90+
#### Tuning Gains
91+
92+
1. Set all gains to zero
93+
2. Increase the P-gain until the step response shows oscillations. Then reduce the P-gain by approximately 50%:
94+
95+
<b>Increase P-gain</b><br>
96+
<img src="https://github.com/user-attachments/assets/db05a018-f9fb-4b3c-9f55-a4d7a577251f"/>
97+
98+
<b>Decrease by 50%</b><br>
99+
<img src="https://github.com/user-attachments/assets/77dc38aa-f829-4878-a58e-32d775fa542c"/>
100+
101+
3. Adjust the I-gain to achieve a good step response with acceptable steady-state error.
102+
103+
![image](https://github.com/user-attachments/assets/78f3bca5-2642-44e2-b3f2-7444fc4ffa40)
104+
105+
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.
106+
107+
5. Use the Bode plot to confirm that the resonant frequency peak remains below 0dB.
108+
109+
![image](https://github.com/user-attachments/assets/86d99295-43a8-47a9-b052-324ab5ac3082)
110+
111+
### Applying the Gains
112+
113+
1. The gains shown in the parallel form correspond to the PX4 rate controller parameters.
114+
![image](https://github.com/user-attachments/assets/2db77238-bd33-4454-af1f-a38901571e88)
115+
116+
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).
117+
118+
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).

0 commit comments

Comments
 (0)