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

Removed the workaround LOCAL2 coordinate system from SphericalCoordinates. #596

Closed
wants to merge 2 commits into from

Conversation

peci1
Copy link
Contributor

@peci1 peci1 commented May 26, 2024

🦟 Bug fix

Fixes #235 (comment)

Summary

PR #235 introduced a workaround coordinate system LOCAL2 that fixed a bug regarding the LOCAL system. This workaround was only intended to be kept for a tick-tock cycle, but it slipped from gz-math6 to gz-math7, too. This PR removes it from gz-math8.

All operations with the LOCAL coordinate system will now correctly use ENU as advertised.

Note that this breaks contract to code programmed for gz-math7 and earlier, where LOCAL system was actually WSU instead of ENU (rotated by 180 degrees heading).

There is one thing I'm not sure about. The LOCAL2 system had index 5 in the enum. Now I removed it and we're again left with just LOCAL with value 4. Maybe it would be more practical to specify LOCAL = 5 so that it is easier to spot cases in which users just supplied the value instead of the enum constant. But I'm not sure how probable that is.

This is a breaking change and will require downstream changes at least in https://github.com/gazebosim/gz-sim/blob/40aaddc7eb4ca12a03b64e18ffc101db9f9c24ec/src/Util.cc#L694 .

Checklist

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

Copy link
Member

@scpeters scpeters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this approach, downstream code using LOCAL2 will fail to compile and code using LOCAL will have a behavior change that may not be discoverable unless they read the release notes. Breaking code is at least discoverable, but I'm concerned about silent behavior changes.

  • If the goal is to get rid of the buggy behavior in a discoverable way, then we should remove the LOCAL enum.
  • If we want a nicer name than LOCAL2, then we should make a new name like LOCAL_Z_UP or something and deprecate LOCAL2 and/or print a warning when it is used.

What do you think?

@peci1
Copy link
Contributor Author

peci1 commented Jun 5, 2024

Thanks for the comments. This PR was meant as a kickoff for discussion.

I support the idea of removing LOCAL and renaming LOCAL2. LOCAL_Z_UP sounds doable, though not optimal. But I don't have anything better right now.

The question is what to do with SphericalFromLocalPosition. The best way I see would also be to rename it. Agree? E.g. SphericalFromLocalZUpPosition.

One practical question: should this PR towards main branch introduce the deprecations, or should it represent the "final state" with all wrong functions completely removed, and the deprecations would be done when splitting out next major version?

@azeey azeey added the beta Targeting beta release of upcoming collection label Jul 29, 2024
@arjo129
Copy link
Contributor

arjo129 commented Aug 6, 2024

Hi @peci1, was wondering what the status on this was. Do we intend shipping this change with ionic (code freeze 26/8)? If we can't come to a consensus by then I will remove the beta label (I personally would prefer seeing it in this release).

Perhaps going the deperecation route is best as we have limited time to release.

@peci1
Copy link
Contributor Author

peci1 commented Aug 6, 2024

I think it would be beneficial to have this in Ionic. I'll have a closer look at it next week.

@peci1
Copy link
Contributor Author

peci1 commented Aug 11, 2024

Okay, I'll try renaming LOCAL2 to LOCAL_TANGENT and deprecating LOCAL.

Regarding renaming of the functions, I don't think it's necessary as it will be obvious what they do.

Use LOCAL_TANGENT instead.

Signed-off-by: Martin Pecka <[email protected]>
Signed-off-by: Martin Pecka <[email protected]>
@peci1
Copy link
Contributor Author

peci1 commented Aug 13, 2024

So, the PR is updated.

I've kept LOCAL and LOCAL2 and deprecated them. I've added LOCAL_TANGENT with the same numerical value as LOCAL.

I've also deprecated all *From*(Position|Velocity) and created *(Position|Velocity)From* instead. The new functions do the conversion using LOCAL_TANGENT, while the deprecated ones do them via LOCAL.

I've also added tests that verify the behavior of the deprecated functions so that some future updated doesn't break them before they're removed.

@peci1
Copy link
Contributor Author

peci1 commented Aug 16, 2024

Continued as a part of #616

@peci1 peci1 closed this Aug 16, 2024
arjo129 pushed a commit that referenced this pull request Aug 20, 2024
As discussed in #597 (comment) , it seems that gz-math would benefit from having a CoordinateVector3 class that explicitly holds either spherical or metric coordinates.

This PR merges the fixes from #596 and #597 - it deprecates LOCAL2 frame and provides an unambiguous interface regarding angular units.
---------

Signed-off-by: Martin Pecka <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta Targeting beta release of upcoming collection 🏛️ ionic Gazebo Ionic
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants