Use your own world
Any launch file here takes world:=, with a file name found on Gazebo’s
resource path or a full path:
ros2 launch kai_custom_vehicle sim.launch.xml world:=/path/to/my_world.sdf
The easiest start is a copy of open_water.sdf, or of one of the four
site worlds, which add a terrain to the same contract:
cp $(ros2 pkg prefix --share kai_gazebo)/worlds/open_water.sdf my_world.sdf
What a world needs
Piece |
Why |
In |
|---|---|---|
Physics, user commands and scene broadcaster systems |
Physics, spawning models, and the GUI view |
|
The gz-maritime buoyancy system |
Floats the collisions vehicles mark |
|
A wave source |
The moving sea: its state, the |
|
The |
Draws the sea |
|
Sensor systems |
IMU, magnetometer, GPS and rendered sensors |
see Add sensors |
The water’s optics |
What the water does to light, for underwater cameras and the underwater rendering |
|
|
GPS origin and magnetic field location |
Portuguese Ledge, Monterey Bay |
Leave out what you don’t need. A world without waves, for example, still floats vehicles; it just draws no sea.
The buoyancy system
<plugin filename="gz-maritime-buoyancy-system"
name="gz::sim::maritime::Buoyancy">
<graded_buoyancy>
<default_density>1025</default_density>
<density_change>
<above_depth>0</above_depth>
<density>1</density>
</density_change>
</graded_buoyancy>
<enable_by_default>false</enable_by_default>
</plugin>
Read it as: seawater (1025 kg/m³) everywhere, except above z = 0, where there
is air (1 kg/m³). <enable_by_default>false</enable_by_default> means the
world floats nothing on its own: only the collisions vehicles mark with
gz:buoyancy="true" displace water.
Marked collisions float in every mode. The tags only decide what happens to the unmarked ones:
|
|
Unmarked collisions |
|---|---|---|
none |
not set |
All float. Every collision of every model, as in stock Gazebo. |
present |
not set |
The listed models or links float. |
none |
|
None float. Only marked collisions do. Recommended. |
present |
|
All float; the list changes nothing. |
The recommended mode is the one that needs to know nothing about your
vehicles. The <enable> list still works, for a vehicle whose model you can’t
edit, and takes names as spawned: <enable>blueboat::hull_displacement</enable>.
This is Gazebo’s own buoyancy system plus the marked-collision change
(gz-sim 229ec07e),
carried by gz_buoyancy until a Gazebo release ships it. When it does, the
plugin line becomes gz-sim-buoyancy-system / gz::sim::systems::Buoyancy
and nothing else changes.
The water’s optics
Every shipped world sets its water with a Jerlov type, the site’s: IB
for open ocean, 1C for a clear coast, 3C for a harbour or a lake, 5C
for a murky lake, I for a pool. Pick the one closest to yours, or give a
<visibility> in metres:
<plugin filename="gz-maritime-water-optics-system"
name="gz::sim::maritime::WaterOptics">
<jerlov>3C</jerlov>
</plugin>
It applies everywhere below the water level (z = 0 by default), indoors
too. Without it, the world has clear water. Cameras see through it only
with the underwater camera plugin, or with model://underwater_optics in
the world, which draws it in the GUI and in colour cameras (RGBD
included). Depth, segmentation, thermal and lidar sensors stay as they
are, by design, and orthographic cameras are drawn as in air.
The world name
The wave service includes the world’s name:
/world/<name>/wave/set_parameters. Every world shipped here is named
default, whatever its file is called, so the commands in these docs work
on all of them. Keep that name in your own world and they will work there
too; if you pick another, commands you type yourself have to use it. The
launch files don’t care either way.
Adding a seabed
For shallow water, or an underwater vehicle working near the bottom, add a static model under the water:
<model name="seabed">
<static>true</static>
<pose>0 0 -20 0 0 0</pose>
<link name="link">
<collision name="collision">
<geometry><box><size>200 200 1</size></box></geometry>
</collision>
<visual name="visual">
<geometry><box><size>200 200 1</size></box></geometry>
</visual>
</link>
</model>
It doesn’t float, because nothing marks its collision.
Next: Troubleshooting.