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文章来源:https://www.toymoban.com/news/detail-780074.html
4、代码示例文章来源地址https://www.toymoban.com/news/detail-780074.html
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)
到了这里,关于机器人中的yaw/pitch/roll的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!