rvec, tvecs, _ = aruco.estimatePoseSingleMarkers(corners, marker_size, k, distortion_coefficients)

idx = np.where(ids == marker_id)[0][0]

#rvec = normalize_rvec(rvecs[idx].flatten())

R, _ = cv2.Rodrigues(rvecs)

euler_angles = rotation_matrix_to_euler_angles(R)

```
R_transformed = rotation_matrix(euler_angles[0], euler_angles[1], euler_angles[2])
rospy.loginfo(f"Euler Angles (degrees): Roll: {np.degrees(euler_angles[0])}, Pitch: {np.degrees(euler_angles[1])}, Yaw: {np.degrees(euler_angles[2])}")
```

}

def rotation_matrix_to_euler_angles(R):

sy = np.sqrt(R[0, 0] * R[0, 0] + R[1, 0] * R[1, 0])

singular = sy < 1e-6

if not singular:

x = np.arctan2(R[2, 1], R[2, 2]) # Roll (phi)

y = np.arctan2(-R[2, 0], sy) # Pitch (theta)

z = np.arctan2(R[1, 0], R[0, 0]) # Yaw (psi)

else:

x = np.arctan2(-R[1, 2], R[1, 1]) # Roll (phi)

y = np.arctan2(-R[2, 0], sy) # Pitch (theta)

z = 0

# Yaw (psi)

return np.array([x,y, z])

Hi @soumildev26,

whenever you need an answer for a question, not only here, but in general life, you should at least explain what is the problem you are facing, what you have tried, what is the expected result, what results did you get, etc.

Please, think about what I just wrote.

@ralves i am telling you again don’t you think I also have chatpgt if you don’t know the answer just let it be. someone who has worked on aruco marker would be able to understand the problem here. camera gives rvec .Actually rodrigues is basically vector geometry and after mathematical derivation we get rotation vector. These rotation vector can be converted to euler angles. Now each of these angles must be between two lines( x of frame 1 and x of frame 2). The problem is that am not getting the correct angles. I think missing some transformation of rotation vector.the yaw(rotaion about z ) should be 0 degree i am getting 90

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.