Where to find custom mode list for MAV_CMD_DO_SET_MODE

I am trying to understand the offboard control example using ROS2 provided in the official docs and I came across a line of code that I couldn’t understand. The line of code is as follows:

this->publish_vehicle_command(VehicleCommand::VEHICLE_CMD_DO_SET_MODE, 1, 6);

After delving deeper into this line, I landed on this page: Messages (common) · MAVLink Developer Guide

Now my question is, where can I find the list of custom modes for param2 of the MAV_CMD_DO_SET_MODE Mavlink message?

I apologize if my question is not clearly understandable as I am a beginner in PX4 with ROS2. Thank you for your support.

1 Like

Hello, custom mode is the mod you can create.
Here is the example and also ENUM’s for other modes.
Adding a New Flight Mode to Copter — Dev documentation (for ardupilot)
Flight Modes | PX4 User Guide (px4)

Can I get more details on. 1 and 6 in that line of code

1 Like

Could you please send a file that you are referring to?

In this particular line
param1 is set 1 and param2 is set to 6
this->publish_vehicle_command(VehicleCommand::VEHICLE_CMD_DO_SET_MODE, 1, 6);

What does 1 and 6 indicate

Ok, so as you can see here:

void OffboardControl::publish_vehicle_command(uint16_t command, float param1, float param2)

we use command: MAV_CMD_DO_SET_MODE

in the structure of THIS exact command we have 3 params:

In line: this->publish_vehicle_command(VehicleCommand::VEHICLE_CMD_DO_SET_MODE, 1, 6);

We just use ENUM for VEHICLE_CMD_DO_SET_MODE (ENUM is just the variable that can be shown with name and not with nimbers just for easy use)
Next we have param 1: Mode
Mode is the vehicle mode we want, we can see here what modes we have Messages (common) · MAVLink Developer Guide
Note, that because they are combined, we cant be 100% sure what exactly does 1 mean (need to check flags).
Then we have param 2: it’s the line for the custom mode, we don’t know exactly again, so need to refer in ardupilot or PX4 specification.
And then we have param 3: it’s the submode, in this case we don’t use this, but it could help you when you create your own mode.

In another example I will send this command as:

this->publish_vehicle_command(VehicleCommand::VEHICLE_CMD_DO_SET_MODE, MAV_MODE_STABILIZE_DISARMED, 0, 0);
In this case I will just send a request for stabilized armed mode.

Where can I find these specifications?

You can read this topic:

1 Like

Thank you so much. From this thread i got a clear understanding of param2.
But I didn’t get any clarity regarding why param1 = 1
If you could give some more information in this regard it would be more helpful

1 Like

Actually in this case I just need to read some code, that ROS provided, because it seems that they use some custom mode, where 1 is CUSTOM_MODE: 1, and 6 is CUSTOM_SUBMODE: 6. Something like that. Glad I could help :slightly_smiling_face:

1 Like

After conducting some research and exploring the MAVLink messages documentation, I discovered that setting param1 to 1 enables the custom mode, as indicated in the documentation found here: MAV_MODE_FLAG.

Based on the assistance provided by @vurdlok, here is a brief summary of the solution for this issue:

  • param1 is set to 1 to enable the custom mode.
  • param2 is set to 6 to indicate the offboard mode.
    • Other options for param2 include:
      • param2 = 1 (MANUAL)
      • param2 = 2 (ALTCTL)
      • param2 = 3 (POSCTL)
      • param2 = 4 (AUTO)
      • param2 = 5 (ACRO)
      • param2 = 6 (OFFBOARD)
      • param2 = 7 (STABILIZED)
      • param2 = 8 (RATTITUDE)

For more information, you can refer to the PX4 Custom Mode file.

1 Like