Quaternion of a JointModelFreeFlyer #2199
-
Hello.
which is rotate about X axis 90 degree. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
the quat is[w,x,y,z] in pinocchio,not the order [x,y,z,w] |
Beta Was this translation helpful? Give feedback.
-
Hello, Actually the quaternion in the generalized position vector (q) is stored in You can see it with the following sample code: import numpy as np
import pinocchio as pin
# Create a model with only a FreeFlyer joint
m = pin.Model()
m.addJoint(0, pin.JointModelFreeFlyer(), pin.SE3.Identity(), "t")
d = m.createData()
# q_vec = [X, Y, Z, QX, QY, QZ, QW]
q_vec = np.array([0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1])
pin.forwardKinematics(m, d, q_vec)
print("Identity quaterion:", q_vec[3:])
print(d.oMi[-1].rotation)
print()
# We create a quaternion from an AngleAxis rotated around X
aa = pin.AngleAxis(np.pi / 2, np.array([1, 0, 0]))
quat = pin.Quaternion(aa)
q_vec[3:] = quat.coeffs()
pin.forwardKinematics(m, d, q_vec)
print("X rotated quaterion:", q_vec[3:])
print(d.oMi[-1].rotation)
print()
# We create a quaternion from an AngleAxis rotated around Y
aa = pin.AngleAxis(np.pi / 2, np.array([0, 1, 0]))
quat = pin.Quaternion(aa)
q_vec[3:] = quat.coeffs()
pin.forwardKinematics(m, d, q_vec)
print("Y rotated quaterion:", q_vec[3:])
print(d.oMi[-1].rotation)
print()
# We create a quaternion from an AngleAxis rotated around Z
aa = pin.AngleAxis(np.pi / 2, np.array([0, 0, 1]))
quat = pin.Quaternion(aa)
q_vec[3:] = quat.coeffs()
pin.forwardKinematics(m, d, q_vec)
print("Z rotated quaterion:", q_vec[3:])
print(d.oMi[-1].rotation)
print() The output is:
In the output, you can see that the last part of the quaternion always hold a value. If the order was |
Beta Was this translation helpful? Give feedback.
-
use the [w,x,y,z] order, the SE3 of the freeflyerjoint is right. It is because of the C++ code? |
Beta Was this translation helpful? Give feedback.
Hello,
Actually the quaternion in the generalized position vector (q) is stored in
[x, y, z, w]
order.The full position vector for the FreeFlyer is
[X, Y, Z, QX, QY, QZ, QW]
where X, Y, Z is the translation vector and QX, QY, QZ, QW is the quaternion.You can see it with the following sample code: