附录3 三维空间刚体运动

四元数

\quad旋转矩阵用9个量来描述3自由度的旋转,具有冗余性;欧拉角虽然用3个量来描述3自由度的旋转,但是具有万向锁的问题,因此我们选择用四元数,(ROS当中描述转向的都是采用的四元数)。一个四元数拥有一个实部和三个虚部组成。

q=w+xi=yj+zk\qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad q=w+xi=yj+zk

\quad三个虚部满足以下关系

{i2=j2=k2=1ij=k,ji=kjk=i,kj=iki=j,jk=j\qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \begin{cases} i^2=j^2=k^2=-1 \\ ij=k,ji=-k\\ jk=i,kj=-i\\ ki=j,jk=-j\\ \end{cases}

\quad写成矩阵的样子就是q=[w,x,y,z]Tq=\begin{bmatrix} w,x,y,z\end{bmatrix}^T,其中q2=w2=x2+y2+z2=1\begin{vmatrix} q\end{vmatrix}^2=w^2=x^2+y^2+z^2=1,从欧拉角到四元数的公式:

q=[wxyz]=[cos(roll/2)cos(pitch/2)cos(yaw/2)+sin(roll/2)sin(pitch/2)sin(yaw/2)sin(roll/2)cos(pitch/2)cos(yaw/2)cos(roll/2)sin(pitch/2)sin(yaw/2)cos(roll/2)sin(pitch/2)cos(yaw/2)+sin(roll/2)cos(pitch/2)sin(yaw/2)cos(roll/2)cos(pitch/2)sin(yaw/2)sin(roll/2)sin(pitch/2)cos(yaw/2)]\qquad \qquad q=\begin{bmatrix} w\\x\\y\\z \end{bmatrix}=\begin{bmatrix} cos(roll/2)cos(pitch/2)cos(yaw/2)+sin(roll/2)sin(pitch/2)sin(yaw/2)\\sin(roll/2)cos(pitch/2)cos(yaw/2)-cos(roll/2)sin(pitch/2)sin(yaw/2)\\cos(roll/2)sin(pitch/2)cos(yaw/2)+sin(roll/2)cos(pitch/2)sin(yaw/2)\\cos(roll/2)cos(pitch/2)sin(yaw/2)-sin(roll/2)sin(pitch/2)cos(yaw/2) \end{bmatrix}

\quad从四元数转化到欧拉角公式

[rollpitchyaw]=[atan2(2(wx+yz),12(x2+y2))arcsin(2(wyzx))atan2(2(wz+xy),12(y2+z2))]\qquad \qquad \qquad \qquad \qquad \qquad \begin{bmatrix} roll\\pitch\\yaw \end{bmatrix}=\begin{bmatrix} atan2(2(wx+yz),1-2(x^2+y^2))\\ arcsin(2(wy-zx))\\atan2(2(wz+xy),1-2(y^2+z^2)) \end{bmatrix}

results matching ""

    No results matching ""