-
-
Notifications
You must be signed in to change notification settings - Fork 599
Expanded capabilities for setting flight mode #2761
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
Expanded capabilities for setting flight mode #2761
Conversation
|
Just FYI I'm working on the mavsdk_server fix, I thought I would be able to re-use datatypes in the proto but I was wrong. Will push fix soon |
|
Should be good to go now (I think) |
| if (allow_mode) { | ||
| px4_mode.main_mode = custom_mode; | ||
| px4_mode.sub_mode = sub_custom_mode; | ||
| uint8_t system_base_mode = get_base_mode(); |
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.
Just noting: I added this because the CUSTOM_MODE_ENABLED flag is required to correctly interpret the custom mode, but it's not set here. You can get into a situation where the default state is "non custom", but the ground station attempts to set a custom mode and it isn't actually recorded as custom.
|
We'll have to wait until GitHub Actions are happy again. |
Not the first time I've opened a PR on a github "down day". Starting to wonder if it's me 😅 |
|
Looking better now |
|



Summary Of Changes
This is the companion PR to the proto changes made here:
mavlink/MAVSDK-Proto#391
The PR implements the changes associated with the proto updates, and also adds support for the MAVLINK SET_MODE command
Justification For Changes
In addition to the notes provided in the proto PR, the main reason for adding the SET_MODE support is that this command is still the primary means by which QGroundControl sets flight mode on an autopilot, and in particular PX4. Since flight modes in MAVSDK are forced to be PX4 custom, in order to be interoperable with QGC in a straightforward way, we need to handle SET_MODE instead of DO_SET_MODE.
As a note about some of the stickier nuance here, QGC expects all custom flight modes to be represented as a single 32-bit value, which is indeed how the SET_MODE command treats it. DO_SET_MODE breaks this into two separate fields. QGroundControl could also be updated to expand this (and arguably should be), but there's also no reason that MAVSDK can't support this very standard MAVLINK message.
As always please don't hesitate to reach out with questions.