Offboard mode lets an external system — a companion computer, ROS 2 node, or MAVSDK application — take control of the vehicle by streaming setpoints to PX4 in real time. Instead of a pilot moving sticks, your software sends position, velocity, acceleration, attitude, body rate, or direct thrust commands over MAVLink or a ROS 2 topic. PX4 executes them through its normal control pipeline while continuously verifying that the external controller is alive. Offboard mode is designed for research, custom autonomy, and advanced automation scenarios where the predefined waypoint system of Mission mode is too rigid. It is the foundation for behaviors like dynamic trajectory following, formation flight, visual servoing, and model-predictive control. The tradeoff is that safety responsibility shifts significantly to you as the developer.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/PX4/PX4-Autopilot/llms.txt
Use this file to discover all available pages before exploring further.
What Offboard mode does
When Offboard mode is active, PX4 hands authority over the specified control axes to the external controller. TheOffboardControlMode message (ROS 2) or the type mask in a MAVLink setpoint message tells PX4 which internal control modules to disable so the external controller can write to them safely.
PX4 still handles low-level motor mixing, ESC communication, sensor fusion, and failsafe logic. Your controller operates at a higher level, injecting setpoints into PX4’s control loops rather than driving hardware directly (unless you choose direct actuator control, which bypasses everything).
Heartbeat requirement
PX4 requires a continuous proof-of-life signal from the external controller at 2 Hz minimum. This signal tells PX4 that the external system is healthy and responsive.- MAVLink: The setpoint messages themselves serve as the heartbeat. If setpoints stop arriving, PX4 starts a timer and triggers the offboard loss failsafe after
COM_OF_LOSS_Tseconds. - ROS 2: The
OffboardControlModetopic serves as the heartbeat. Stream it at 2 Hz or faster at all times. TheTrajectorySetpoint(and other setpoint topics) only need to be published when the setpoint value changes — butOffboardControlModemust be continuous.
The 2 Hz minimum is a floor, not a recommendation. In practice, stream your heartbeat and setpoints at 10–50 Hz for smooth control response. Irregular timing at the minimum rate will cause visible jitter in vehicle motion.
Setpoint types
The setpoint type determines which PX4 control loops remain active and which estimates (position, velocity, attitude) are required.ROS 2 setpoints
Set theOffboardControlMode field flags to enable the appropriate control level. Fields are prioritized from top to bottom — the first non-zero field determines the active control mode.
| Control level | OffboardControlMode flag | Required message | Required estimate |
|---|---|---|---|
| Position (NED) | position = true | TrajectorySetpoint | Position (GPS/VIO) |
| Velocity (NED) | velocity = true | TrajectorySetpoint | Velocity |
| Acceleration (NED) | acceleration = true | TrajectorySetpoint | Attitude |
| Attitude (FRD) | attitude = true | VehicleAttitudeSetpoint | Attitude |
| Body rate (FRD) | body_rate = true | VehicleRatesSetpoint | Angular velocity |
| Thrust + torque | thrust_and_torque = true | VehicleThrustSetpoint + VehicleTorqueSetpoint | None |
| Direct actuators | direct_actuator = true | ActuatorMotors + ActuatorServos | None |
TrajectorySetpoint, the actual active controller (position, velocity, or acceleration) depends on which fields in the message are non-NaN. Setting the velocity flag in OffboardControlMode but sending a non-NaN position value in TrajectorySetpoint will run the position controller — the OffboardControlMode flag alone does not override the setpoint content.
MAVLink setpoints
- Multicopter / VTOL
- Fixed-wing
Use
SET_POSITION_TARGET_LOCAL_NED with frame MAV_FRAME_LOCAL_NED or MAV_FRAME_BODY_NED:- Position setpoint: set
x,y,z - Velocity setpoint: set
vx,vy,vz - Combined position + velocity: both non-zero; velocity is used as a feedforward term
SET_ATTITUDE_TARGET for attitude control:- Attitude quaternion (
q) + thrust scalar - Body rates (
body_roll_rate,body_pitch_rate,body_yaw_rate) + thrust scalar
ROS 2 offboard example pattern
The standard pattern for a ROS 2 offboard controller follows these steps:Set up the ROS 2 publisher
Create publishers for
OffboardControlMode and TrajectorySetpoint (or whichever setpoint topic matches your control level). Create a subscriber for VehicleStatus to monitor the current flight mode.Stream the heartbeat before requesting Offboard mode
Start a timer at 10 Hz and publish
OffboardControlMode on every tick. Publish your initial setpoint (typically the vehicle’s current position to avoid sudden jumps). Wait for at least 1 second (10 ticks) before sending the mode switch command.Arm and switch to Offboard mode
Send
VehicleCommand messages to arm the vehicle and switch to Offboard mode. Only do this after the heartbeat has been streaming for at least 1 second.Publish setpoints at your control rate
Continue streaming
OffboardControlMode as the heartbeat. Publish TrajectorySetpoint whenever you want the vehicle to move. Use NED coordinates (North-East-Down frame — positive Z is downward).Enabling and configuring Offboard mode
Key parameters
| Parameter | Description | Default |
|---|---|---|
COM_OF_LOSS_T | Time in seconds to wait after the offboard connection is lost before triggering the failsafe action | 1.0 s |
COM_OBL_RC_ACT | Failsafe action when offboard connection is lost: 0 = Position, 1 = Altitude, 2 = Manual, 3 = Return, 4 = Land | 0 (Position) |
COM_RC_OVERRIDE | Whether RC stick movement during Offboard mode switches to Position mode (not enabled for Offboard by default) | Disabled for Offboard |
COM_RC_STICK_OV | Stick deflection threshold (%) that triggers RC override when COM_RC_OVERRIDE is enabled | 30% |
COM_RCL_EXCEPT | Modes in which RC loss is ignored; set bit 2 to ignore RC loss in Offboard mode | 0 |
COM_RC_IN_MODE | Set to 4 to disable manual RC control entirely and allow offboard-only operation | 0 |
Activating Offboard mode
You can switch to Offboard mode via:- RC transmitter switch configured to Offboard in QGroundControl Vehicle Setup → Flight Modes
- MAVLink
MAV_CMD_DO_SET_MODEcommand (mode 6) - ROS 2
VehicleCommandmessage withVEHICLE_CMD_DO_SET_MODE
Safety considerations
Set a conservative COM_OF_LOSS_T
Set a conservative COM_OF_LOSS_T
The default 1-second timeout is aggressive. If your companion computer reboots, experiences a watchdog reset, or if your ROS 2 executor lags, the vehicle may switch to the failsafe action before you can recover. For development, consider setting
COM_OF_LOSS_T to 5–10 seconds and COM_OBL_RC_ACT to Return or Land. Tighten the timeout once your system is reliable.Always have an RC override path
Always have an RC override path
Keep an RC transmitter ready with a mode switch that can pull the vehicle into Position mode or Return mode. Even if
COM_RC_OVERRIDE is not enabled for Offboard mode by default, you can still switch modes manually via the mode switch. Test this override before every offboard flight.Validate setpoint continuity
Validate setpoint continuity
Large discontinuities in position setpoints cause sudden, violent vehicle motion. When starting offboard control, your first setpoint should be the vehicle’s current position. When ending offboard control, transition through Hold mode rather than cutting the setpoint stream abruptly.
Understand frame conventions
Understand frame conventions
PX4 uses NED (North-East-Down) coordinates internally. ROS 2 uses ENU (East-North-Up) by convention. The PX4 ROS 2 interface (
px4_msgs) uses NED — do not apply a standard ROS ENU-to-NED transform if you are using the raw PX4 uORB topics. Review the PX4-ROS 2 frame convention documentation carefully.Consider the PX4 ROS 2 Interface Library as an alternative
Consider the PX4 ROS 2 Interface Library as an alternative
The PX4 ROS 2 Interface Library provides a higher-level, safer API for offboard control. It handles the
OffboardControlMode heartbeat, mode switching, and some of the frame convention complexity for you. For production use cases, it is strongly preferred over the raw setpoint topics.