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

Make WindEffects configurable on a location basis #1357

Merged
merged 2 commits into from
Apr 6, 2022

Conversation

hidmic
Copy link
Contributor

@hidmic hidmic commented Feb 23, 2022

🎉 New feature

Closes #1354.

Summary

This patch turns the force approximation scaling factor in the WindEffects plugin into a piecewise scalar field, configurable from the SDF file. It can still be configured as a scalar, so it remains backwards compatible.

Test it

An integration test case has been added to the INTEGRATION_wind_effects test suite.

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • 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.

@github-actions github-actions bot added the 🌱 garden Ignition Garden label Feb 23, 2022
@osrf-triage osrf-triage added this to Inbox in Core development Feb 23, 2022
@hidmic
Copy link
Contributor Author

hidmic commented Feb 23, 2022

There are a few questions that remain to be answered:

  • Is the force approximation scaling factor the best place to introduce a dependency on link location? Should the wind velocity itself be dependent on location instead?
  • Should Polynomial3, SeparableFunction3d, and PiecewiseScalarField3d be here in an anonymous namespace or over at ignition-math? If so, sdformat parsing needs to be put elsewhere.
  • Are we OK with a dynamic schema for convenience? Right now, <force_approximation_scaling_factor> can take either a scalar or nested structures.
  • Is a bounds attribute OK for managing open and closed subspaces? I don't like it very much, but I couldn't come up with anything better.

On a related note, I couldn't easily run codecheck. Maybe I'm not using the right directory layout?

@hidmic
Copy link
Contributor Author

hidmic commented Feb 23, 2022

FYI @caguero

This was referenced Feb 23, 2022
@hidmic
Copy link
Contributor Author

hidmic commented Feb 23, 2022

Talking to @azeey earlier today, he rightly pointed out that simply applying forces to link frame origins does not allow for torques to be developed at the interface between regions.

Then the question is how we model wind forces. Right now we make them proportional to the link mass and linear velocity w.r.t that of the wind. We could compute the solid geometries that result from the intersection between a link's collision geometry and each region (a là CSG), assume homogeneous density, and apply the same model to each solid geometry independently.

I wonder though, if forces proportional to some cross-section area normal to the direction of the wind wouldn't give us "better" results (the definition of good, let alone better, is quite blurry to me).

@hidmic
Copy link
Contributor Author

hidmic commented Feb 23, 2022

Is the force approximation scaling factor the best place to introduce a dependency on link location? Should the wind velocity itself be dependent on location instead?

Hmm, a piecewise vector field for wind velocity would indeed be simpler to reason about than this scaling factor (which is bound to the approximation model).

@arjo129
Copy link
Contributor

arjo129 commented Feb 25, 2022

Talking to @azeey earlier today, he rightly pointed out that simply applying forces to link frame origins does not allow for torques to be developed at the interface between regions.

Then the question is how we model wind forces. Right now we make them proportional to the link mass and linear velocity w.r.t that of the wind. We could compute the solid geometries that result from the intersection between a link's collision geometry and each region (a là CSG), assume homogeneous density, and apply the same model to each solid geometry independently.

I wonder though, if forces proportional to some cross-section area normal to the direction of the wind wouldn't give us "better" results (the definition of good, let alone better, is quite blurry to me).

I had wondered about this actually. It would seem to me that there is some formulation that will be similar to the hydrodynamics formulation where we can capture the changing faces on the behaviour of the wind. However, I think we don't need to go to this detail at all for the LRAUV. One thing to note is that the LRAUV will experience torque given its CG is not the same as the link so for now I think we can get away with what we have implemented.

Copy link
Contributor

@caguero caguero left a comment

Choose a reason for hiding this comment

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

  • I definitely recommend to move Polynomial3, Region3d, SeparableFunction3d, and PiecewiseScalarField3d to Ignition Math. Overall, it'll make the review easier to follow, as we'll be splitting everything into multiple PRs.

  • I noticed a few style inconsistencies. E.g.: Not using this-> for every member or function, not using the function separators (////////////////////////////////////////////////) and not using Doxygen in the function declarations.

  • I agree that maybe we can live with the fact that some torques won't be generated if we apply the force at the link origin.

  • We probably need to parse the SDF data in this plugin, and then, pass the numeric values to the Ignition Math classes that we use.

  • I recommend to document the new SDF parameters in the WindEffects.hh file. Open it to see how the current parameters are described. It'll be infinite more useful if you include an example and explain what you're trying to achieve and how that translates into the SDF parameters. It could be your test but explained for a human.

@chapulina chapulina moved this from Inbox to In review in Core development Mar 1, 2022
@chapulina chapulina linked an issue Mar 1, 2022 that may be closed by this pull request
@hidmic hidmic force-pushed the location-bound-wind-effects branch from 4f41954 to ad4b5ab Compare March 15, 2022 15:56
@hidmic
Copy link
Contributor Author

hidmic commented Mar 15, 2022

I definitely recommend to move Polynomial3, Region3d, SeparableFunction3d, and PiecewiseScalarField3d to Ignition Math. Overall, it'll make the review easier to follow, as we'll be splitting everything into multiple PRs.

@caguero See gazebosim/gz-math#387. That PR can of course be further split.

I noticed a few style inconsistencies. E.g.: Not using this-> for every member or function, not using the function separators (////////////////////////////////////////////////) and not using Doxygen in the function declarations.

@caguero I think I've addressed this, though I haven't added Doxygen documentation to private functions that are implementation details (which are fairly self explanatory on their own already).

I agree that maybe we can live with the fact that some torques won't be generated if we apply the force at the link origin.

@caguero Fair enough.

We probably need to parse the SDF data in this plugin, and then, pass the numeric values to the Ignition Math classes that we use.

@caguero Done.

I recommend to document the new SDF parameters in the WindEffects.hh file. Open it to see how the current parameters are described.

@caguero Done.

It'll be infinite more useful if you include an example and explain what you're trying to achieve and how that translates into the SDF parameters. It could be your test but explained for a human.

@caguero We have class documentation and regression tests. We can add an example too if you think it's worth it.

@hidmic hidmic requested a review from caguero March 15, 2022 16:32
@chapulina chapulina added MBARI-LRAUV Sponsored by MBARI-LRAUV project: https://github.com/osrf/lrauv needs upstream release Blocked by a release of an upstream library and removed needs upstream release Blocked by a release of an upstream library labels Mar 28, 2022
Its <force_approximation_scaling_factor> is now a
piecewise scalar field configurable from the SDF file.
Backwards compatibility has been observed.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
@hidmic hidmic force-pushed the location-bound-wind-effects branch from 68310f3 to a6ac58b Compare April 1, 2022 21:38
@hidmic
Copy link
Contributor Author

hidmic commented Apr 1, 2022

Rebased to resolve conflicts.

@hidmic
Copy link
Contributor Author

hidmic commented Apr 1, 2022

@codecov
Copy link

codecov bot commented Apr 2, 2022

Codecov Report

Merging #1357 (a6ac58b) into main (f6ba375) will increase coverage by 0.05%.
The diff coverage is 63.20%.

@@            Coverage Diff             @@
##             main    #1357      +/-   ##
==========================================
+ Coverage   62.34%   62.39%   +0.05%     
==========================================
  Files         317      317              
  Lines       24419    24489      +70     
==========================================
+ Hits        15224    15281      +57     
- Misses       9195     9208      +13     
Impacted Files Coverage Δ
.../gui/plugins/transform_control/TransformControl.cc 7.36% <ø> (+0.01%) ⬆️
...lization_capabilities/VisualizationCapabilities.cc 3.66% <0.00%> (ø)
src/rendering/RenderUtil.cc 36.94% <0.00%> (ø)
src/systems/contact/Contact.hh 100.00% <ø> (ø)
src/systems/particle_emitter/ParticleEmitter.cc 55.40% <0.00%> (ø)
src/systems/scene_broadcaster/SceneBroadcaster.hh 100.00% <ø> (ø)
src/systems/thruster/Thruster.cc 92.30% <ø> (-0.06%) ⬇️
src/systems/wind_effects/WindEffects.cc 78.82% <79.74%> (+0.68%) ⬆️
...ems/collada_world_exporter/ColladaWorldExporter.hh 100.00% <100.00%> (ø)
...ems/kinetic_energy_monitor/KineticEnergyMonitor.hh 100.00% <100.00%> (ø)
... and 2 more

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 8c690ff...a6ac58b. Read the comment docs.

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.

This looks good to me now.

@hidmic
Copy link
Contributor Author

hidmic commented Apr 5, 2022

Thanks @arjo129 !

@chapulina how do we go about failing CI jobs? Do we merge despite them or do we quarantine PRs until that's solved?

@chapulina
Copy link
Contributor

how do we go about failing CI jobs? Do we merge despite them or do we quarantine PRs until that's solved?

Everything that's Required must be green. For this branch, that's none of the jobs 🙃 Which means all jobs have known flakes. So we look at them and if the failures aren't new or related to the PR we merge. That's the case here, so merging!

@chapulina chapulina merged commit a5464eb into gazebosim:main Apr 6, 2022
Core development automation moved this from In review to Done Apr 6, 2022
@chapulina chapulina moved this from Done to Highlights in Core development Apr 6, 2022
@hidmic hidmic deleted the location-bound-wind-effects branch April 6, 2022 18:16
@j-rivero j-rivero removed this from Highlights in Core development May 6, 2022
@j-rivero j-rivero mentioned this pull request Sep 16, 2022
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌱 garden Ignition Garden MBARI-LRAUV Sponsored by MBARI-LRAUV project: https://github.com/osrf/lrauv
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Location-bound wind effects
4 participants