-
Notifications
You must be signed in to change notification settings - Fork 15
How to generate new DEMs?
The Gazebo Simulation uses heightmaps to simulate the different types and shpes of terrain. NetCDF files containing heightmap information can be loaded through using the configuration in the SDFormat XML file that contains the world. The Portuguese ledge model that can be found in the Gazebo Fuel model database serves as an example on how to load the data through the XML file. We can load the model directly from Gazebo Fuel
with a simple <include>
in our <world>
XML file:
<?xml version="1.0" ?>
<sdf version="1.9">
<world name="portuguese_ledge">
<include>
<uri>
https://fuel.gazebosim.org/1.0/OpenRobotics/models/Portuguese Ledge
</uri>
</include>
</world>
</sdf>
This should show the Portuguese Ledge in the gazebo sim GUI:
The portugese ledge model can be downloaded from fuel. Thee process of loading a heightmap can be seen when looking at the model.sdf
file content:
<?xml version="1.0" ?>
<sdf version="1.9">
<!--
This model itself only loads Tile1, but other models and worlds can
directly refer to the other tiles.
-->
<model name="portuguese_ledge">
<static>true</static>
<link name="link">
<collision name="collision">
<geometry>
<heightmap>
<uri>meshes/PortugueseLedgeTile1_DecDeg.nc</uri>
<size>1000 1000 25.34</size>
</heightmap>
</geometry>
</collision>
<visual name="visual">
<geometry>
<heightmap>
<use_terrain_paging>true</use_terrain_paging>
<texture>
<diffuse>materials/textures/dirt_diffusespecular.png</diffuse>
<normal>materials/textures/flat_normal.png</normal>
<size>10</size>
</texture>
<uri>meshes/PortugueseLedgeTile1_DecDeg.nc</uri>
<size>1000 1000 25.34</size>
</heightmap>
</geometry>
</visual>
</link>
</model>
</sdf>
You can see there is a <visual>
part and a <collision>
part, this is to allow the user to load different files for collision and visual purposes (in order to improve performance usually models have a lower resolution collision mesh). On the <collision>
side the following options are used:
-
<uri>
Inidcates the file containing the NetCDF formated heightmap data. -
<size>
Indicates size of the heightmap.
on the <visual>
side the same plus some extra options are used:
-
<uri>
Inidcates the file containing the NetCDF formated heightmap data. -
<size>
Indicates size of the heightmap. -
<use_terrain_paging>
To tell the rendering engine to use terrain paging, a technique that loads -
<texture>
Allows to indicate the texture that the heightmap will use.
As the comment in the XML indicates, this model only loads the Tile1. Changing the <uri>
to point to other files like meshes/PortugueseLedgeTile2_DecDeg.nc
will load different tile values. To load more tiles just add new <collision>
and <visual>
fields with the new data, remember to give them a different <pose>
so they can show up in the correct position. Here is a heightmap with an associated pose:
<heightmap>
<pos>-750.1514193750727 8.244755512159376 -0.044066349944798855 0 0 0</pos>
<use_terrain_paging>true</use_terrain_paging>
<texture>
<diffuse>https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Portuguese Ledge/tip/files/materials/textures/dirt_diffusespecular.png</diffuse>
<normal>https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Portuguese Ledge/tip/files/materials/textures/flat_normal.png</normal>
<size>10</size>
</texture>
<uri>https://fuel.ignitionrobotics.org/1.0/OpenRobotics/models/Portuguese Ledge/tip/files/meshes/PortugueseLedgeTile2_DecDeg.nc</uri>
<size>1000 1000 27.094</size>
</heightmap>
For more details on the SDF Specification you can find the heightmap tag details here.
When using several tiles, remember to enable levels to improve performance.
When bathymetry data is too large, it is a good idea to create tiles so performance can be improved by using Gazebo features such as levels. The portuguese ledge example in this reposoitory is a good example on several tiles loaded in a big world.
The script directory provides python tools to automatically create tiles in order to add them to a world later on. The make_dem_utm_tiles.py
helps generate tiles from a parent digital elevation map (DEM) using the Generic Mapping Tool (GMT). Because of this prior to the use of the script, it is necessary to install the gmt tool, so please have a look at the installation instructions. Once installed the script can be used with the following options:
-
-p/--dem_path
The path to original DEM file. (required) -
-z/--utm_zone
The DEM utm zone. (required) -
-o/--output_path
Output path for the tile files. (required) -
-s/--tile_size
Tile size in meters. Each tile will have size of tile_size x tile_size. Defaults to 1000. (optional) -
-l/--title_overlap
Tiles will have 'overlap' meters shared with adjacent tiles on each edge. Defaults to 250. (optional)
Once the script is run the tiles will be created in the output path. A csv
with the tile centers will also be created.
Further processing can be done with the utm_tiles_to_decdeg.py
script which converts Universal Transverse Mercator (UTM) northings and eastings coordinates to WGS84 Lat/Lon decimal degree. It accepts the following options:
-
-p/--dem_path
The path to tiles folder. (required) -
-z/--utm_zone
The DEM utm zone. (required)
The new tiles will appear in the tiles folder.