A few questions about using SET_ATTITUDE_TARGET to set yaw and pitch

I’ve been trying to use MAVLINK_MSG_ID_SET_ATTITUDE_TARGET to get my drone to change its angle with limited success. The manoeuvre I am initially looking at is to yaw the drone, although eventually I will need pitch and pitch rate control, all using GUIDED mode.

I am aware that a quaternion must be set up and the thrust must be passed to the drone for it to respond to the SET_ATTITUDE_TARGET message however here is a video of what happens when I tell my drone to yaw by pi/2 rads = 90 degrees.

It seems to yaw by the right amount but why does the drone fly off in a direction? Surely it should just yaw on the spot? I supply a log here with password set as my username. The 90 degree yaw attempt happens at about 13:18:55.

When I tell the drone to yaw by pi rads = 180 degrees, this video shows the result. Why does it not yaw by 180 degrees as expected?

Must I run SET_ATTITUDE_TARGET repeatedly in order that the drone continues to that target and if so, how often? Is a single message (as I am currently sending) sufficient?

I am using the Ardupilot “Quaternion::from_euler” function to convert radians to quaternions and using the correct type_mask to ensure that all 3 of roll rate, pitch rate and yaw rate are ignored (is this correct?).

Many thanks and sorry for all the questions.

Okay, in case anyone is reading I have an answer to one of my questions which is, the drone yaws not in the body frame (I thought it did since the SET_ATTITUDE rates are specified as body frame rates) but in the global frame.

i.e. my command to tell it to yaw to pi/2 told it to yaw to face east. A quaternion yaw of pi will face south.

Still no idea about how often I must send SET_ATTITUDE_TARGET or why the drone flies off to the east in both situations.

What’s the typemask?

1 Like


Thrust set to 0.5 to maintain altitude.

are you using this branch?

1 Like

No, just the latest stable one. 4.11.