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

mjcf->sdformat sliding friction #86

Merged
merged 9 commits into from
Jun 28, 2022
Merged

mjcf->sdformat sliding friction #86

merged 9 commits into from
Jun 28, 2022

Conversation

scpeters
Copy link
Member

🎉 New feature

Follow-up to #70

Summary

This supports translation of sliding friction parameters from MJCF to SDFormat, the reverse of #70. It requires gazebosim/sdformat#1049 and will remain in draft state until that is merged.

Test it

sdformat2mjcf friction_demo.sdf friction_demo_1.xml
mjcf2sdformat friction_demo_1.xml friction_demo_2.sdf

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • 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.

Add friction to plane in test_mujoco.xml for unit test
and test default friction with tennis_ball.xml

Signed-off-by: Steve Peters <[email protected]>
@codecov
Copy link

codecov bot commented Jun 16, 2022

Codecov Report

Merging #86 (359552a) into main (9ae088d) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main      #86   +/-   ##
=======================================
  Coverage   95.15%   95.16%           
=======================================
  Files          24       24           
  Lines        1177     1179    +2     
=======================================
+ Hits         1120     1122    +2     
  Misses         57       57           
Impacted Files Coverage Δ
...ormat_mjcf/mjcf_to_sdformat/converters/geometry.py 96.84% <100.00%> (+0.06%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9ae088d...359552a. Read the comment docs.

@scpeters scpeters marked this pull request as ready for review June 28, 2022 16:08
@scpeters scpeters requested a review from azeey June 28, 2022 16:08
Copy link
Collaborator

@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 good. Just need to handle missing attributes.

Comment on lines 157 to 158
if geom.friction is not None:
col.surface().friction().ode().set_mu(geom.friction[0])
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the friction is None, we should set to the default value of 1.

Suggested change
if geom.friction is not None:
col.surface().friction().ode().set_mu(geom.friction[0])
friction = su.get_value_or_default(geom.friction, [1, 0.005, 0.0001])
col.surface().friction().ode().set_mu(friction[0])

Copy link
Member Author

Choose a reason for hiding this comment

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

Signed-off-by: Steve Peters <[email protected]>

Co-authored-by: Addisu Z. Taddese <[email protected]>
Copy link
Collaborator

@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.

Just linter issues.

Comment on lines 212 to 215
self.assertEqual(sdf.GeometryType.PLANE,
sdf_plane_collision.geom().type())
self.assertEqual(0.9,
sdf_plane_collision.surface().friction().ode().mu())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
self.assertEqual(sdf.GeometryType.PLANE,
sdf_plane_collision.geom().type())
self.assertEqual(0.9,
sdf_plane_collision.surface().friction().ode().mu())
self.assertEqual(sdf.GeometryType.PLANE,
sdf_plane_collision.geom().type())
self.assertEqual(0.9,
sdf_plane_collision.surface().friction().ode().mu())

Copy link
Member Author

Choose a reason for hiding this comment

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

Comment on lines 220 to 223
self.assertEqual(sdf.GeometryType.CAPSULE,
sdf_rail1_collision.geom().type())
self.assertEqual(1.0,
sdf_rail1_collision.surface().friction().ode().mu())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
self.assertEqual(sdf.GeometryType.CAPSULE,
sdf_rail1_collision.geom().type())
self.assertEqual(1.0,
sdf_rail1_collision.surface().friction().ode().mu())
self.assertEqual(sdf.GeometryType.CAPSULE,
sdf_rail1_collision.geom().type())
self.assertEqual(1.0,
sdf_rail1_collision.surface().friction().ode().mu())

Copy link
Member Author

Choose a reason for hiding this comment

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

scpeters and others added 2 commits June 28, 2022 12:31
Signed-off-by: Steve Peters <[email protected]>
Signed-off-by: Addisu Z. Taddese <[email protected]>
@azeey
Copy link
Collaborator

azeey commented Jun 28, 2022

Fixed test error in 359552a

@azeey azeey merged commit 06d9b30 into main Jun 28, 2022
@azeey azeey deleted the scpeters/friction_params2 branch June 28, 2022 20:45
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.

2 participants