Maybe this example might help you understand the fundamentals. Also its an example with URDF, which might be usefull for further ROS integration. Here you have the launch files and the URDF to test it. Also the script to calculate the Buoyancy Forces of a sphere.
Here you have a full video tutorial: VIDEO
main.launch
spawn_simple_sphere.launch
spawn_robot_urdf.launch
ocean.world
simple_floating_sphere.urdf
volume_calculator.py
inertial_calculator.py
You can launch the world through the launch main.launch, and spawn the sphere through the spawn_simple_sphere.launch
Then you can play around with the mass , radius and fluid_desnisty to get different buoyancy.
You can calculate the perfect neutral buoyancy with the help of the volume_calculator.py script. It will tell you the force produced by buoyancy and of the weight of the Sphere. All this is applicable to any shape of course.
Hope this helps understand a bit better and complement the previous answers given.
Edit:
Here you have a second part explaining how to do it with a complex 3D shape from a dae file: VIDEO PART 2
Basically you could try it with the 3D mesh real volume but the plugin doesnt fully support that still so I also teach you how to know the volume of the bounding box and use that instead.
The formula we use too calculate the neutral buoyancy mass is:
Ff
: Final Force
Fb
: Buoyancy Force
W
: Weight of the object
Ff = Fb - W
Ff = 0
, because we want neutral buoyancy.
Fb = FluidDensity * 3dMeshVolume
W = mass * gravity
mass = FluidDensity * 3dMeshVolume
This mass
is the one you have to put in the URDF file.
Bare in mind that even with this the force distribution has to be evenly distributed otherwise it can make the robot be in an unstable situation. But that's another topic that you will need to calibrate yourself depending on what you want.
Edit2:
Here I give you the urdf for the 3DMesh version and the geometric version.
C:\fakepath\naro_buoyancy.urdf.sdf
C:\fakepath\naro_geometric_buoyancy.urdf.sdf
For the 3D mesh you use Blender 3DPrint plugin to get its volume.
For the geometric versions you dont need that, with formulas is ok. You can use the volume.py
that I give at the top of the question to calculate all you need including the mass that it has to have to have neautral buoyancy.
Here you have the VIDEO PART3 that explain all this in more detail.
Also bare in mind that when changing the mas of an object and shape, you have to recalculate the inertial matrix. I give a pythons script also to make those calculations for you inertial_calculator.py
.
The only thing that it wouldn't be solve is that there is no friction with the fluid and therefore it migh move in un unstable way.
It might be easier for someone to help you if you provide a simple example model which reproduces the problem you're having. The yellow submarine on the underwater.world example stays in place: http://gazebosim.org/tutorials?tut=hydrodynamics&cat=plugins
I am making a bluerobotics T200 thruster. It's relatively small and weighs 0.211 kgs. When I create it in gazebo it ends up going to the surface and floating at the top. I guess if I attach the thruster to a thruster then it won't have the same issue.A simpler example of my problem would be if I make a tube which weighs 0.211kgs but with the same density as water (along with the hydrodynamics plugin) it floats at the surface instead of staying in place.
Are you using the `<volume>` tag?
I am using the model editor and I am not aware of a volume tag so no.