Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect conversion of Rodrigues from OpenCV #933

Closed
prensing opened this issue Oct 7, 2023 · 5 comments · Fixed by #934
Closed

Incorrect conversion of Rodrigues from OpenCV #933

prensing opened this issue Oct 7, 2023 · 5 comments · Fixed by #934

Comments

@prensing
Copy link
Contributor

prensing commented Oct 7, 2023

In OpenCVHelp, the routine rvecToRotation() does not work if the input rvec is all 0.

If rvec = (0,0,0), this is a valid value which means "no rotation". The equivalent rotation matrix is the 3x3 identity. I checked this in Python with OpenCV directly. The current version produces a Rotation3d which is all "NaN".

I am seeing this in the simulation where the MultiTag results exactly produce a EstimatedPose with no rotation.

Build is latest from master branch. Running on Linux with the simulation.

@prensing
Copy link
Contributor Author

prensing commented Oct 7, 2023

I wonder if it would be better to have OpenCV convert it to a 3x3 rotation matrix, and then use that to create the Rotation3d. Rotation matrices are very tightly defined, and I think WPILib has a constructor from one.

@prensing
Copy link
Contributor Author

prensing commented Oct 7, 2023

I think the bug is that you are dividing by the norm() to normalize the vector.

Looks to me like you could just use the existing constructor:
Rotation3d(Vector rvec)

@amquake
Copy link
Member

amquake commented Oct 7, 2023

Yes, it should be updated to use that Rotation3d constructor. All it does differently is skip the constructor if the rvec norm is 0.

@mcm001
Copy link
Contributor

mcm001 commented Oct 8, 2023

Working this now

@prensing
Copy link
Contributor Author

prensing commented Oct 9, 2023

I tested and it seemed to be good. Fixed my particular problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants