-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
PID autotuner for velocity loop #12479
Conversation
Great description. This could go straight into a blog or release note when the feature delivers. |
0437012
to
0d09812
Compare
…loop The strategy adopted is to force an oscillation, find the ultimate gain and period, and compute the PID gains using Ziegler-Nichols rules.
…r when it has to rescale xy thrust for altitude control
…y with the current FlightTask structure
5e3caf3
to
832fb04
Compare
@PX4/testflights Can you test that PR during a calm (almost no wind) day please?
NOTE the drone will oscillate, this is normal but it should be a controlled oscillation, if this is too extreme, and the drone becomes unstable, simply move the sticks to abort the procedure. You can also switch to stabilized and it will stop. Also do not forget to save the previous |
@bresch we are testing this pr and no changes on MPC_XY_VEL_[PID] tested on pixhawk 4 v5 f-450 pr log= https://review.px4.io/plot_app?log=534ce58c-5022-4e41-bba0-b874591cd7a0 |
Tested on PixRacer V4:Process: Log: Tested on Pixhawk 2 Cube V3:Process: Log: Tested on CUAV+ V5:Process: Log: |
Unfortunately that didn't work as expected. The learning rate is apparently too fast--the critical gain has been underestimated. I have to find a more appropriate learning rate. |
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions. |
No, this isn't dead, I'm going to work on it at some point |
Great initiative @bresch . I also think the tuning of the outer PID loops such as the transnational states vx/vy/vz/x/y/z are dependent on how well tuned the lower level PID loops (rotational states roll_rate/roll ... etc). So I was wondering if this should be done first? I am personally working on an LQR-based + Genetic Algorithm method for tuning the attitude PID loops using ulog files. Will release once I get a usable version. |
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions. |
I'll continue to work on that after #14212 gets merged. |
This issue has been automatically marked as stale because it has not had recent activity. Thank you for your contributions. |
I'll rebase and continue it now that we have the interface for acceleration input in place! |
Closing as stale, leaving the branch. |
Describe problem solved by the proposed pull request
I've never seen anyone tuning the velocity loop. The main reason is that it's really hard to visualize the velocity tracking while flying and it usually "looks okay". After inspecting many log files, I realized that many velocity loops are poorly tuned.
A common practice of the users to "fix" the poorly tuned velocity loops is to modify the parameters of the setpoints such that the handling qualities requirements are fulfilled in most situations (e.g.:a fast-moving setpoint reduces the reaction delay of a poorly tuned loop). The drawback of this approach is that the response does not follow properly the setpoint and that limited dynamics of the setpoint won't be properly applied by the drone (the drone can exceed acceleration and jerk limits in some conditions).
The idea here is to provide a tool to the user to automatically adjust the PID gains of the velocity controller to easily achieve proper tracking.
The method is an improved version of the classical forced oscillation method that automates the tuning of the ultimate gain without introducing too many harmonics (a drawback of the relay-feedback experiment). Once the ultimate gain is found, the ultimate period is measured and the gains are computed using the well known Ziegler-Nichols rules (https://blog.opticontrols.com/archives/131)
Algorithm block diagram:
Additional features:
Usage:
MPC_XY_ATUNE
to 1 and wait until the tuning finishesYou can move the RC sticks at any time to abort the autotuning. To restart autotuning, set the parameter back to 1.
SITL tests:
Left: with parameters after the autotuning
Right: with default parameters
TODO