C_uart_interface_example auto take off does not work

Hi, I’ve got my laptop running the c_uart_interface_example over a wireless Mavlink dongle. The program will communicate with the drone successfully, and I see the drone arm and disarm.

The problem is that the “-a” command line option to perform take off does not work.

Does anyone have any suggestions what might be going wrong?


I presume you’re using the example from here: https://github.com/mavlink/c_uart_interface_example?

In that case, the above example is for PX4. It may not be 100% compatible with ArduPilot.

Yes, that is the example I am using.

I would like to use this with Ardupilot and Pixhawk 1. I assumed that Mavlink commands were compatible with Ardupilot.

Most MAVLink commands are compatible. Unfortunately there is a small set of commands that are either ArduPilot-only or PX4-only.

Your issue is one such example - the c_uart_interface_example uses the PX4 OFFBOARD flight mode. To work with ArduPilot, the example would have to be changed to instead use the more generic GUIDED flight mode.

Okay, this sounds interesting. In the example code I see “MAV_CMD_NAV_GUIDED_ENABLE” but nothing about “OFFBOARD”.

int Autopilot_Interface::toggle_offboard_control(bool flag)
	// Prepare command for off-board mode
	mavlink_command_long_t com = { 0 };
	com.target_system    = system_id;
	com.target_component = autopilot_id;
	com.command          = MAV_CMD_NAV_GUIDED_ENABLE;

Ahh, OK. Looks like the PX4 people re-labelled GUIDED mode as OFFBOARD mode.

Looking more deeply, I think this is the issue:

I think the MAVLINK_MSG_SET_POSITION_TARGET_LOCAL_NED_TAKEOFF guided mode sub-command isn’t supported by ArduPilot.

1 Like

Yes, I think you’re onto something.

./ArduCopter/GCS_Mavlink.cpp has no reference to MAVLINK_MSG_SET_POSITION_TARGET_LOCAL_NED_TAKEOFF

It does have a reference to:

Without going into the code much more at the moment, I wonder if this would make things work?

I decided to look at the Ardupilot source code.

In GCS_MAVLINK_Copter::handleMessage we see the following different bits of type_mask being checked:

The latter macros are defined in include/mavlink/v2.0/common/common.h which tellingly does not have any set to 0x1000 == 4096 (MAV_CMD_NAV_GUIDED_ENABLE)!

This suggests the example code is broken for takeoff for all Mavlink platforms.

I meant to say:

The latter macros are defined in include/mavlink/v2.0/common/common.h which tellingly does not have any set to 0x1000 == 4096 (MAVLINK_MSG_SET_POSITION_TARGET_LOCAL_NED_TAKEOFF)!