zauberzeug / rosys

An all-Python robot system based on web technologies. The purpose is similar to ROS, but it's based on NiceGUI and easier to use for mobile robotics.
https://rosys.io
MIT License
78 stars 10 forks source link

Fix calibration.project_to_image #187

Closed pascalzauberzeug closed 1 month ago

pascalzauberzeug commented 2 months ago

While creating a calibration, I found that the zero-function of rosys.geometry.Rotation uses integers, which causes cv2.Rodrigues to fail, because it expects floats. While using .astype(np.float32) helps, using floats directly makes it easier to use in the future.

import cv2
import numpy as np
from rosys.geometry import Pose3d, Rotation

# works
extrinsics = Pose3d(x=0, y=0, z=0, rotation=Rotation(R=[[0, 0, 0], [0, 1, 0], [0, 0, 1]]))
R = extrinsics.rotation.matrix.astype(np.float32)
Rod = cv2.Rodrigues(R.T)[0]

# works
extrinsics = Pose3d(x=0.0, y=0.0, z=0.0, rotation=Rotation(R=[[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]))
R = extrinsics.rotation.matrix
Rod = cv2.Rodrigues(R.T)[0]

# doesn't work without the changes
extrinsics = Pose3d(x=0, y=0, z=0, rotation=Rotation(R=[[0, 0, 0], [0, 1, 0], [0, 0, 1]]))
R = extrinsics.rotation.matrix
Rod = cv2.Rodrigues(R.T)[0]

edit: float64 is needed for our tests