srmainwaring / asv_wave_sim

This package contains plugins that support the simulation of waves and surface vessels in Gazebo.
GNU General Public License v3.0
114 stars 31 forks source link

Collision pose not accounted for in hydrodynamics plugin #35

Closed srmainwaring closed 2 years ago

srmainwaring commented 2 years ago

The hydrodynamics plugin does not account for the pose of the collision relative to the origin of the link

Description

The hydrodynamics system plugin uses the model's collision meshes to calculate buoyancy and hydrodynamics forces. At each update step a copy of the collision mesh (CGAL surface mesh) is updated to place it the the correct location relative to the wave field. The engine then determines the number of submerged triangles, centroid heights above the local wave field, pressure forces etc.

The function ApplyPose in src/systems/hydrodynamics/Hydrodynamics.cc applies the transformation. In the functions HydrodynamicsPrivate::InitPhysics and HydrodynamicsPrivate::UpdatePhysics the link pose is used; no account is taken for the pose of the collision relative to the link origin.

The results is incorrect buoyancy forces for objects with offset collisions. This may result in objects floating at the wrong level, or upside down.

Example

gzsim_buoyancy_test_4_fail

The example illustrates a number of spherical buoys with the visuals, collisions and inertial elements offset from the link origin. Examples 4 (left most) and 3 (second from left) have the CoM at the link origin but the collision off set 0.5 m below. In both cases the expected behaviour is displayed in example 2 (second from right), where the CoM is displaced down 0.5 m and the collision remains at the origin.

https://user-images.githubusercontent.com/24916364/170686783-f1a4e1f1-2dcf-4765-9245-6a950eaa5b34.mov

srmainwaring commented 2 years ago

Fixed by #36