RPY_Euler_Quaternion_AngleAxis角度转化:Matlab、Python、Halc
RPY_Euler_Quaternion_AngleAxis角度转化:Matlab、Python、Halcon版本
UR协作机器人和Franka机器人导出的位姿为angleVector,三个量表示,在Matlab中angleVector是四个量表示。如果是三个量的表示推荐使用Python的scipy库做转换。
https://en.wikipedia.org/wiki/Axis%E2%80%93angle_representation#Rotation_vector
[var1]
1.1 Quaternion转Matrix (带位置和姿态)
robotHtool =[0.10345922, -0.48407779, 0.29668114, -0.03533355, 0.09830182, -0.86382214, 0.49284846];
% w x y z
robotHtool_qua = Quaternion([robotHtool(7), robotHtool(4), robotHtool(5) , robotHtool(6)])
robotHtool_matrix = transl(robotHtool(1), robotHtool(2), robotHtool(3)) * robotHtool_qua.T
[var1]
2.1 UR机器人rotvec转换为RPY_rxryrz
UR机械臂通过30003端口发送过来的是rotation vector, 示教器Polyscope界面上Move标签栏中显示的是RPY_rxryrz
https://www.universal-robots.com/articles/ur/explanation-on-robot-orientation/
https://www.universal-robots.com/articles/ur/rpy-tofrom-rotation-vector/
scipy spatial transform官方帮助:
https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.transform.Rotation.html
from scipy.spatial.transform import Rotation as R
r = R.from_rotvec([-0.001220983, 3.1162765, 0.038891915])
Euler_xyz = r.as_euler('xyz', degrees=False)
2.2 川崎机器人Euler_ZYZ转四元数Quaternion
[var1]
3.1 Halcon 的姿态、齐次变换和四元数
create_pose函数是包含位置和姿态的,姿态格式为RPY_rx_ry_rz,注意输入为角度。pose_to_hom_mat3d是RPY_rx_ry_rz转为齐次矩阵。四元数的顺序是w, x, y, z
robot_V_cam := [0.418906862152, 0.471104634456, 0.729862740299, 2.851, -1.241, -0.008]
* Create pose use degrees.
create_pose (robot_V_cam[0], robot_V_cam[1], robot_V_cam[2], deg(robot_V_cam[3]), deg(robot_V_cam[4]), deg(robot_V_cam[5]), 'Rp+T', 'gba', 'point', Pose)
pose_to_hom_mat3d(Pose, robot_H_cam)
pose_to_quat(Pose, robot_Q_cam)
hom_mat3d_to_pose(robot_H_cam, pose_test1)
************************* xyz *********************************************
hom_mat3d_identity (HomMat3DIdentity)
hom_mat3d_translate (HomMat3DIdentity, robot_V_cam[0], robot_V_cam[1], robot_V_cam[2], HomMat3DTranslate)
hom_mat3d_rotate_local (HomMat3DTranslate, robot_V_cam[3], 'x', HomMat3DT_Rl)
hom_mat3d_rotate_local (HomMat3DT_Rl, robot_V_cam[4], 'y', HomMat3DT_Rl_Rm)
hom_mat3d_rotate_local (HomMat3DT_Rl_Rm, robot_V_cam[5], 'z', HomMat3D)
hom_mat3d_to_pose (HomMat3D, pose_test2)
********************* right-left old zyx **********************************
hom_mat3d_identity (HomMat3DIdent)
hom_mat3d_rotate (HomMat3DIdent, robot_V_cam[5], 'z', 0, 0, 0, HomMat3DRotZ)
hom_mat3d_rotate (HomMat3DRotZ, robot_V_cam[4], 'y', 0, 0, 0, HomMat3DRotYZ)
hom_mat3d_rotate (HomMat3DRotYZ, robot_V_cam[3], 'x', 0, 0, 0, HomMat3DXYZ3)
hom_mat3d_translate(HomMat3DXYZ3, robot_V_cam[0], robot_V_cam[1], robot_V_cam[2], HomMat3Dzyx)
hom_mat3d_to_pose(HomMat3Dzyx, pose_test3)
RPY_Euler_Quaternion_AngleAxis角度转化:Matlab、Python、Halc相关教程