MAVLink Interface Definitions

Make table in gitbook here

The definitions that are used through the MAVlink protocol for the complex trajectory tracking are defined in the SET_POSITION_TARGET_LOCAL_NED message and can be seen in the following table:

Field NameTypeUnitsValueDescription

time_boot_ms

uint32_t

ms

Timestamp (time since system boot)

coordinate_frame

uint8_t

Variety of valid options are available listed here.

type_mask

uint16_t

x

float

m

X Position in NED frame

y

float

m

Y Position in NED frame

z

float

m

Z Position in NED frame (note, altitude is negative in NED)

vx

float

m/s

X velocity in NED frame

vy

float

m/s

Y velocity in NED frame

vz

float

m/s

Z velocity in NED frame

afx

float

m/s/s

X acceleration or force (if bit 10 of type_mask is set) in NED frame in meter / s^2 or N

afy

float

m/s/s

Y acceleration or force (if bit 10 of type_mask is set) in NED frame in meter / s^2 or N

afz

float

m/s/s

Z acceleration or force (if bit 10 of type_mask is set) in NED frame in meter / s^2 or N

yaw

float

rad

yaw setpoint

yaw_rate

float

rad/s

yaw rate setpoint

From this list of definition, all of them can be set or a select few, it all depends on what the user desires before setting the type_mask field appropriately. For the tracking in this example, we will set every field to ensure ideal tracking of the trajectory.

One thing to take note is the MAVlink message above receives values assuming they are set in the North East Down (NED) reference frame which is the reference frame PX4 operates in. The reference frame ROS uses, and one many users are more intuitively familiar with, is the East North Up (ENU) frame where positive altitude is upwards. Fortunately this is the reference frame we will work in when publishing the setpoints using MAVROS, this is because the MAVROS node takes care of the reference frame conversion for us as can be seen in the setpoint_raw plugin. This is the plugin that will be used for publishing setpoints discussed in the MAVROS Topics section.

MAVROS Topics

A complete list of MAVROS topics can be found:

The important MAVROS topics and services used with Clover can be referenced from their website:

Where the information is repeated here:

Main services

/mavros/set_mode โ€” set flight mode of the controller. Most often used to set the OFFBOARD mode to accept commands from Raspberry Pi.

/mavros/cmd/arming โ€” arm or disarm drone motors (change arming status).

Main published topics

/mavros/state โ€” status of connection to the flight controller and flight controller mode.

/mavros/local_position/pose โ€” local position and orientation of the copter in the ENU coordinate system.

/mavros/local_position/velocity โ€” current speed in local coordinates and angular velocities.

/mavros/global_position/global โ€” current global position (latitude, longitude, altitude).

/mavros/global_position/local โ€” the global position in the UTM coordinate system.

/mavros/global_position/rel_alt โ€” relative altitude (relative to the arming altitude).

Messages published in the topics may be viewed with the rostopic utility, e.g., rostopic echo /mavros/state. See more in working with ROS.

Main topics for publication

/mavros/setpoint_position/local โ€” set target position and yaw of the drone (in the ENU coordinate system).

/mavros/setpoint_position/global โ€“ set target position in global coordinates (latitude, longitude, altitude) and yaw of the drone.

/mavros/setpoint_position/cmd_vel โ€” set target linear velocity of the drone.

/mavros/setpoint_attitude/attitude and /mavros/setpoint_attitude/att_throttle โ€” set target attitude and throttle level.

/mavros/setpoint_attitude/cmd_vel and /mavros/setpoint_attitude/att_throttle โ€” set target angular velocity and throttle level.

Topics for sending raw packets

/mavros/setpoint_raw/local โ€” sends SET_POSITION_TARGET_LOCAL_NED message. Allows setting target position/target speed and target yaw/angular yaw velocity. The values to be set are selected using the type_mask field.

/mavros/setpoint_raw/attitude โ€” sends SET_ATTITUDE_TARGET message. Allows setting the target attitude /angular velocity and throttle level. The values to be set are selected using the type_mask field

/mavros/setpoint_raw/global โ€” sends SET_POSITION_TARGET_GLOBAL_INT. Allows setting the target attitude in global coordinates (latitude, longitude, altitude) and flight speed.

Last updated