Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add D-term to control loop on fixed wing #6669

Merged
merged 8 commits into from
Mar 8, 2021

Conversation

avsaase
Copy link
Member

@avsaase avsaase commented Mar 4, 2021

Closes #3732 (multirotors now have CD so FF is no longer needed)

I have not tested this yet, but @rts18 has and says it works well. I hope he can add his findings here.

src/main/fc/settings.yaml Outdated Show resolved Hide resolved
src/main/flight/pid.c Outdated Show resolved Hide resolved
@avsaase avsaase requested a review from DzikuVx March 4, 2021 11:01
@rts18
Copy link

rts18 commented Mar 4, 2021

This test was done with a Dart250G.

This clip shows two back to back flights. The first part is with PIFF and the second part is PIDFF.
Keep an eye on the Roll axis OSD elements average roll angle, between the two clips.

Its been windy here of late and its nice to see the Dart tamed a little under these conditions.

The servo frame rate was set to 160hz.

Its obviously impossible to make a fixed wing as stable as a quad. With that considered, the results of the test on this airframe seem promising.
I think it will work even better on larger airframes, that have more powerful servo's.

PIFF_PIDFF.mp4

@DzikuVx
Copy link
Member

DzikuVx commented Mar 4, 2021

@rts18 could you share the Dgains you used for the test?

@avsaase
Copy link
Member Author

avsaase commented Mar 4, 2021

These are the setting @rts18 sent me via RCG pm:

set fw_p_pitch = 6
set fw_i_pitch = 13
set fw_d_pitch = 1
set fw_ff_pitch = 38
set fw_p_roll = 3
set fw_i_roll = 8
set fw_d_roll = 15
set fw_ff_roll = 25
set fw_p_yaw = 1
set fw_i_yaw = 1
set fw_d_yaw = 0
set fw_ff_yaw = 8
set fw_p_level = 24
set fw_i_level = 4
set fw_d_level = 70
set max_angle_inclination_rll = 500
set max_angle_inclination_pit = 350
set roll_rate = 50
set pitch_rate = 18
set fw_turn_assist_pitch_gain = 0.150
set fw_iterm_limit_stick_position = 0.200
set airmode_type = STICK_CENTER_ONCE
set servo_pwm_rate = 160
set gyro_hardware_lpf = 98HZ
set gyro_lpf_hz = 22
set dynamic_gyro_notch_enabled = ON
set dynamic_gyro_notch_q = 250
set dynamic_gyro_notch_min_hz = 35

I hope to test fly this myself this weekend.

@avsaase
Copy link
Member Author

avsaase commented Mar 4, 2021

@DzikuVx, what do I do with the commits that make the D and FF gains adjustable via the osd menu? I initially worked on that in the same branch so the commit history is a bit confusing. Is it not better to just push it to this branch? Testing this feature when the only way to change the gains is the CLI is a PITA anyway.

@rts18
Copy link

rts18 commented Mar 4, 2021

@rts18 could you share the Dgains you used for the test?

The settings @avsaase pasted, show that I focused on the roll axis D gain. The Dart250 showed no bad tendencies on the pitch axis.
@avsaase mention to me the the D gain is scaled by 1905, not 31 like the other gains. I assume this is the reason I had to set it that high.
@DzikuVx how differently will the current multi rotor D-term mechanics and filters affect a fixed wing?

src/main/flight/pid.c Show resolved Hide resolved
@DzikuVx DzikuVx merged commit 44d6a15 into iNavFlight:master Mar 8, 2021
@DzikuVx DzikuVx added this to the 2.7 milestone Mar 8, 2021
@avsaase
Copy link
Member Author

avsaase commented Mar 8, 2021

Awesome! Thanks Pawel.

@jeffkub
Copy link
Contributor

jeffkub commented Mar 14, 2021

I'm actually in the middle of tuning my race wing (CTH Rebel 40") and could use the D term to help dampen the response on sharp stick movements. Configured for 650 deg/s on the roll axis but getting a decent bit of bounce-back. Running good quality digital servos at 330Hz so it may be able to take advantage of this. I'll give this a shot the next time the weather allows.

@avsaase
Copy link
Member Author

avsaase commented Mar 14, 2021

@jeffkub let us know how it went. On my Dart 250 I increased the P to ten times what autotune gave me, and set D equal to P. I also set dterm_lpf_hz = 10 to limit the super fast jitters and reduce the wear on the servos.

@jeffkub
Copy link
Contributor

jeffkub commented Mar 16, 2021

@jeffkub let us know how it went. On my Dart 250 I increased the P to ten times what autotune gave me, and set D equal to P. I also set dterm_lpf_hz = 10 to limit the super fast jitters and reduce the wear on the servos.

Managed to get a tuning session in yesterday - added in a bit of d term and saw some notable improvement in the handling of the roll axis. Here was my tune at the start of the day.

no d term

Here it is after adding d-term and a few tweaks

with d term

with these settings

set fw_p_pitch = 9
set fw_i_pitch = 14
set fw_d_pitch = 6
set fw_ff_pitch = 67
set fw_p_roll = 6
set fw_i_roll = 3
set fw_d_roll = 4
set fw_ff_roll = 22
set fw_p_yaw = 0
set fw_i_yaw = 0
set fw_ff_yaw = 0
set mc_iterm_relax_cutoff = 9
set tpa_rate = 40
set tpa_breakpoint = 1750
set rc_expo = 30
set rc_yaw_expo = 30
set roll_rate = 65
set pitch_rate = 25
set yaw_rate = 9

I'll have to give dterm_lpf_hz = 10 a try next time.

@avsaase avsaase added the Release Notes Add this when a PR needs to be mentioned in the release notes label May 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release Notes Add this when a PR needs to be mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change both MC and FW PID controllers to P+I+D+FF
4 participants