Acceleration control in offboard mode

I have been struggling with this issue for quite some time now.

I am trying to control a quadrotor using acceleration commands. My idea is to command the attitude and thrust using the /mavros/setpoint_raw/attitude. This seems to work, in the sense that the drone follows the commanded attitude and thrust. However, it’s not proper.

My issues are following:

  1. If I need the drone to have an acceleration (ax,ay,az) in the ENU frame, how should I compute the quaternion to be commanded.

  2. Currently I am using a PI controller on throttle to maintain the acceleration. Is there a better choice?

  3. If I read the current position and velocity from topic /local_position, what is the reference frame.

  4. Apart from IMU data, is any other value provided in body frame by MAVROS?

Any help is much appreciated.



  1. Multirotors can only accelerate towards the z axis, therefore you can define your attitude(quaternion) with the direction of acceleration being aligned with the body z-axis. the yaw is reduntant.

  2. I don’t think using a PI controller is a good idea. (how is your error defined?) If your acceleration is not aligned with the thrust direction it will result in high acceleration to compensate the error.

  3. The reference frame is the local inertial frame.

1 Like

Thanks a lot.
For the first part I have one more doubt. I am new to quaternions, that’s the issue.

If I find the required attitude in ENU frame, then should my command be q_curr * q_req, where q_curr is the current orientation of quadrotor in ENU frame, and q_req is the attitude of the acceleration vector. Is this correct?

The error in PI controller is the difference between the magnitude of required acceleration and current acceleration obtained from IMU.

Hi BossHater,

I am also trying to do acceleration control in Offboard mode.
How did you implement this?

Do you have a link to your github repo?

It seems like Acceleration control in offboard mode is not support yet from this comment in /home/esl/Masters/Developer/PX4/src/lib/FlightTasks/tasks/Offboard/FlightTaskOffboard.cpp

	// Acceleration
	// Note: this is not supported yet and will be mapped to normalized thrust directly.
	if (_sub_triplet_setpoint->get().current.acceleration_valid) {
		_thrust_setpoint(0) = _sub_triplet_setpoint->get().current.a_x;
		_thrust_setpoint(1) = _sub_triplet_setpoint->get().current.a_y;
		_thrust_setpoint(2) = _sub_triplet_setpoint->get().current.a_z;

@Murray_Louw It is supported now