Heading drift in acceleration mode in gz sim

Running make px4_sitl gz_x500

Using the offboard control in mavsdk and setting an acceleration setpoint of just 5 north and 0 down and 0 east, the drone heads in the correct direction but the heading drifts anticlockwise. Does anyone know how to fix this?

I would first separate the translational command from the yaw control path.

An acceleration setpoint of (North=5, East=0, Down=0) defines the desired translational acceleration, but it does not by itself necessarily define the vehicle heading.

I’d log/inspect:

commanded acceleration → yaw/yaw-rate setpoint → vehicle yaw → yaw-rate → actuator/control response

In particular, check what MAVSDK is actually sending for the yaw/yaw-rate field with your acceleration command. If heading is expected to remain fixed, make that yaw behaviour explicit rather than assuming the acceleration vector constrains it.

A useful isolation test would be:

  1. hover and hold an explicit fixed yaw;
  2. apply the same north acceleration;
  3. check whether the yaw setpoint remains constant while the measured yaw begins drifting.

If the yaw setpoint itself moves, investigate the Offboard/MAVSDK command path. If the setpoint remains fixed but vehicle yaw diverges from it, then move downstream into the PX4 attitude/rate controller and simulator dynamics.

A short ULog from this minimal test would make the distinction very clear.