From ac3e7482b18a74084e2fa7e4b0d57326012280dd Mon Sep 17 00:00:00 2001 From: mahima-yoga Date: Tue, 2 Sep 2025 14:33:37 +0200 Subject: [PATCH 1/5] autotune: update README with fixed-wing rate tuning instructions --- autotune/README.md | 87 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/autotune/README.md b/autotune/README.md index 6f767c6..2d54734 100644 --- a/autotune/README.md +++ b/autotune/README.md @@ -29,3 +29,90 @@ python3 autotune.py ![image](https://github.com/user-attachments/assets/fcdf5c25-d92d-4487-9736-e77f6576d180) +# Tuning Worflow + +## Fixed-Wing Rate Tuning + +**Prerequisites**: + +- Requires valid airspeed measurement on vehicle +- Correctly set FW_AIRSPD_TRIM + +### Flight Maneuvers + +Using default PX4 gains. Perform these maneuvers separately for each axis: roll, pitch, and yaw. + +1. Requires valid airspeed measurement, and a correctly set FW_AIRSPD_TRIM. +2. Fly in stabilized mode and start from level flight. +3. Apply a manual sine chirp input (sine wave with increasing frequency) on the selected axis. Avoid any other control inputs simultaneously. +4. For pitch and yaw: The amplitude of the input should not be too high, but should be enough to overcome noise. +5. Repeat the maneuver a few times if necessary to capture good data. + +### Using the Tool + +#### Load the flight log and select the relevant tuning loop (roll, pitch, or yaw): + +![image](https://github.com/user-attachments/assets/f962a004-eae8-433f-9b7e-adc618dcbeae) + +#### Window selection: + +1. Select the portion of the log where the maneuver occurred. +2. Ensure the window starts from level flight and covers the full maneuver. +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: + i. We are interested in frequencies between 0.5-10Hz + ii. Values > 0.6 are sufficient + iii. If the coherence function is oscillating dramatically, the frequency response identification may not be reliable. +4. Once you have identified the window, load the selection into the tool. + + + + + + +
+ Good window selection
+
+ Starts from level flight and covers the full maneuver. Coherence is sufficient. +
+ Bad window selection
+
+ Does not isolate the maneuver. Coherence is insufficient. +
+ +#### Model Verification + +1. Check that the estimated dynamic model correctly tracks the actual aircraft output. +2. If not, adjust the system order (number of poles and zeros) and/or delay parameters. +3. Verify that the system is minimum-phase (i.e., zeroes lie inside the unit circle). + + + +#### Tuning Gains + +1. Set all gains to zero +2. Increase the P-gain until the step response shows oscillations. Then reduce the P-gain by approximately 50%: + + Increase P-gain
+ + + Decrease by 50%
+ + +3. Adjust the I-gain to achieve a good step response with acceptable steady-state error. + + ![image](https://github.com/user-attachments/assets/78f3bca5-2642-44e2-b3f2-7444fc4ffa40) + +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. + +5. Use the Bode plot to confirm that the resonant frequency peak remains below 0dB. + + ![image](https://github.com/user-attachments/assets/86d99295-43a8-47a9-b052-324ab5ac3082) + +### Applying the Gains + +1. The gains shown in the parallel form correspond to the PX4 rate controller parameters. + ![image](https://github.com/user-attachments/assets/2db77238-bd33-4454-af1f-a38901571e88) + +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). + +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). From 9d921d5268cebca31137136abb3d0194aea9dcda Mon Sep 17 00:00:00 2001 From: Mahima Yoga Date: Wed, 3 Sep 2025 10:38:57 +0200 Subject: [PATCH 2/5] Apply suggestions from code review Co-authored-by: Mathieu Bresciani --- autotune/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autotune/README.md b/autotune/README.md index 2d54734..f8ace3d 100644 --- a/autotune/README.md +++ b/autotune/README.md @@ -58,10 +58,10 @@ Using default PX4 gains. Perform these maneuvers separately for each axis: roll, 1. Select the portion of the log where the maneuver occurred. 2. Ensure the window starts from level flight and covers the full maneuver. -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: +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: i. We are interested in frequencies between 0.5-10Hz ii. Values > 0.6 are sufficient - iii. If the coherence function is oscillating dramatically, the frequency response identification may not be reliable. + iii. If the coherence function is oscillating dramatically, the identified model may be unreliable at those frequencies. 4. Once you have identified the window, load the selection into the tool. From 26836c00f9289af65b59ea118d69969b09a3fe44 Mon Sep 17 00:00:00 2001 From: Mahima Yoga Date: Wed, 3 Sep 2025 10:40:47 +0200 Subject: [PATCH 3/5] Add new line delim in nested list --- autotune/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/autotune/README.md b/autotune/README.md index f8ace3d..d29090b 100644 --- a/autotune/README.md +++ b/autotune/README.md @@ -58,10 +58,10 @@ Using default PX4 gains. Perform these maneuvers separately for each axis: roll, 1. Select the portion of the log where the maneuver occurred. 2. Ensure the window starts from level flight and covers the full maneuver. -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: - i. We are interested in frequencies between 0.5-10Hz - ii. Values > 0.6 are sufficient - iii. If the coherence function is oscillating dramatically, the identified model may be unreliable at those frequencies. +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: \ + i. We are interested in frequencies between 0.5-10Hz \ + ii. Values > 0.6 are sufficient \ + iii. If the coherence function is oscillating dramatically, the identified model may be unreliable at those frequencies. \ 4. Once you have identified the window, load the selection into the tool.
From b353f74cc136be40127925352be84aefdf205b13 Mon Sep 17 00:00:00 2001 From: Mathieu Bresciani Date: Wed, 3 Sep 2025 11:15:44 +0200 Subject: [PATCH 4/5] Update autotune/README.md --- autotune/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autotune/README.md b/autotune/README.md index d29090b..0b8d5ce 100644 --- a/autotune/README.md +++ b/autotune/README.md @@ -61,7 +61,7 @@ Using default PX4 gains. Perform these maneuvers separately for each axis: roll, 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: \ i. We are interested in frequencies between 0.5-10Hz \ ii. Values > 0.6 are sufficient \ - iii. If the coherence function is oscillating dramatically, the identified model may be unreliable at those frequencies. \ + iii. If the coherence function is oscillating dramatically, the identified model may be unreliable at those frequencies. 4. Once you have identified the window, load the selection into the tool.
From ffecaa2bc61548ed8c4b648df4ea0e077548d023 Mon Sep 17 00:00:00 2001 From: Mathieu Bresciani Date: Wed, 3 Sep 2025 11:17:42 +0200 Subject: [PATCH 5/5] Apply suggestions from code review --- autotune/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autotune/README.md b/autotune/README.md index 0b8d5ce..640ca7c 100644 --- a/autotune/README.md +++ b/autotune/README.md @@ -59,8 +59,8 @@ Using default PX4 gains. Perform these maneuvers separately for each axis: roll, 1. Select the portion of the log where the maneuver occurred. 2. Ensure the window starts from level flight and covers the full maneuver. 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: \ - i. We are interested in frequencies between 0.5-10Hz \ - ii. Values > 0.6 are sufficient \ + i. We are interested in frequencies between 0.5-10Hz. \ + ii. Values > 0.6 are sufficient. \ iii. If the coherence function is oscillating dramatically, the identified model may be unreliable at those frequencies. 4. Once you have identified the window, load the selection into the tool.