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

Apply gravity external to dartsim for added mass #462

Merged
merged 9 commits into from
Jan 19, 2023

Conversation

mjcarroll
Copy link
Contributor

🎉 New feature

Summary

When fluid added mass (#384) is used, dartsim will apply gravitational force to the total virtual mass of each link. Since this mass is only to model the inertial aspects of the dynamics, this is incorrect behavior.

In this PR, I disable dart's application of gravity to links that have added mass defined in their sdf file. Instead, gravity is applied as an external force right before the world update by multiplying the link mass by the gravity vector (F = ma!).

Test it

The unit test verifies that when added mass is set to all zeros, that gravity continues to work as expected.

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.

@mjcarroll mjcarroll self-assigned this Dec 9, 2022
@mjcarroll mjcarroll requested a review from JoanAguilar December 9, 2022 17:32
@github-actions github-actions bot added the 🌱 garden Ignition Garden label Dec 9, 2022
@codecov
Copy link

codecov bot commented Dec 9, 2022

Codecov Report

Merging #462 (54deeb8) into gz-physics6 (70059ae) will increase coverage by 0.09%.
The diff coverage is 94.64%.

@@               Coverage Diff               @@
##           gz-physics6     #462      +/-   ##
===============================================
+ Coverage        75.43%   75.52%   +0.09%     
===============================================
  Files              140      142       +2     
  Lines             7099     7138      +39     
===============================================
+ Hits              5355     5391      +36     
- Misses            1744     1747       +3     
Impacted Files Coverage Δ
dartsim/src/plugin.cc 100.00% <ø> (ø)
dartsim/src/SDFFeatures.cc 62.66% <57.14%> (-1.42%) ⬇️
dartsim/src/AddedMassFeatures.cc 100.00% <100.00%> (ø)
dartsim/src/SimulationFeatures.cc 95.00% <100.00%> (+0.55%) ⬆️
include/gz/physics/AddedMass.hh 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Contributor

@JoanAguilar JoanAguilar left a comment

Choose a reason for hiding this comment

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

The implementation looks good, my major comment is for the unit test, which only checks gravity application for a body with zero added mass.

@azeey azeey removed their request for review December 12, 2022 20:37
@mjcarroll mjcarroll requested a review from mabelzhang January 10, 2023 15:24
mjcarroll and others added 4 commits January 11, 2023 16:39
Signed-off-by: Michael Carroll <[email protected]>

Co-authored-by: Alejandro Hernández Cordero <[email protected]>
@mjcarroll mjcarroll force-pushed the mjcarroll/added_mass_gravity branch from 4dc22d6 to 2629c90 Compare January 11, 2023 22:40
Signed-off-by: Michael Carroll <[email protected]>
@mjcarroll mjcarroll force-pushed the mjcarroll/added_mass_gravity branch from 8c9fc92 to 2776827 Compare January 11, 2023 23:44
Copy link
Contributor

@mabelzhang mabelzhang left a comment

Choose a reason for hiding this comment

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

I've read the code, but I'm not familiar with gz-physics, so I'm leaning on Joan's review for the most part.

For the tests, I guess the top-level test is test/common_test/added_mass.cc, and it's looking at 3 spheres without added mass, and 1 sphere with added mass. I don't know enough to say whether that's sufficient, but more tests can always be added later.

Since this is a new feature and doesn't break existing things, and CI is passing, it's probably okay.

@mjcarroll mjcarroll merged commit 65a0beb into gz-physics6 Jan 19, 2023
@mjcarroll mjcarroll deleted the mjcarroll/added_mass_gravity branch January 19, 2023 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌱 garden Ignition Garden
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants