库卡KUKA机器人:编程之欧拉角与四元数转换
2.四元数:
3.库卡欧拉角转四元数:
import ant; overflow-wrap: break-word !import ant;">DEFFCT QUATERNION EulerZYXToQuaternion(ABC:IN )
import ant; overflow-wrap: break-word !import ant;">DECL EulerZYX ABC
import ant; overflow-wrap: break-word !import ant;">DECL QUATERNION Q
import ant; overflow-wrap: break-word !import ant;">DECL REAL SINA,COSA
import ant; overflow-wrap: break-word !import ant;">DECL REAL SINB,COSB
import ant; overflow-wrap: break-word !import ant;">DECL REAL SINC,COSC
import ant; overflow-wrap: break-word !import ant;">DECL INT Sum
import ant; overflow-wrap: break-word !import ant;">IF VARSTATE("ABC")<>#INITIALIZED THEN
import ant; overflow-wrap: break-word !import ant;"> MsgQuit("Input Euler Angles not initialized!")
import ant; overflow-wrap: break-word !import ant;"> LOOP
import ant; overflow-wrap: break-word !import ant;"> HALT
import ant; overflow-wrap: break-word !import ant;"> ENDLOOP
import ant; overflow-wrap: break-word !import ant;">ENDIF
import ant; overflow-wrap: break-word !import ant;">SINC=SIN(ABC.Rx*0.5)
import ant; overflow-wrap: break-word !import ant;">COSC=COS(ABC.Rx*0.5)
import ant; overflow-wrap: break-word !import ant;">SINB=SIN(ABC.Ry*0.5)
import ant; overflow-wrap: break-word !import ant;">COSB=COS(ABC.Ry*0.5)
import ant; overflow-wrap: break-word !import ant;">SINA=SIN(ABC.Rz*0.5)
import ant; overflow-wrap: break-word !import ant;">COSA=COS(ABC.Rz*0.5)
import ant; overflow-wrap: break-word !import ant;">Q.W=COSC*COSB*COSA+SINC*SINB*SINA
import ant; overflow-wrap: break-word !import ant;">Q.X=SINC*COSB*COSA-COSC*SINB*SINA
import ant; overflow-wrap: break-word !import ant;">Q.Y=COSC*SINB*COSA+SINC*COSB*SINA
import ant; overflow-wrap: break-word !import ant;">Q.Z=COSC*COSB*SINA-SINC*SINB*COSA
import ant; overflow-wrap: break-word !import ant;">Sum=Q.W*Q.W+Q.X*Q.X+Q.Y*Q.Y+Q.Z*Q.Z
import ant; overflow-wrap: break-word !import ant;">IF Sum<>1 THEN
import ant; overflow-wrap: break-word !import ant;"> MsgQuit("Sum of Quaternion elements power NOT 1!")
import ant; overflow-wrap: break-word !import ant;"> LOOP
import ant; overflow-wrap: break-word !import ant;"> HALT
import ant; overflow-wrap: break-word !import ant;"> ENDLOOP
import ant; overflow-wrap: break-word !import ant;">ELSE
import ant; overflow-wrap: break-word !import ant;"> RETURN (Q)
import ant; overflow-wrap: break-word !import ant;">ENDIF
import ant; overflow-wrap: break-word !import ant;">ENDFCT
import ant; overflow-wrap: break-word !import ant;">DEFFCT EulerZYX QuaternionToEulerZYX(Q:IN )
import ant; overflow-wrap: break-word !import ant;">DECL EulerZYX Ret
import ant; overflow-wrap: break-word !import ant;">DECL QUATERNION Q
import ant; overflow-wrap: break-word !import ant;">DECL INT Sum
import ant; overflow-wrap: break-word !import ant;">DECL REAL Tempz1,Tempz2
import ant; overflow-wrap: break-word !import ant;">DECL REAL Tempy
import ant; overflow-wrap: break-word !import ant;">DECL REAL Tempx1,Tempx2
import ant; overflow-wrap: break-word !import ant;">IF VARSTATE("Q")<>#INITIALIZED THEN
import ant; overflow-wrap: break-word !import ant;"> MsgQuit("Input Quaternion not initialized!")
import ant; overflow-wrap: break-word !import ant;"> LOOP
import ant; overflow-wrap: break-word !import ant;"> HALT
import ant; overflow-wrap: break-word !import ant;"> ENDLOOP
import ant; overflow-wrap: break-word !import ant;">ENDIF
import ant; overflow-wrap: break-word !import ant;">Sum=Q.W*Q.W+Q.X*Q.X+Q.Y*Q.Y+Q.Z*Q.Z
import ant; overflow-wrap: break-word !import ant;">IF Sum<>1 THEN
import ant; overflow-wrap: break-word !import ant;"> MsgQuit("Sum of Quaternion elements power NOT 1!")
import ant; overflow-wrap: break-word !import ant;"> LOOP
import ant; overflow-wrap: break-word !import ant;"> HALT
import ant; overflow-wrap: break-word !import ant;"> ENDLOOP
import ant; overflow-wrap: break-word !import ant;">ENDIF
import ant; overflow-wrap: break-word !import ant;">Tempx1=2*(Q.Y*Q.Z+Q.W*Q.X)
import ant; overflow-wrap: break-word !import ant;">Tempx2=Q.W*Q.W-Q.X*Q.X-Q.Y*Q.Y+Q.Z*Q.Z
import ant; overflow-wrap: break-word !import ant;">Tempy=2*(Q.W*Q.Y-Q.X*Q.Z)
import ant; overflow-wrap: break-word !import ant;">Tempz1=2*(Q.X*Q.Y+Q.W*Q.Z)
import ant; overflow-wrap: break-word !import ant;">TempZ2=Q.W*Q.W+Q.X*Q.X-Q.Y*Q.Y-Q.Z*Q.Z
import ant; overflow-wrap: break-word !import ant;">Ret.Rx=ATAN2(Tempx1,Tempx2)
import ant; overflow-wrap: break-word !import ant;">Ret.Rz=ATAN2(Tempz1,tempz2)
import ant; overflow-wrap: break-word !import ant;">Ret.Ry=90-ACOS(Tempy)
import ant; overflow-wrap: break-word !import ant;">RETURN (RET)
import ant; overflow-wrap: break-word !import ant;">ENDFCT
import ant; overflow-wrap: break-word !import ant;">DEF FunctionTest( )
import ant; overflow-wrap: break-word !import ant;">DECL QUATERNION Q1,Q2
import ant; overflow-wrap: break-word !import ant;">DECL EulerZYX ZYX1,ZYX2
import ant; overflow-wrap: break-word !import ant;">ZYX1={Rz 3,Ry 2,Rx 1}
import ant; overflow-wrap: break-word !import ant;">Q2={W 0.5,X 0.5,Y 0.5,Z 0.5}
import ant; overflow-wrap: break-word !import ant;">Q1=EulerZYXToQuaternion(ZYX1)
import ant; overflow-wrap: break-word !import ant;">HALT
import ant; overflow-wrap: break-word !import ant;">ZYX2=QuaternionToEulerZYX(Q2)
import ant; overflow-wrap: break-word !import ant;">HALT
import ant; overflow-wrap: break-word !import ant;">END 更多信息请咨询:库卡KUKA机器人
- 下一篇:库卡KUKA包装机器人:常用的调试工具
- 上一篇:暂无