当前位置:   article > 正文

机器人中的yaw/pitch/roll_yaw轴

yaw轴

1、yaw(pan)/pitch(tilt)/roll

我认为,yaw/pitch/roll绕哪个轴旋转,是要看坐标系的朝向的,如果坐标系的轴如下图,则对应关系是yaw(z轴)、pitch(x轴)、roll(y轴)。

如果换个坐标系,比如下图,则是yaw(Y轴)、pitch(X轴)、roll(Z轴)。

2、yaw/pitch/roll的计算

工业上,一般的旋转顺序是yaw=>pitch=>roll的顺序。

所以,这个坐标系的旋转顺序是ZXY,则对应的旋转矩阵是下图的红色部分。

令旋转矩阵,则

m21 = sinx, x =asin(m21)=>pitch
m20 / m22 = -cosxsiny / cosxcosy = -siny / cosy = -tany, y = -atan2(m20, m22)=>roll
m01 / m11 = -cosxsinz / coszcosx = -sinz / cosz = -tanz, z = -atan2(m01, m11)=>yaw

3、yaw/pitch/roll的坐标系转换

设数据源的坐标系如下图(同2的计算),

数据目标的坐标系如下(都是右手坐标系),

则yaw的旋转与上一步计算相反,有

x =asin(m21)=>pitch

y = atan2(m01, m11)=>yaw

z = -atan2(m20, m22)=>roll

4、代码示例

import numpy as npimport math as mathfrom autolab_core import RigidTransformorientation = {'y': -0.6971278819736084, 'x': -0.716556549511624, 'z': -0.010016582945017661, 'w': 0.02142651612120239}position = {'y': -0.26022684372145516, 'x': 0.6453529828252734, 'z': 1.179122068068349}rotation_quaternion = np.asarray([orientation['w'], orientation['x'], orientation['y'], orientation['z']])translation = np.asarray([position['x'], position['y'], position['z']])m = RigidTransform(rotation_quaternion, translation)r = m.rotationpitch = math.asin(r[2, 1])yaw = -math.atan2(r[0, 1], r[1, 1])roll = -math.atan2(r[2, 0], r[2, 2])pitch_ang = pitch * 180.0 / 3.1415926yaw_ang = -yaw * 180.0 / 3.1415926 roll_ang = roll * 180.0 / 3.1415926print('----- ji result -------')print('pitch: %f' % pitch_ang )print('yaw: %f' % yaw_ang)print('roll_ang: %f' % roll_ang)
  • 1
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/415969
推荐阅读
相关标签
  

闽ICP备14008679号