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

Adding tests for hydrodynamics #1617

Merged
merged 11 commits into from
Aug 24, 2022
Merged

Conversation

quarkytale
Copy link
Contributor

@quarkytale quarkytale commented Jul 27, 2022

Summary

Updated the plugin with downstream changes from LRAUV Hydrodynamics plugin with the added mass contribution sign and smoothening stateDot calculation.
Added tests for verifying:

  1. The plugin affects the motion of a body when a force is applied. Here comparing two models, first having hydrodynamics applied and second without it.
  2. Making sure that the transforms of the hydrodynamics plugin are correct by comparing 3 models in different positions and orientations having the same final velocities.

Setup

Using basic shapes: sphere and cylinders in the test world.
To get hydrodynamic plugin parameters for the models,

  • Choose any rigid body mass and dimensions
  • Inertia: sphere = 2/5 MR^2, cylinder = 1/2 MR^2
  • Added mass in z-direction: sphere = 2/3 ρπR^3, cylinder = ρπR^2 L -> zDotW
  • Linear drag coefficient using Stoke's law, C=6πηR -> zW
  • Quadratic drag coefficient,C=1/4 ρA ->zWW

Resources

  1. Added_Mass_Derivation
  2. Viscosity
  3. Linear Drag
  4. Quadratic Drag Model

Test it

Run the test ./build/ignition-gazebo6/bin/INTEGRATION_hydrodynamics
or check the world directly ign gazebo src/ign-gazebo/test/worlds/hydrodynamics.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.

@quarkytale quarkytale added tests Broken or missing tests / testing infra 🌱 garden Ignition Garden MBARI buoy Sponsored by MBARI buoy sim project: https:/osrf/buoy_sim labels Jul 27, 2022
@quarkytale quarkytale self-assigned this Jul 27, 2022
@quarkytale quarkytale linked an issue Jul 27, 2022 that may be closed by this pull request
Copy link
Contributor

@chapulina chapulina left a comment

Choose a reason for hiding this comment

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

Could you target this PR at ign-gazebo6 (Fortress)? That's where the plugin was first added. Then after merged we forward-port.

test/integration/hydrodynamics.cc Outdated Show resolved Hide resolved
test/integration/hydrodynamics.cc Outdated Show resolved Hide resolved
test/integration/hydrodynamics.cc Outdated Show resolved Hide resolved
@chapulina chapulina added the bug Something isn't working label Jul 29, 2022
@quarkytale quarkytale changed the base branch from main to ign-gazebo6 August 1, 2022 06:59
@quarkytale quarkytale force-pushed the quarkytale/hydrodynamics_tests branch from 73728b4 to df60e57 Compare August 5, 2022 19:35
@quarkytale quarkytale changed the base branch from ign-gazebo6 to main August 5, 2022 19:36
@quarkytale quarkytale force-pushed the quarkytale/hydrodynamics_tests branch from df60e57 to b3da1a7 Compare August 5, 2022 20:05
Signed-off-by: Dharini Dutia <[email protected]>
@quarkytale quarkytale force-pushed the quarkytale/hydrodynamics_tests branch from b3da1a7 to e96d7ad Compare August 5, 2022 20:09
@quarkytale quarkytale changed the base branch from main to ign-gazebo6 August 5, 2022 20:10
Signed-off-by: Dharini Dutia <[email protected]>
Signed-off-by: Dharini Dutia <[email protected]>
Signed-off-by: Dharini Dutia <[email protected]>
Signed-off-by: Dharini Dutia <[email protected]>
@quarkytale quarkytale marked this pull request as ready for review August 19, 2022 02:06
Signed-off-by: Dharini Dutia <[email protected]>
Copy link
Contributor

@arjo129 arjo129 left a comment

Choose a reason for hiding this comment

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

The test expectations seem reasonable. You might want to put in a disclaimer that added mass was flipped as thats a behaviour change. In any case we should look at deprecating added mass here in Garden and onwards. I'll follow up with a few more tests from my side next week.

src/systems/hydrodynamics/Hydrodynamics.cc Outdated Show resolved Hide resolved
src/systems/hydrodynamics/Hydrodynamics.cc Outdated Show resolved Hide resolved
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 tests look to me like good high-level tests. I'll defer any language-specific comments to more experienced reviewers.

Comment on lines 347 to 350
auto dt = (double)_info.dt.count()/1e9;
auto alpha = 0.9;
stateDot = alpha * (state - this->dataPtr->prevState)/dt
+ (1-alpha) * this->dataPtr->prevStateDot;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious, what's the reason to filter stateDot here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is to smoothen the rate of change of velocity, we can directly capture WorldLinearAccelerationt too.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm saying because having the rolling average filter here means that stateDot depends on all previously visited states (rather than just the last one). I'm not sure if or how much we want to worry about this, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a valid point. It was discussed in the Buoy Sim project that this might introduce lag and instability.
@arjo129 How should I proceed here? I'm thinking to get this in to be at par with the current changes (though I want to make sure this is generally sound and not specific for LRAUV). And have a separate effort to make this suitable for buoy as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

We can go ahead and remove this. It will not effect LRAUV much. Alternatively we can add an alpha. Finally I thought we were deprecating the added mass within this plugin and switching to the new added mass formulation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So I compared the previous implementation, the filter and WorldLinearAcceleration and the previous implementation is definitely the most stable. Going with that and we can iterate on it in future, thanks!

Signed-off-by: Dharini Dutia <[email protected]>
@quarkytale quarkytale force-pushed the quarkytale/hydrodynamics_tests branch from 40a39cb to 0fef948 Compare August 21, 2022 22:17
@codecov
Copy link

codecov bot commented Aug 21, 2022

Codecov Report

Merging #1617 (a91ec74) into ign-gazebo6 (4f93cde) will increase coverage by 0.14%.
The diff coverage is 100.00%.

@@               Coverage Diff               @@
##           ign-gazebo6    #1617      +/-   ##
===============================================
+ Coverage        64.54%   64.69%   +0.14%     
===============================================
  Files              320      321       +1     
  Lines            25904    26055     +151     
===============================================
+ Hits             16720    16855     +135     
- Misses            9184     9200      +16     
Impacted Files Coverage Δ
src/systems/hydrodynamics/Hydrodynamics.cc 88.07% <100.00%> (ø)
src/network/PeerInfo.cc 100.00% <0.00%> (+4.54%) ⬆️

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

@quarkytale quarkytale merged commit 25bdef6 into ign-gazebo6 Aug 24, 2022
@quarkytale quarkytale deleted the quarkytale/hydrodynamics_tests branch August 24, 2022 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 🌱 garden Ignition Garden MBARI buoy Sponsored by MBARI buoy sim project: https:/osrf/buoy_sim tests Broken or missing tests / testing infra
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Add tests for Hydrodynamics plugin
4 participants