2
$\begingroup$

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?

$\endgroup$

3 Answers 3

3
$\begingroup$

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:

Roll, pitch, and yaw on an airplane

$$\phi_{vehicle} = \phi_{world}\cos(\psi) - \theta_{world}\sin(\psi)$$ $$\theta_{vehicle} = \phi_{world}\sin(\psi) + \theta_{world}\cos(\psi)$$

$\endgroup$
2
  • $\begingroup$ Hey, actually, I'm not sure that's correct. For example, won't this always make θ (the pitch) 0 when ψ (the yaw) is 0°? $\endgroup$
    – gtmtg
    Jan 26, 2014 at 2:15
  • $\begingroup$ 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. $\endgroup$
    – Ian
    Jan 27, 2014 at 19:53
1
$\begingroup$

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.

$\endgroup$
1
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ 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))? $\endgroup$
    – gtmtg
    Feb 9, 2014 at 0:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.