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

Coordinate the physics and visualization of the wave field #23

Closed
osrf-migration opened this issue Jul 20, 2018 · 7 comments
Closed

Coordinate the physics and visualization of the wave field #23

osrf-migration opened this issue Jul 20, 2018 · 7 comments
Labels
enhancement New feature or request major
Milestone

Comments

@osrf-migration
Copy link

Original report (archived issue) by Brian Bingham (Bitbucket: brian_bingham).


Currently the visualization of the surface waves is independent of the wave displacements that affect the vessel motion. We have them setup to use the same wave parameters (amplitude, direction, etc.), but they are not synchronized in time.
See a demo of the effect: https://vimeo.com/253718860 And here is what happens if you have large wave in the physics, but the same small waves in the rendering: https://vimeo.com/253842494

@osrf-migration
Copy link
Author

Original comment by Carlos Agüero (Bitbucket: caguero, GitHub: caguero).


  • changed milestone from "0.2" to "0.3"

@osrf-migration
Copy link
Author

Original comment by Brian Bingham (Bitbucket: brian_bingham).


  • set assignee_account_id to "557058:6c52d6e5-77e0-41a8-8b6e-cb9462f4d5f1"
  • set assignee to "brian_bingham (Bitbucket: brian_bingham)"

@osrf-migration
Copy link
Author

Original comment by Carlos Agüero (Bitbucket: caguero, GitHub: caguero).


  • changed milestone from "0.3" to "0.5"

@osrf-migration
Copy link
Author

Original comment by Brian Bingham (Bitbucket: brian_bingham).


Rhys provided a very interesting solution in the asv_wave_sim project. Going through that project, there are two significant innovations:

  1. The visualization and physics share a common wave field. This is done by having a WavefieldModelPlugin associated with the Ocean model. Two WavefieldVisualPlugins request the wave field parameters via Gazebo messages which then drives the OpenGL shader. The HydrodynamicsPlugin associated with the physical objects within the wave field access a shared WavefieldEntity pointer which is used to access a Wavefield object directly from the WavefieldModelPlugin.
  2. The buoyancy calculation is generalized to use triangle meshes as described in Jacques Kerner's two part blog describing boat physics for games - see asv_wave_sim Acknowledgments.

The WAM-V geometry (twin cylindrical hulls) is sufficiently simple that, as a first step, we might consider Rhys's synchronization of the visual and physical (1) without adding the complexity of mesh-based buoyancy (2). This might also allow us to avoid licensing issues associated with using CGAL.

Here is my notes from going through the code...


asv_wave_sim Explanation

Model: ocean_waves

The ocean_waves model includes three plugins:

  1. WavefieldModelPlugin, inherits from ModelPlugin. Instantiates a WavefieldEntity and a Wavefield object. Wave field parameters are passed to the Wavefield object. Subscribes to Gazebo message on ~/request. When receives message, responds on ~/response with wave field parameters.
  2. A WavefieldVisualPlugin for the water surface, inherits from VisualPlugin. Requests wave parameters from the WavefieldModelPlugin via Gazebo message. Uses rendering API to set input parameters to OpenGL shader GernstnerWaves.frag.
  3. Another WavefieldVisualPlugin for below the water surface. Uses the same parameters and shader.

WavefieldModelPlugin, OnUpdate

The update is throttled to a nominal 30 Hz. The WavefieldEntity is updated, which calls the Wavefield Update and UpdateGerstnerWave methods. The Wavfield UpdateGerstnerWave method modifies the underlying CGAL Surface_mesh object based on the Gerstner wave model for the water surface.

Model: box

For objects within the wave field, the HydrodynamicsPlugin, a ModelPlugin, connects the object to the wave field. The wave_model plugin parameter specifies the name of the model that includes the WavefieldModelPlugin.

HydrodynamicsPlugin, Init

Calls InitPhysics() which retrieves the specified ModelPtr by name, which then gets the a pointer to a WavefieldEntity object from within the WavefieldModelPlugin. Finally calls the WavefieldEntity GetWaveField method to return a shared pointer to the Wavefield object.

Creates a vector of HydrodynamicsLinkData objects, one for each link in the model. Each HydrodynamicsLinkData objects includes...

  • WavefieldSampler (Wavefield.hh) pointer
  • Hydrodynamics (Physics.hh) pointer
    • Private data of Hydrodynamics object includes a WavefieldSampler pointer.

HydrodynamicsPlugin, OnUpdate

Calls UpdatePhysics(), which again retrieves the Wavefield object pointer (why do this again?). Then loops through the vector of HydrodynamicsLinkData objects to...

  • Update the each Hydrodynamics.WavefieldSampler
  • Call Hydrodynamics.Update() method which (takes the Hydrodynamics.WavefieldSampler as an input argument?) calculates forces and torques on the link

The above explanation is limited - I may be missing some of the implementation.

@osrf-migration
Copy link
Author

Original comment by Carlos Agüero (Bitbucket: caguero, GitHub: caguero).


  • changed milestone from "0.5" to "1.1"

@osrf-migration
Copy link
Author

Original comment by Brian Bingham (Bitbucket: brian_bingham).


PR #78 looks like a good solution moving forward. We need to update the wave-visualization branch and start working integrating into default.

@osrf-migration
Copy link
Author

Original comment by Carlos Agüero (Bitbucket: caguero, GitHub: caguero).


  • changed state from "new" to "resolved"

See pull request #107.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request major
Projects
None yet
Development

No branches or pull requests

1 participant