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

MC rate controller: add I term reduction factor #12296

Merged
merged 2 commits into from
Jun 22, 2019
Merged

Conversation

bkueng
Copy link
Member

@bkueng bkueng commented Jun 17, 2019

As mentioned in #11560, as a result of keeping the integrators enabled, there is a bounce-back effect after a flip, due to integral build-up. This effect is non-linear, and therefore cannot be accounted for by the existing PID controller.

So this PR adds another factor to the I gain. It reduces the I gain in cases of very large rate tracking errors (in which case the P gain should reduce the error, not the I gain). The formula is visualized here: https://www.desmos.com/calculator/3o8tfaetan. Red is the existing behavior, and blue the adjusted I gain.
Up to 100 degrees tracking error, the behavior is nearly identical. And up to 200 degrees the gain is almost not reduced (<25%), so it really only takes effect where it should, without introducing steps. In the logs I checked, the tracking error is generally around or below 100 degrees for 'normal' flight.

The result is noticeably better, and it allows to considerably increase I gains in general w/o negative side-effects.

master:

bokeh_plot_roll_rate_i_factor_disabled

this PR:

bokeh_plot_roll_rate_i_factor_enabled

The better the rate tracking, the less this is required (because of the lower tracking error). At the same time it also does not harm, as the i_factor will always be close to 1.

I have flown this for several weeks/months and have not noticed any negative side-effects.

Here are some logs:

@bkueng bkueng requested a review from MaEtUgR June 17, 2019 09:42
bkueng added 2 commits June 18, 2019 08:21
Reduce the I gain for high rate errors to reduce bounce-back effects after
flips. Up to 200 degrees the gain is almost not reduced (<25%), so this
will only take noticeable effects for large errors (setpoint changes),
where we actually want to have an effect.

This allows to increase the MC_*RATE_I parameters w/o negative effects
when doing flips (i.e. bounce-back after flips).

The 400 degrees limit and the x^2 are empirical.

The better the rate tracking in general (high P gain), the less this is
required (because of the lower tracking error). At the same time it also
does not harm, as the i_factor will always be close to 1.
Previous commit allows to increase them again.
Partially reverts commit 6c3e79f.
@bkueng bkueng force-pushed the mc_rate_i_reduction branch from 538af66 to 8487830 Compare June 18, 2019 06:22
Copy link
Member

@MaEtUgR MaEtUgR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice practical solution!
Thanks for addressing this. To me it's understandable.

@bkueng bkueng requested a review from a team June 18, 2019 20:16
@dannyfpv
Copy link

tested on Pixhawk4 V5 f450
Modes Tested

mission Mode: no issue
Altitude Mode: no issue
Stabilized Mode: no issue
rtl mode: no issue
land mode no issue
pr log:
https://review.px4.io/plot_app?log=764bb85a-5700-436d-8e80-17ebb5c1036c
https://review.px4.io/plot_app?log=00e2d5da-5a92-4ec4-8bad-932d413992c1
master log:
https://review.px4.io/plot_app?log=cebcba34-7c87-46d0-aeaa-1d5073a54654

@jorge789
Copy link

Tested on Pixhawk 2 Cube V3:

Modes Tested

Position Mode: Good.
Altitude Mode: Good.
Stabilized Mode: Good.
Mission Plan Mode (Automated): Good.
RTL: Good.

Procedure
Arm and Take off in position mode, after flying for approximately one minute, switched to altitude then stabilized mode proceed to switch to mission plan mode then make sure that vehicle follows all waypoints as shown in QGC, once completed all waypoin activate RTL and see landing behaviour.

Notes:
No issues noted, good flight in general.

Log:
https://review.px4.io/plot_app?log=998c2fef-246c-451f-aa3e-a3d6437caede

https://review.px4.io/plot_app?log=bfc710a5-e8af-4218-8e55-6549738a0864

Logs: Comparison to master
https://review.px4.io/plot_app?log=96e68db9-e858-4c67-ae9c-34127a0e1c2f

Tested on PixRacer V4:

Modes Tested

Position Mode: Good.
Altitude Mode: Good.
Stabilized Mode: Good.
Mission Plan Mode (Automated): Good.
RTL: Good.

Procedure
Arm and Take off in position mode, after flying for approximately one minute, switched to altitude then stabilized mode proceed to switch to mission plan mode then make sure that vehicle follows all waypoints as shown in QGC, once completed all waypoin activate RTL and see landing behaviour.

Notes:
No issues noted, good flight in general.

Log:
https://review.px4.io/plot_app?log=269537b3-48f0-48fc-8d03-c51b8dd14084

@dagar dagar merged commit 64ac8c1 into master Jun 22, 2019
@dagar dagar deleted the mc_rate_i_reduction branch June 22, 2019 11:23
@dagar dagar added this to the Release v1.9.1 milestone Jun 24, 2019
@junwoo091400 junwoo091400 added Multirotor 🛸 Flight Controls 🦅 Anything about flight control algorithm (Navigation, Attitude control, etc) labels Aug 11, 2023
@DronecodeBot
Copy link

This pull request has been mentioned on Discussion Forum for PX4, Pixhawk, QGroundControl, MAVSDK, MAVLink. There might be relevant details there:

https://discuss.px4.io/t/pid-tuning-for-a-small-flying-wing-47-cm-wingspan/33705/5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Flight Controls 🦅 Anything about flight control algorithm (Navigation, Attitude control, etc) Multirotor 🛸
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants