# Simulate surface waves and marine vehicle dynamics

**URL:** <https://discourse.openrobotics.org/t/simulate-surface-waves-and-marine-vehicle-dynamics/47727>\
**Category:** Projects\
**Created:** [February 18, 2022, 8:51pm UTC](https://discourse.openrobotics.org/t/simulate-surface-waves-and-marine-vehicle-dynamics/47727 "2022-02-18T20:51:32Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![srmainwaring](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/srmainwaring/32/12607_2.png) [@srmainwaring](https://discourse.openrobotics.org/u/srmainwaring)\
**Post date:** [February 18, 2022, 8:51pm UTC](https://discourse.openrobotics.org/t/simulate-surface-waves-and-marine-vehicle-dynamics/47727/1 "2022-02-18T20:51:32Z")

</div>

This is a project to provide set of system plugins for simulating surface waves and the dynamics of marine surface craft. The original plugins were developed for legacy Gazebo and are being ported to Ignition. The target render system is Ogre2 and the plugins should work on both Ubuntu and macOS (using Metal).

The libraries are GPL because one of the core components used to implement the vehicle dynamics is [CGAL](https://www.cgal.org/) and the ocean simulation uses [FFTW](https://www.fftw.org/) to generate the surface waves. It would be possible to find alternatives for both components, but replacing [CGAL](https://www.cgal.org/) would be a substantial undertaking.

The migration is being tracked here: [Migrate to Ignition Gazebo · Issue #15 · srmainwaring/asv\_wave\_sim · GitHub](https://github.com/srmainwaring/asv_wave_sim/issues/15) and has progressed to the stage where there is an initial version that provides the main components that allow some of the example models that were used in Gazebo11 to be run on Ignition Garden.

[https://user-images.githubusercontent.com/24916364/154754258-d1fa28dc-d86f-4d79-8a96-672b5d74c8c9.mov](https://user-images.githubusercontent.com/24916364/154754258-d1fa28dc-d86f-4d79-8a96-672b5d74c8c9.mov)

There is a lot more to do, especially regarding optimisation, parameter setting and general usability. The details of the approach and references are described in the project README.

---

<div class="post-metadata">

**Author:** ![acxz](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/acxz/32/4985_2.png) [@acxz](https://discourse.openrobotics.org/u/acxz)\
**Post date:** [February 21, 2022, 11:10pm UTC](https://discourse.openrobotics.org/t/simulate-surface-waves-and-marine-vehicle-dynamics/47727/2 "2022-02-21T23:10:22Z")

</div>

This is really great work! Excited to see it progress and eventually make use of the wave physics!!!

---

<div class="post-metadata">

**Author:** ![caguero](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/caguero/32/3037_2.png) [@caguero](https://discourse.openrobotics.org/u/caguero)\
**Post date:** [February 24, 2022, 10:44pm UTC](https://discourse.openrobotics.org/t/simulate-surface-waves-and-marine-vehicle-dynamics/47727/3 "2022-02-24T22:44:46Z")

</div>

Hi Rhys,

Take a look at [GitHub - osrf/mbzirc: Simulator for the MBZIRC Maritime Grand Challenge](https://github.com/osrf/mbzirc/) as well. We also implemented waves for this the MBZIRC project. We still haven’t upstreamed all the pieces. It’s a simplification over what you did for VRX.

---

<div class="post-metadata">

**Author:** ![srmainwaring](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/srmainwaring/32/12607_2.png) [@srmainwaring](https://discourse.openrobotics.org/u/srmainwaring)\
**Post date:** [February 25, 2022, 9:54am UTC](https://discourse.openrobotics.org/t/simulate-surface-waves-and-marine-vehicle-dynamics/47727/4 "2022-02-25T09:54:32Z")

</div>

Hi @caguero, thanks for the link. I’ll see if I can get the MBZIRC project up and running on macOS for comparison.

I have been looking at various approaches to improve the visuals:

1. Use an HlmsLowLevel material and implement the ShaderParam plugin logic directly in the wave visual plugin (this appears to be the approach in MBZIRC)
2. Use the ShaderParam visual plugin alongside another visual plugin attaching to a wave entity
3. Define a PBS material within the existing system and attach to the visual (this is the method used in the example above)
4. Create a new Hlms and datablock overloading HlmsPbs for a wave mesh
5. Use a new Hlms and datablock overloading HlmsTerra using same vertex tricks in that implementation applied to waves (there is a example for ogre2.1 here: [https://forums.ogre3d.org/viewtopic.php?t=93592](https://forums.ogre3d.org/viewtopic.php?t=93592) with repo [GitHub - yoyTeam/OgreOcean: Simple Ocean implementation using Ogre 2.1 and the Terra tutorial as base, with a nice baked animated texture, for more info see http://www.ogre3d.org/forums/viewtopic.php?f=25&t=93592](https://github.com/yoyTeam/OgreOcean) which uses a similar pixel shader to the one used in VRX with a pseudo wave generator in the vertex shader and additional bump map sampling with a fine grained mesh (4096x4096) to get detail.

Options 1 and 2 are quite similar and really only differ in that 2 factors out common code for defining custom shaders. At present multiple visual plugins are not supported which leaves option 1 as the approach using Ogre1 type materials and where the wave generation code is also in the shader.

In my case the vertex positions are calculated on the CPU, so I need a fast way to get these into the GPU. One way would be to use GPU code for the FFT wave generation as well as for sinusoidal and trochoidal waves. There is a OpenCL option for generating the waves, but it uses a read-back from the GPU into CPU vertices (for the physics and the visual), and then ships back to the GPU as an Ogre1 material for visuals. In principal that FFT shader code could be used in a render pass directly for the visuals, but I’m someway way away from understanding the Hlms and compositor systems well enough to implement that.

The other options 4, and 5 that use a custom Hlms could be seen as intermediate steps to using shader based wave generation. The Ogre2 examples for these are quite advanced and I’m slowly working through the methods to see how they can be adapted. Most of the wave generation code I use displaces the vertices in the xy-plane as well vertically, and I’m not yet sure whether the logic for cell tiling used in Terra can relax it’s assumptions about a fixed planar grid. With periodic boundary conditions it should tile correctly but that would all need to be worked through.

---

<div class="post-metadata">

**Author:** ![srmainwaring](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/srmainwaring/32/12607_2.png) [@srmainwaring](https://discourse.openrobotics.org/u/srmainwaring)\
**Post date:** [March 25, 2022, 4:12pm UTC](https://discourse.openrobotics.org/t/simulate-surface-waves-and-marine-vehicle-dynamics/47727/5 "2022-03-25T16:12:21Z")

</div>

Hi Carlos,

I’ve managed to get the MBZIRC project built on macOS running Ignition Gazebo and ROS2 Galactic. With a little bit of tuning it’s working and it’s very useful to have a baseline.

As a side note: it would be nice to be able to control the thruster plugin for the USV using ArduPilot - this should be possible with some tweaks to the ardupilot\_gazebo system plugin.

 ![mbzirc_macos_simple_demo](https://us1.discourse-cdn.com/flex022/uploads/ros/original/1X/690ae28194312aad735d2df555f09e2531b9a72b.jpeg)

---

<div class="post-metadata">

**Author:** ![srmainwaring](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/srmainwaring/32/12607_2.png) [@srmainwaring](https://discourse.openrobotics.org/u/srmainwaring)\
**Post date:** [May 27, 2022, 2:11pm UTC](https://discourse.openrobotics.org/t/simulate-surface-waves-and-marine-vehicle-dynamics/47727/6 "2022-05-27T14:11:52Z")

</div>

An example of the sea surface simulation applied to the [GitHub - osrf/mbari\_wec\_gz: Simulation of wave energy harvesting buoy](https://github.com/osrf/buoy_sim) project.

[![](https://us1.discourse-cdn.com/flex022/uploads/ros/original/3X/3/f/3f6789d129823e42e9c0582fd95f611920149bb7.jpeg "Wave buoy Gazebo simulation") ](https://vimeo.com/714469817)

There is still optimisation required in the physics calculations in order to run complex models, such as the wave buoy, that have many links and collisions each contributing to buoyancy and hydrodynamics. For the visuals two approaches have been investigated. The first uses dynamic vertices - recalculating the vertices, normals and tangents then copying them to the GPU each frame. This is not fast and does not scale well for tiling as each geometry instance must update its vertex buffers. It does make it easy to use PBS materials however. This is the approach used in the clip. The second approach updates texture maps for the displacements and the surface derivatives. The textures are updated then staged for upload to the GPU each frame. This is done once per frame regardless of how many tiles are loaded (each share the same material). This is much better for large scenes but requires custom shaders that apply the displacements and compute the TBN matrix in the vertex shader. To use PBS materials with this approach requires a custom Hlms and adopting shader pieces to override the PBS vertex and fragment shaders where needed. This is work in progress. The second approach scales better, and is amenable to moving the wave model to the GPU as well.

To optimise the physics requires a fast-read back of the wave height given a surface state and collection of model mesh points. Also for future work.

---

<div class="post-metadata">

**Author:** ![sickopickle](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/sickopickle/32/26785_2.png) [@sickopickle](https://discourse.openrobotics.org/u/sickopickle)\
**Post date:** [November 18, 2024, 4:33am UTC](https://discourse.openrobotics.org/t/simulate-surface-waves-and-marine-vehicle-dynamics/47727/7 "2024-11-18T04:33:00Z")

</div>

How can I simulate waves on Ubuntu 24.04.1 and Gazebo Harmonic and ROS Jazzy Jalisco? I tried using the asv\_wave\_sim mentioned here, but got the following error:

CMake Error at C:/vcpkg/scripts/buildsystems/vcpkg.cmake:782 (\_find\_package):  
By not providing “Findgz-cmake3.cmake” in CMAKE\_MODULE\_PATH this project  
has asked CMake to find a package configuration file provided by  
“gz-cmake3”, but CMake did not find one.

Could not find a package configuration file provided by “gz-cmake3” with  
any of the following names:

```
gz-cmake3Config.cmake
gz-cmake3-config.cmake

```

Add the installation prefix of “gz-cmake3” to CMAKE\_PREFIX\_PATH or set  
“gz-cmake3\_DIR” to a directory containing one of the above files. If  
“gz-cmake3” provides a separate development package or SDK, be sure it has  
been installed.  
Call Stack (most recent call first):  
CMakeLists.txt:12 (find\_package)

This is mentioned here [👩‍🌾 Error finding gz-cmake3 package build regression · Issue #1004 · gazebosim/gz-rendering · GitHub](https://github.com/gazebosim/gz-rendering/issues/1004) and was supposedly fixed but I’m still getting this error. Can anyone help? Thanks!

---

<div class="post-metadata">

**Author:** ![morgan544545](https://avatars.discourse-cdn.com/v4/letter/m/0ea827/32.png) [@morgan544545](https://discourse.openrobotics.org/u/morgan544545)\
**Post date:** [August 19, 2025, 1:00pm UTC](https://discourse.openrobotics.org/t/simulate-surface-waves-and-marine-vehicle-dynamics/47727/8 "2025-08-19T13:00:16Z")

</div>

> [@srmainwaring](#):
>
> This is a project to provide set of system plugins for simulating surface waves and the dynamics of marine surface craft. The original plugins were developed for legacy Gazebo and are being ported to Ignition. The target render system is Ogre2 and the plugins should work on both Ubuntu and macOS (using Metal).
> 
> The libraries are GPL because one of the core components used to implement the vehicle dynamics is [CGAL](https://www.cgal.org/) and the ocean simulation uses [FFTW](https://www.fftw.org/) to generate the surface waves. It would be possible to find alternatives for both components, but replacing [CGAL](https://www.cgal.org/) would be a substantial undertaking.
> 
> The migration is being tracked here: [Migrate to Ignition Gazebo · Issue #15 · srmainwaring/asv\_wave\_sim · GitHub](https://github.com/srmainwaring/asv_wave_sim/issues/15) and has progressed to the stage where there is an initial version that provides the main components that allow some of the example models that were used in Gazebo11 to be run on Ignition Garden.

I think this is a really useful project, especially since it brings the older Gazebo plugins into Ignition with support for Ogre2. Having surface wave simulation and marine craft dynamics available across Ubuntu and macOS will definitely help researchers and developers working in this area. I had a look at the migration progress and it’s great to see that example models from Gazebo11 are already running in Ignition Garden. Looking forward to seeing how this develops further.

---

<div class="post-metadata">

**Author:** ![Rezenders](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/rezenders/32/6734_2.png) [@Rezenders](https://discourse.openrobotics.org/u/Rezenders)\
**Post date:** [September 5, 2025, 2:42pm UTC](https://discourse.openrobotics.org/t/simulate-surface-waves-and-marine-vehicle-dynamics/47727/9 "2025-09-05T14:42:05Z")

</div>

Hi @caguero @srmainwaring

Since @caguero mentioned that you also did some stuff for VRX, I wonder what is the relation between the `gz::sim::systems::WavesModel` from the asv\_wave\_sim repo and the `maritime::Surface` plugin from the VRX project. Are they different? If so, how do they differ?

I wonder whether these plugins support collisions different from or as this seems to be a limitation from the gazebo native Buoyancy plugin.  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![srmainwaring](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/srmainwaring/32/12607_2.png) [@srmainwaring](https://discourse.openrobotics.org/u/srmainwaring)\
**Post date:** [September 9, 2025, 12:48pm UTC](https://discourse.openrobotics.org/t/simulate-surface-waves-and-marine-vehicle-dynamics/47727/10 "2025-09-09T12:48:25Z")

</div>

Hi @Rezenders , I did a bit of work with VRX to provide a service to help keep the wave visuals and physics in sync, IIRC I may have rewrote some of the shader as well. `asv_wave_sim` is a separate project maintained by me. It has a different wave field algo (FFT generated waves), so more fidelity than the superposition of 3 trochoid waves in the Gazebo plugins. The hydrodynamics is calculated differently as well, calculating the contribution of each submerged triangle from the collision mesh to the buoyancy and drag. The details are in the articles referenced at the bottom of the repo README.

I mainly use ArduPilot for vehicle control. ArduPilot Discourse and the repo `ArduPilot/SITL_Models` have a number of examples using the plugins (BlueOS BlueBoat, sailing catamarans etc.).

Collisions are calculated using the vehicle collision mesh, which is also used for the hydrodynamics calculation. Visuals are just what appears in the GUI and do not affect the physics.

---

<div class="post-metadata">

**Author:** ![hu\_Xiaolan](https://sea2.discourse-cdn.com/flex022/user_avatar/discourse.openrobotics.org/hu_xiaolan/32/31265_2.png) [@hu\_Xiaolan](https://discourse.openrobotics.org/u/hu_Xiaolan)\
**Post date:** [November 26, 2025, 7:20am UTC](https://discourse.openrobotics.org/t/simulate-surface-waves-and-marine-vehicle-dynamics/47727/11 "2025-11-26T07:20:09Z")

</div>

Do you need any support for rapid prototyping?
