Roll, pitch, yaw calculation

耗尽温柔 提交于 2019-12-04 10:42:30

Your equations are correct only if the order of rotations is: roll, then pitch, then yaw. For the record, the correspondence with Euler angles (with respect to the frame of reference implicitly given with the transformation matrix) is as follows:

  • Roll is the rotation about the x axis (between -180 and 180 deg);
  • Pitch is the rotations about the y axis (between -90 and 90 deg);
  • Yaw is the rotation about the z axis (between -180 and 180).

Given these, the order roll, pitch, yaw mentioned in the first sentence corresponds to the rotation matrix obtain by the matrix product Rz Ry Rx (in this order). Note that your formula give the values of these angles in radians (multiply by 180 and divide by pi to obtain values in degrees). All rotations are counter-clockwise with respect to the axis.

Figure taken from Wikipedia

Following your comment about this link, I think this paper might help to understand the program you are referring to. The input to the Matlab function is supposed to be your transformation matrix, followed by 'deg' if you want the angles to be returned in degrees, and an obsolete option 'zyx' if the order of the rotations is around z, then around y, then around x.

[This might be better suited as a comment but it is to long for that ;) ]

When I compare your formula with the one on the german Wikipedia page about roll, pitch an yaw (see here) there is a difference in the calculation of the pitch. According to Wikipedia your formula should look like this:

pitch = atan2(-r20,(sqrt(pow(r21,2)+pow(r00,2))); // replaced r22 by r00

Note that on the wikipedia page they use a different indexing for the matrix elements (thex start with 1 and not with 0 for the first row/column). Furthermore they call pitch beta, yaw alpha and roll gamma. Also, they divide the coefficents for atan2 in the yaw and roll calculation by the cos(pitch), but that should cancel out.

Otherwise your formula looks fine to me.

"Roll is the rotation about the x axis (between -180 and 180 deg); Pitch is the rotations about the y axis (between -90 and 90 deg); Yaw is the rotation about the z axis (between -180 and 180)."

There is a mistake in this quoted answer posted above. While the figure is accurate, the "roll" and the "pitch" have been interchanged in the quoted answer. It should read:

"Roll is the rotation about the y axis ...; Pitch is the rotations about the x axis ...; Yaw is the rotation about the z axis ..."

I hope this was helpful to you.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!