I’m currently working on extending the PX4 firmware and I’d like to add a new custom flight mode for a multicopter. I’ve explored the existing flight modes in the codebase (like Position, Offboard, Auto, etc.), but I’m unsure about the complete process and correct files to modify in the latest version of PX4.
Could someone please guide me or point me to an updated, detailed step-by-step approach for:
Where to define the new mode (e.g., new enum or mode number)?
How to create and integrate the new mode logic (in which file should the control logic be written)?
How to register it so that it shows up in QGroundControl or via MAVLink?
Any changes needed in navigator, commander, or other modules?
I’ve found some older resources and GitHub threads, but they seem outdated or not compatible with the current PX4 master branch. If there’s a recommended way or if anyone has an example repo, that would be amazing!
If you want that it shows up in QGroundControl, you would have to extend the mavlink definition, which can be quite a hassle. If that is needed, I would point you towards the PX4 ROS 2 Interface Library you need an onboard computer for that (like a Raspberry Pi or similar), but this package is written specifically for that use case. You can create and overwrite flight modes, which work like internal flight modes and also get displayed in QGC
To clarify — my requirement is to add a new flight mode directly into the PX4 firmware itself, not via an external companion computer or ROS 2 interface. I’d like the mode to be embedded natively, just like Position, Altitude, or Hold modes, and I want to eventually have it selectable via QGroundControl.
If there’s a step-by-step approach (especially for the newer PX4 versions), or an example PR/reference repo that does this, I’d really appreciate it!