-
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
Replace old PID library with a new unit tested C++ class #23931
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, seems to be a lot easier to implement then the old library.
I just have one fix on the implementation in the ackermann module (which is due to the fact that I had initially implemented the old PID library wrong) and a suggestion on handling the Output/Integral limits.
src/modules/rover_ackermann/RoverAckermannControl/RoverAckermannControl.cpp
Outdated
Show resolved
Hide resolved
src/modules/rover_ackermann/RoverAckermannControl/RoverAckermannControl.cpp
Outdated
Show resolved
Hide resolved
FLASH Analysispx4_fmu-v5x
px4_fmu-v6x
Updated: 2024-11-26T13:10:55 |
9663c0e
to
5640287
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes fix the unit tests, but I also noticed that the integral is delayed in the output by one update step. Is this on purpose?
Co-authored-by: chfriedrich98 <125505139+chfriedrich98@users.noreply.github.com>
…teration Co-authored-by: chfriedrich98 <125505139+chfriedrich98@users.noreply.github.com>
Thanks @chfriedrich98 for following up! I didn't even realize the tests were failing 🙈 I accepted both your suggestions but changed them as in having a separate function for the derivative since we'll likely add filtering to it, similar to https://github.com/PX4/PX4-Autopilot/blob/e194a52907083783f7e67ff93504016ca1275ce8/src/lib/mathlib/math/filter/FilteredDerivative.hpp and having the test verify the reset to zero and the first integral update. |
MAVROS fails on every new pr 😬 |
Solved Problem
When doing heli rpm and boat control I found that there is a PID library in PX4 which is pretty tedious to use.
Solution
I wrote a new one with a C++ interface and unit tests.
Changelog Entry
Test coverage
I successfully used this library for heli rpm control and boat heading control but without a derivative term. PI control only.
For a more practical derivative implementation it'd need a filter on the derivative and possibly one that considers the change of error not just feedback.
Note that the PID speed control instance in
RoverPositionControl
supplied a vehicle acceleration but configured the old library withPID_MODE_DERIVATIV_CALC
which made it calculate a numerical derivative and ignore the provided acceleration all along:aef5225#diff-0e5af3f25fa84fecddb10c4607acaf89f788f58553835199b217b5d230dfde14R142
FYI @TomasTwardzik