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

Reverse order of rotation offset (rpyOffset) calculation in p3d and imu plugins #1241

Open
wants to merge 4 commits into
base: melodic-devel
Choose a base branch
from

Conversation

iche033
Copy link
Contributor

@iche033 iche033 commented Feb 26, 2021

See this comment in sdformat. Ran into an issue with calculation of rpyOffset in urdf to sdf conversion, which seems to suggest that the rpyOffset should be post multiplied in the gazebo ros plugins.

There isn't really much documentation on the xyzOffset and rpyOffset params and what frames they are in. All the example I found online have been using 0s for rpyOffset. The changes here will however affect user's code if they are manually specifying rpyOffset.

Signed-off-by: Ian Chen [email protected]

@@ -244,7 +244,7 @@ void GazeboRosIMU::UpdateChild()
rot = pose.Rot();

// apply rpy offsets
rot = this->offset_.Rot()*rot;
rot = rot*this->offset_.Rot();
Copy link

Choose a reason for hiding this comment

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

Would it be possible to condition this based on what version of libsdformat is being used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added version check in fca594d. It assumes that the release will be made in sdformat 6.3.0 and forward ported though. So we'll need to merge and release the sdformat pull request first

Signed-off-by: Ian Chen <[email protected]>
Copy link

@azeey azeey left a comment

Choose a reason for hiding this comment

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

Looks like there's another IMU plugin (GazeboRosImuSensor) that also uses rpyOffset

orientation = offset.Rot()*sensor->Orientation(); //applying offsets to the orientation measurement

but from what I can tell, the rpyOffset that would be used in that sensor is manually set, not automatically generated by the fixed joint reduction code in libsdformat. So it seems okay to leave it as is.

@@ -244,7 +246,13 @@ void GazeboRosIMU::UpdateChild()
rot = pose.Rot();

// apply rpy offsets
// rotation calculation needs to be reversed for sdformat versions > 6.2.0,
// see https://github.com/osrf/sdformat/pull/500
#if SDF_MAJOR_VERSION < 6 || (SDF_MAJOR_VERSION == 6 && SDF_MINOR_VERSION <= 2)
Copy link

Choose a reason for hiding this comment

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

hmm, thinking on this some more, if this runs on currently released versions of libsdformat that are greater than 6.2 (eg. v9.0), it'll do the wrong thing. It might be an ugly hack, but maybe we should have a flag in libsdformat that we check instead of the version?

Copy link
Member

Choose a reason for hiding this comment

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

I think injecting an SDFormat element into the plugin block would be much simpler than trying to track which versions have the fix, especially once we start forward-porting:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated to use the injected corrected_offsets element

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@scpeters are you ok with the latest changes?

@iche033
Copy link
Contributor Author

iche033 commented Mar 5, 2021

but from what I can tell, the rpyOffset that would be used in that sensor is manually set, not automatically generated by the fixed joint reduction code in libsdformat. So it seems okay to leave it as is.

I think for p3d and the imu plugin, the rpyOffset can also be manually set. If not set, fixed joint reduction will generate them. If they are set, fixed joint reduction will read in the manually specified rpyOffset values and apply additional transformation on them.

hmm does that mean we should also not be touching these equations?

Signed-off-by: Ian Chen <[email protected]>
Signed-off-by: Ian Chen <[email protected]>
@iche033
Copy link
Contributor Author

iche033 commented Aug 30, 2021

as of ef708a3, the equation will only be flipped if it detects that the ignition::corrected_offsets tag was injected by sdformat. So this change should not break existing behavior. We also don't need to wait for an sdformat release before merging this.

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 this pull request may close these issues.

3 participants