teun_Q
teun_Q

Reputation: 11

Rotation matrix from robot pose for hand-to-eye calibration

I'm trying to perform hand to eye calibration for a staubli robot in combination with an Intel Realsense d455 depth camera. Therefore I am following the process described in: https://docs.opencv.org/4.5.4/d9/d0c/group__calib3d.html#gaebfc1c9f7434196a374c382abf43439b

  1. Mount calibration board on robot gripper
  2. Determine transformation matrix from calibration board to camera (up to this point everything works).
  3. Retrieve pose from robot (x,y,z,rx,ry,rz)
  4. convert pose to rotation matrix (I suspect this is where i go wrong)
  5. Use cv2.CalibrateHandEye(R_base_to_gripper, t_base_to_gripper, R_target_to_cam, t_target_to_cam)

The results are somewhat correct: The cameras Y-axis is aligned with the robots Y-axis, but the cameras X-axis corresponds to the robots Z-axis and the other way around. The translation values make no sense.

I'm suspecting the problem lies in my method of converting rx, ry, rz to a rotation matrix. The robots documentation mentiones:

We are using Tait-Bryan convention with XYZ system

Euler/Tait-Bryan angles are quite new to me, so I used this function like:

transforms3d.taitbryan.euler2mat(rx, ry, rz)

This seems to work in the sense that my coordinate systems are aligned, although according to its documentation this function returns "matrix for rotations around z, y and x axes". I suspect I have to use this function differently, because right now I swapped rx and rz, but I can't seem to figure out how to do this.

Thanks very much for thinking along!

Upvotes: 1

Views: 1182

Answers (2)

teun_Q
teun_Q

Reputation: 11

It turned out that my robot returned clockwise rotations, while the rotation returned by my camera calibration were anti-clockwise. Simply multiplying rx_robot, ry_robot and rz_robot by -1 resolved my issues.

Upvotes: 0

rvd
rvd

Reputation: 404

I suspect that your rx, ry, rz values are a rotation vector and not Euler angles, so you are erroneously using euler2mat.

You can use the cv2.Rodrigues function to transform a rotation vector into a rotation matrix, or use scipy.spatial.transform.Rotation objects, which are quite convenient.

Upvotes: 1

Related Questions