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

TinyMPC for PX4 #23820

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

TinyMPC for PX4 #23820

wants to merge 2 commits into from

Conversation

Pedro-Roque
Copy link
Member

@Pedro-Roque Pedro-Roque commented Oct 16, 2024

Solved Problem

Preliminary support for MPC on PX4 based on TinyMPC, more information here https://tinympc.org/ .

Solution

  • Adds tinympc as a library, which can then be used by each vehicle type

Changelog Entry

For release notes:

Feature/Bugfix XYZ
New parameter: XYZ_Z
Documentation: Need to clarify page ... / done, read docs.px4.io/...

Alternatives

Keep using PID.

Test coverage

  • Will be added

Context

More information to follow.

@Pedro-Roque Pedro-Roque changed the title TinyMPC for Quadrotors TinyMPC for PX4 Oct 16, 2024
.vscode/settings.json Outdated Show resolved Hide resolved
@Pedro-Roque
Copy link
Member Author

Pedro-Roque commented Oct 16, 2024

@dagar @MaEtUgR Me and @Jaeyoung-Lim think that this could be an interesting addition to the PX4 control stack. Together with @sschoedel we are working on that capability. What do you think is a good way forward? We thought about providing a library (tinympc) and each user can create an MPC for the application in hand.

We will most likely start integration on https://github.com/DISCOWER/PX4-Space-Systems before merging it in, but we would like to have a solid baseplate for PX4 compatibility.

@oursland
Copy link

FWIW, integrating this was something I also had on my plate for my application. I'm interested in seeing it integrated in a way that could be used for multiple applications.

I believe TinyMPC can be applied for a generalized position controller as a selectable alternative to the existing controllers, but the application of constraints may be platform and application dependent.

@Pedro-Roque
Copy link
Member Author

Pedro-Roque commented Oct 16, 2024

@oursland That's great to hear that there is more interest on the community. Right now we are considering a few options for autogenerating models for application-specific use cases. Would be nice to hear what you think could be a good way forward.

Right now the biggest hurdle is compatibility of the existing PID stack vs what an MPC stack would look like. We are starting with providing thrust and attitude setpoints to start with, while we prepare the stack for it.

It also would be good to hear what are the community needs and why they can't be met with the existing infrastructure, so that there is a solid case for adding this capability.

"ros.distro": "humble"
"ros.distro": "humble",
"python.autoComplete.extraPaths": [
"/home/roque/gz_garden_ws/install/local/lib/python3.10/dist-packages",
Copy link
Member

Choose a reason for hiding this comment

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

roque?

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed!

PS: I really need to make sure that my .vscode is always ignored for committing in PX4

julianoes and others added 2 commits October 16, 2024 22:55
Otherwise, this will conflict with the MS5525DSO airspeed sensor.

add: tinyMPC

feat: ran once, let's make it run stable

feat: small changes to position MPC for ifdef compilation
@AlexKlimaj
Copy link
Member

Looking forward to this! How do you foresee the user being able to switch between PID and MPC?

@Pedro-Roque
Copy link
Member Author

Looking forward to this! How do you foresee the user being able to switch between PID and MPC?

Thanks @AlexKlimaj ! This is a big beast to integrate into every possible case, but we are starting in https://github.com/DISCOWER/PX4-Space-Systems/tree/dev-sc_tinympc by using it for a free-flyer platform (satellite-like dynamics), as a position controller that gives attitude setpoints. We are evaluating the best ways to generate models for the supported vehicle platforms (since it is a model-based controller, we can't just use the same MPC for everything), and it will not be the default control stack - that means the user will need to enable the MPC and provide extra parameters like mass, approximate inertia, bounds, etc. This might be integrated neatly in QGC, but I'd say we are far from getting there.

For now, we will make sure it sits well within the stack as a library and try setpoint stabilization, followed by trajectory tracking (which will involve re-sampling the generated trajectory according to the controller sampling time). And as always, we are super happy for any help / insights / suggestions we can get.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants