Skip to content

Acceleration

The toolkit calculates position/velocity feedback and sends a NED acceleration request to PX4. PX4 converts it to attitude/thrust and runs its lower feedback loops and control allocation. This handoff needs no physical mass in its acceleration law; the shared runtime still validates vehicle mass as part of the vehicle configuration.

Translation law

With \(e_x=x-x_d\) and \(e_v=v-v_d\) in NED:

\[ a_{\mathrm{cmd}}=a_d-\bar k_xe_x-\bar k_ve_v. \]

All terms are in m/s². At zero hover error the request is zero acceleration; PX4 applies gravity compensation below this interface. See the force derivation.

kx_over_mass (\(\bar k_x\)) and kv_over_mass (\(\bar k_v\)) are used directly; no mass multiplication or division occurs in the control law. Both gains must be finite and positive. The shared vehicle configuration also requires a positive mass, which is used only at physical-output or diagnostic boundaries.

Messages and timing

Only OffboardControlMode.acceleration is true; the other control-level flags are false. The active TrajectorySetpoint contains:

Field Value
acceleration \(a_{\mathrm{cmd}}\), NED m/s²
yaw Desired trajectory heading, rad
position, velocity, jerk NaN on all axes
yawspeed NaN
timestamp Publication time in microseconds

NaN means unused. Zero position or velocity would enable a different PX4 interpretation. The separately published /se3/trajectory_reference contains the full desired trajectory for analysis and is not this PX4 input.

The outer wall timer publishes at control_rate_hz (100 Hz by default) after Offboard confirmation. Readiness requires finite position/velocity plus all PX4 validity flags; attitude/rate state is not required for this handoff, except that the runtime also requires valid attitude when the selected trajectory is hover. The shared startup/return behavior applies.

Run and inspect

With a prepared airborne SITL vehicle, valid vehicle configuration, and no competing controller, in a separate repository-root shell:

source ros2/runtime_env.sh
ros2 launch offboard_controllers se3.launch.py \
  vehicle:=gz_f450 trajectory:=line_x handoff:=acceleration \
  publish_diagnostics:=true record:=true

Inspect position/velocity tracking, commanded acceleration, and PX4 attitude/thrust. Lower-loop response and saturation also affect tracking error.

The calculation is in translation.cpp; exact fields are in runtime/publication.cpp, selected by runtime/control.cpp.