Buoyancy and hydrodynamics improvements across Gazebo

Hi everyone,

We’ve recently merged a series of fixes and new features in gz-math and gz-sim that significantly improve Gazebo’s buoyancy and hydrodynamics support. These should be particularly relevant to the maritime community, but the gz-math changes are general-purpose and useful well beyond simulation of underwater/surface vehicles.

gz-math (general-purpose fixes and new functionality)

  • gz-math#724 — Fix Box::VolumeBelow / CenterOfVolumeBelow
    Replaces the previous mesh-based implementation with closed-form analytic formulas. Fixes:

    • Wrong volumes for non-axis-aligned cutting planes (the old code relied on exact float comparisons).
    • CenterOfVolumeBelow was returning the arithmetic mean of polygon vertices instead of the volumetric centroid.
    • Sphere<float> failed to compile due to hardcoded Vector3d.

    The new implementation is O(1), heap-allocation free, and numerically robust.

  • gz-math#730 — Add VolumeBelow / CenterOfVolumeBelow for Ellipsoid, Cylinder, Capsule and Cone
    Extends the volume API (previously only on Sphere and Box) to all four additional primitive shapes, using closed-form formulas (and Gauss-Legendre quadrature for the Cone). Header-only, zero-allocation, with C++ tests, Python bindings and Ruby bindings.

gz-sim (buoyancy and hydrodynamics)

  • gz-sim#3422 — Fix graded buoyancy SDF parsing and division by zero
    Three bug fixes in the Buoyancy system:

    • SDF parsing of <graded_buoyancy> was silently failing when other elements (like <enable>) appeared first.
    • Division by zero in the graded buoyancy loop when a shape was entirely below a layer boundary, which propagated NaN into torques and could crash physics.
    • Emit a warning when <graded_buoyancy> is specified without any <density_change> elements.
  • gz-sim#3423 — Add cylinder, capsule, ellipsoid and cone support to graded buoyancy
    Builds on gz-math#730 to extend the Buoyancy system to support cylinder, capsule, ellipsoid and cone geometries in both uniform and graded buoyancy modes.

  • gz-sim#3456 — Hydrodynamic updates
    Multiple improvements to the Hydrodynamics system:

    • Bug fixes: wrong sign in Coriolis matrix C(0,5), wrong index and sign in C(5,0) (restoring skew-symmetry), abs() truncating sub-unit velocities to int, first-timestep velocity spike, and a Coriolis correction when both <fluid_added_mass> and ocean current are active.
    • New functionality: guard against double-counting added mass when both native <fluid_added_mass> and plugin parameters are active, engine-aware deprecation warnings (DART vs Bullet/MuJoCo), and proper simulation reset support.
    • Refactoring: math extracted to HydrodynamicsUtils.hh with fixed-size Eigen types.
    • Documentation and tutorials updated to reflect engine-specific recommendations.

Backports

All of the above have been backported from Rotary to Jetty, Ionic, Harmonic and Fortress, so users on any current release should be able to pick them up in the next round of binary releases.

Thanks!

3 Likes