# Compensating for Yaw in Lateral Quadcopter Movement

I'm trying to make a quadcopter move laterally at a certain angle. I've been able to find the proper roll and pitch angles for this (that work with a yaw of 0°); how would I adjust these values to compensate for a different yaw?

This is just basic trigonometry; you'll covert your world-relative calculations of roll and pitch ($\phi$ and $\theta$) into vehicle-relative values, based on yaw ($\psi$).

Just so we're on the same page, I'm assuming measurements like the following, with roll, pitch, and yaw being zero when levelly flying North: $$\phi_{vehicle} = \phi_{world}\cos(\psi) - \theta_{world}\sin(\psi)$$ $$\theta_{vehicle} = \phi_{world}\sin(\psi) + \theta_{world}\cos(\psi)$$

• Hey, actually, I'm not sure that's correct. For example, won't this always make θ (the pitch) 0 when ψ (the yaw) is 0°? Jan 26, 2014 at 2:15
• It's possible that I've swapped a sign or a sine. Since different fields use yaw differently (unit circle vs compass heading), I'll re-write this to be more clear.
– Ian
Jan 27, 2014 at 19:53

Think of it this way, if you had 90$^\circ$ yaw you would swap roll and pitch, and maybe switch the sign depending on your coordinate system definition. Once you think through that, you just use the yaw angle to interpolate for arbitrary yaw angles.

\begin{align} \phi' &= \cos(\psi) \phi + \sin(\psi) \theta \\ \theta' &= -\sin(\psi) \phi + \cos(\psi) \theta \end{align}

The $\pm$ signs might be off, but you get the idea.

Don't think roll and pitch. think of the level flight case where the vertical axis of the 'copter is vertical. Now if you want to move in any direction at all create a plane that contains your vertical axis (so this is a vertical plane) and also contains your desired new direction. two line now define a plane. You need to tip the 'copter's vertical axis while keeping ti on that plane

Looking down on this plane from high up on your z-axis the plane looks line a line drawn on the x,y plane pointing to your desired new heading. The line is has some angle which equals the change in heading you want call it theta.

the rotation will have a pitch and roll component and you must distribute the total amount of tilt between pitch and roll. that is sin(theta) and cos(theta) Does this make sense? Try it: what if you want to turn 90 degrees then sin(90)=1 and cos(90)=0 this means to so "due left" you roll. To move forward is is pitch one because sin(0)=0 and cos(0) = 1. At 45 degree heading sin(45)=cos(45) so equal amount of pitch and roll.

Now you can go any direction take the total rotation and proportion it between pitch and roll be multiplying by (total rotation)(sin(theta)) and cos for roll.

• Did you switch sine and cosine? You said that pitch maps to sine and roll maps to cosine, but shouldn't it be the other way around, because if you want to move forward pitch should be one (ie. cos(0)) and roll should be zero (ie. sin(0))? Feb 9, 2014 at 0:27