MAVROS

On this page 7

MAVROS is an open-source ROS package that translates MAVLink messages into ROS topics, services and parameters, so that robotics software can read the state of an autopilot and send it commands. In drone software & autonomy, it is the classic bridge between a flight controller running PX4 or ArduPilot and the high-level code on a companion computer that handles perception, planning and mission logic for drones.

The flight controller keeps the fast, safety-critical loops: attitude stabilization, motor mixing and state estimation. MAVROS lets a ROS developer treat that controller as just another ROS node, subscribing to pose and battery data and publishing setpoints, without writing raw MAVLink parsing code.

How MAVROS connects ROS to an autopilot

MAVROS works as a protocol translator with a plugin architecture. The core node opens a link to the flight controller, decodes incoming MAVLink packets and dispatches each message type to a plugin that republishes it as a typed ROS message. In the other direction, plugins convert ROS messages into MAVLink commands and send them to the autopilot.

The link is defined by the `fcu_url` parameter. A typical value is serial:///dev/ttyACM0:921600 for a USB or UART connection, or udp://:14540@127.0.0.1:14557 for a simulated PX4 vehicle in SITL. A second parameter, `gcs_url`, can forward the same traffic to a ground control station such as QGroundControl, which lets the operator watch the vehicle while ROS code controls it.

The table below lists the plugins that most autonomy projects rely on and the ROS interfaces they expose.

PluginMain ROS interfacePurpose
sys_status/mavros/stateConnection, armed state and flight mode
local_position/mavros/local_position/poseVehicle pose in the local frame
setpoint_position/mavros/setpoint_position/localSend position targets
setpoint_raw/mavros/setpoint_raw/localMixed position, velocity and acceleration targets
command/mavros/cmd/armingArm, disarm, take off and land
vision_pose/mavros/vision_pose/poseFeed external pose estimates to the estimator
waypoint/mavros/mission/pushUpload and read missions
Commonly used MAVROS plugins

Coordinate frames and the ENU to NED conversion

One of the most valuable and least visible jobs of MAVROS is automatic frame conversion. ROS follows the conventions of REP 103 and REP 105: a world frame that is East-North-Up (ENU) and a body frame that is forward-left-up. PX4 and ArduPilot use North-East-Down (NED) and a forward-right-down body frame.

MAVROS rotates positions, velocities and orientations between these conventions so that ROS code can stay in ENU. A frequent source of crashes is converting the frames twice, for example by publishing NED data to a MAVROS topic that already expects ENU. The comparison below shows the mapping.

QuantityROS sideAutopilot side
World axesEast, north, upNorth, east, down
Body axesForward, left, upForward, right, down
Positive yawCounterclockwise from eastClockwise from north
Altitude signUp is positiveDown is positive
Frame conventions on each side of the bridge

Global coordinates add another subtlety. Autopilots report altitude above the WGS84 ellipsoid or above mean sea level depending on the message, and MAVROS uses the GeographicLib geoid datasets to convert between them. Without those datasets installed, the node refuses to start or reports incorrect heights.

Offboard and guided control through MAVROS

The main reason teams adopt MAVROS is external control of the vehicle from a companion computer. On PX4 this is called offboard mode; on ArduPilot the equivalent is guided mode. The ROS node publishes setpoints, and the autopilot tracks them with its own controllers.

PX4 enforces a strict handshake. The ROS node must stream setpoints at more than 2 Hz before requesting offboard mode, and if the stream stops for longer than the configured timeout, the autopilot triggers a failsafe such as hold, return or land. Practical systems publish at 20 to 50 Hz to leave margin for scheduling jitter.

  1. Wait until /mavros/state reports that the link is connected.
  2. Start streaming setpoints at a steady rate, usually the current position.
  3. Call the set_mode service to request offboard or guided mode.
  4. Call the arming service and confirm the armed state.
  5. Update setpoints continuously and monitor state for failsafe transitions.

The same mechanism carries external pose estimates. Visual-inertial odometry or a motion-capture system publishes to the vision pose or odometry topic, MAVROS forwards it as MAVLink, and the autopilot estimator fuses it, which enables flight without GPS indoors or under bridges.

MAVROS compared with other integration options

MAVROS is one of several ways to connect high-level software to an autopilot, and the right choice depends on the middleware, the autopilot and the latency budget. The table compares it with the neighboring options in the same toolchain.

OptionInterface styleBest fit
MAVROSROS topics and services over MAVLinkROS projects on PX4 or ArduPilot
MAVSDKC++, Python and other language APIsApplications without ROS
PX4 uXRCE-DDS bridgeNative ROS 2 topics from PX4 uORBROS 2 projects on PX4 only
Raw MAVLink librariesDirect message encodingCustom or embedded tools
Integration options for companion computer software

MAVROS remains attractive because it is autopilot-neutral: the same ROS code can drive PX4 and ArduPilot with minor changes. Its cost is an extra translation layer, and on PX4 with ROS 2 the native DDS bridge offers lower latency and access to internal uORB topics that MAVLink never exposes.

Deployment practices and common pitfalls

Most MAVROS problems come from configuration rather than code. Telemetry rates, serial bandwidth and version mismatches cause the majority of field failures, and they rarely show up in simulation. The following table links typical symptoms to their usual causes.

SymptomLikely causeFix
No data on pose topicsAutopilot not streaming those messagesRequest rates with the message interval service
Offboard request rejectedNo setpoint stream before the switchStream setpoints before changing mode
Vehicle drifts in wrong directionFrames converted twicePublish ENU data only
Node fails at startupMissing GeographicLib datasetsInstall the geoid datasets
Laggy or dropped messagesSerial baud rate too lowUse 921600 baud or Ethernet
Typical MAVROS symptoms and fixes
  • Test every flight behavior in SITL with the same launch files before flying hardware.
  • Keep the MAVROS, ROS and autopilot versions aligned, because message definitions evolve.
  • Plan migration away from ROS 1, since ROS Noetic reached end of life in May 2025 and new work targets ROS 2.
  • Keep a manual override on the RC transmitter for every offboard test.

A non-technical view

A drone has a small built-in computer that keeps it stable in the air, and it speaks its own message language. Robotics programs that recognize obstacles or plan routes usually speak a different language called ROS. MAVROS is the interpreter between the two.

With MAVROS in place, a smarter onboard computer can ask the drone where it is and tell it where to go next, while the flight controller still does the delicate work of staying balanced. The drone keeps its reflexes, and the extra computer adds the judgment.

A concrete example

A university robotics team builds a quadcopter to inspect the underside of a concrete bridge, where GPS reception is poor. The flight controller runs PX4, and an onboard Jetson computer runs ROS 2 with a stereo camera for visual-inertial odometry. MAVROS connects the two over a UART link at 921600 baud.

The odometry node publishes the drone pose at 30 Hz to the MAVROS vision pose topic, and PX4 fuses it in its estimator. A planning node then streams position setpoints at 20 Hz, switches the vehicle to offboard mode and flies a lawnmower pattern 2 meters below the deck. After weeks of SITL testing with the same launch files, the team completes the survey with stable position hold without GPS and a pilot ready to retake manual control.