Sorry for not describing my problem in detail before.I took the quaternion of the IMU at a certain moment in time and converted it into a rotation matrix.
q=np.array([-0.019775,0.479309,0.003967,0.877441])
def quaternion_to_rotation_matrix(q): # x, y ,z ,w
rot_matrix = np.array(
[[1.0 - 2 * (q[1] * q[1] + q[2] * q[2]), 2 * (q[0] * q[1] - q[3] * q[2]), 2 * (q[3] * q[1] + q[0] * q[2])],
[2 * (q[0] * q[1] + q[3] * q[2]), 1.0 - 2 * (q[0] * q[0] + q[2] * q[2]), 2 * (q[1] * q[2] - q[3] * q[0])],
[2 * (q[0] * q[2] - q[3] * q[1]), 2 * (q[1] * q[2] + q[3] * q[0]), 1.0 - 2 * (q[0] * q[0] + q[1] * q[1])]],
dtype=q.dtype)
return rot_matrix
R = np.eye(4)
R[:3, :3] = quaternion_to_rotation_matrix(q)
print(R)
As a result, it was:
[[ 0.54049429 -0.02591829 0.84097384 0. ]
[-0.01199505 0.99918642 0.03850563 0. ]
[-0.84128763 -0.03089995 0.53974366 0. ]
[ 0. 0. 0. 1. ]]
I think the resulting rotation matrix should be an orthogonal identity matrix, but obviously, R is not.An orthogonal identity matrix can convert the point cloud to the world coordinate system.That's where I'm confused