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

MAVLink: add support for the AVAILABLE_MODES message #28566

Merged
merged 8 commits into from
Nov 13, 2024

Conversation

IamPete1
Copy link
Member

@IamPete1 IamPete1 commented Nov 9, 2024

This message allows the GCS to get the list of available modes at runtime. In the future this allows things like #28110

This requires: ArduPilot/mavlink#374

This message is supported by the QGC daily build and has been tested using it.

For example if you connect to a plane without Quadplane enabled it will only show the fixed wing modes:
image

If you enable quadplane and re-connect you will then see all modes:
image

Current master shows a preconfigured subset of modes:
image

Editing a mode name in the cpp proves that it is updated with the new message:
image

Future work (not for this PR):

  • Fillout the message more completely:

    • Set MAV_MODE_PROPERTY bitmask for each mode.
    • Set MAV_STANDARD_MODE enum for each mode
  • Report the current mode with the new CURRENT_MODE message

  • Send AVAILABLE_MODES_MONITOR to allow the GCS to notice and re-request if the number of modes changes.

  • Support MAV_CMD_DO_SET_STANDARD_MODE

  • Addition of new modes from scripting and more.

const Mode* modes[] {
#if MODE_AUTO_ENABLED
&copter.mode_auto, // This auto is actually auto RTL!
&copter.mode_auto, // This one is really is auto!
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why copy-paste twice?

Copy link
Member Author

Choose a reason for hiding this comment

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

Once is for auto RTL mode the other is for auto mode. Auto RTL is not a full mode, just auto mode with a some hacks so it presents as its own mode.

Copy link
Collaborator

@Ryanf55 Ryanf55 left a comment

Choose a reason for hiding this comment

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

Preliminary thoughts, will do a more thorough review tonight/tomorrow.

@@ -583,7 +583,8 @@ static const ap_message STREAM_EXTRA3_msgs[] = {
#endif
};
static const ap_message STREAM_PARAMS_msgs[] = {
MSG_NEXT_PARAM
MSG_NEXT_PARAM,
MSG_AVAILABLE_MODES
Copy link
Collaborator

Choose a reason for hiding this comment

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

What sets this rate, and did you consider making only send the mode on chance?

Copy link
Member Author

Choose a reason for hiding this comment

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

You can request the full list be sent where it would use this rate. QGC actually just requests the modes one at a time, so the stream rate doesn't really mean anything, it would be the SRx_PARAMS parameter.

@IamPete1 IamPete1 force-pushed the MAVLink_custom_modes branch 2 times, most recently from c40e5b7 to f5862c9 Compare November 10, 2024 10:57
@amilcarlucas
Copy link
Contributor

Binary Name      Text [B]        Data [B]     BSS (B)        Total Flash Change [B] (%)      Flash Free After PR (B)
---------------  --------------  -----------  -------------  ----------------------------  -------------------------
arducopter-heli  572 (+0.0314%)  0 (0.0000%)  -4 (-0.0015%)  572 (+0.0314%)                                   141000
antennatracker   576 (+0.0427%)  0 (0.0000%)  0 (0.0000%)    576 (+0.0426                                   613348
arducopter       576 (+0.0316%)  0 (0.0000%)  0 (0.0000%)    576 (+0.0316%)                                   140544
ardurover        444 (+0.0266%)  0 (0.0000%)  -4 (-0.0015%)  444 (+0.0266%)                                   294592
arduplane        564 (+0.0310%)  0 (0.0000%)  -4 (-0.0015%)  564 (+0.0310%)                                   143768
blimp            456 (+0.0332%)  0 (0.0000%)  0 (0.0000%)    456 (+0.0332%)                                   591440
ardusub          540 (+0.0335%)  0 (0.0000%)  4 (+0.0015%)   540 (+0.0334%)                                   350220

@Ryanf55
Copy link
Collaborator

Ryanf55 commented Nov 11, 2024

Binary Name      Text [B]        Data [B]     BSS (B)        Total Flash Change [B] (%)      Flash Free After PR (B)
---------------  --------------  -----------  -------------  ----------------------------  -------------------------
arducopter-heli  572 (+0.0314%)  0 (0.0000%)  -4 (-0.0015%)  572 (+0.0314%)                                   141000
antennatracker   576 (+0.0427%)  0 (0.0000%)  0 (0.0000%)    576 (+0.0426                                   613348
arducopter       576 (+0.0316%)  0 (0.0000%)  0 (0.0000%)    576 (+0.0316%)                                   140544
ardurover        444 (+0.0266%)  0 (0.0000%)  -4 (-0.0015%)  444 (+0.0266%)                                   294592
arduplane        564 (+0.0310%)  0 (0.0000%)  -4 (-0.0015%)  564 (+0.0310%)                                   143768
blimp            456 (+0.0332%)  0 (0.0000%)  0 (0.0000%)    456 (+0.0332%)                                   591440
ardusub          540 (+0.0335%)  0 (0.0000%)  4 (+0.0015%)   540 (+0.0334%)                                   350220

It could be wrapped in an ifdef to reduce impact

@IamPete1
Copy link
Member Author

It could be wrapped in an ifdef to reduce impact

It could, but I think it should be defined in by default. This allows the GCS to accurately relay the modes the vehicle has. This is important on low flash boards where modes are likely to be removed to save flash. Plane vs Quadplane for example.

@tridge tridge merged commit f08a212 into ArduPilot:master Nov 13, 2024
99 checks passed
@hamishwillee
Copy link
Contributor

Very cool @IamPete1

Note, we recently merged the rtl and safety return standard modes, which may affect this mavlink/mavlink#2191

@IamPete1
Copy link
Member Author

Very cool @IamPete1

Note, we recently merged the rtl and safety return standard modes, which may affect this mavlink/mavlink#2191

Thanks! Although we support the available modes stuff we don't do the standard mode thing yet. Everything is still "custom". But I think we will in the future.

@hamishwillee
Copy link
Contributor

Thanks @IamPete1 . I'm hoping you do too - better for the GCS and for users.

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

Successfully merging this pull request may close these issues.

6 participants