Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added DEM support #1262

Merged
merged 6 commits into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
145 changes: 145 additions & 0 deletions examples/worlds/dem_monterey_bay.sdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
<?xml version="1.0" ?>
<!--

Demonstrates a Digital Elevation Model (DEM) heightmap of Monterey Bay bathymetry
downloaded from GEBCO (General Bathymetric Chart of the Oceans) 2021 https://www.gebco.net/

-->
<sdf version="1.9">
<world name="dem_monterey_bay">
<physics name="1ms" type="ignored">
<dart>
<!-- Heightmaps behave better with the bullet collision detector -->
<collision_detector>bullet</collision_detector>
</dart>
</physics>

<gui fullscreen="0">
<plugin filename="MinimalScene" name="3D View">
<ignition-gui>
<title>3D View</title>
<property type="bool" key="showTitleBar">false</property>
<property type="string" key="state">docked</property>
</ignition-gui>

<engine>ogre</engine>
<scene>scene</scene>
<ambient_light>0 0 0</ambient_light>
<background_color>0.8 0.8 0.8</background_color>
<camera_pose>-91.402603 7.516849 114.206924 0 0.889399 -0.016090</camera_pose>
</plugin>

<!-- Plugins that add functionality to the scene -->
<plugin filename="EntityContextMenuPlugin" name="Entity context menu">
<ignition-gui>
<property key="state" type="string">floating</property>
<property key="width" type="double">5</property>
<property key="height" type="double">5</property>
<property key="showTitleBar" type="bool">false</property>
</ignition-gui>
</plugin>
<plugin filename="GzSceneManager" name="Scene Manager">
<ignition-gui>
<property key="resizable" type="bool">false</property>
<property key="width" type="double">5</property>
<property key="height" type="double">5</property>
<property key="state" type="string">floating</property>
<property key="showTitleBar" type="bool">false</property>
</ignition-gui>
</plugin>
<plugin filename="InteractiveViewControl" name="Interactive view control">
<ignition-gui>
<property key="resizable" type="bool">false</property>
<property key="width" type="double">5</property>
<property key="height" type="double">5</property>
<property key="state" type="string">floating</property>
<property key="showTitleBar" type="bool">false</property>
</ignition-gui>
</plugin>
<plugin filename="CameraTracking" name="Camera Tracking">
<ignition-gui>
<property key="resizable" type="bool">false</property>
<property key="width" type="double">5</property>
<property key="height" type="double">5</property>
<property key="state" type="string">floating</property>
<property key="showTitleBar" type="bool">false</property>
</ignition-gui>
</plugin>
<plugin filename="WorldControl" name="World control">
<ignition-gui>
<title>World control</title>
<property type="bool" key="showTitleBar">false</property>
<property type="bool" key="resizable">false</property>
<property type="double" key="height">72</property>
<property type="double" key="width">121</property>
<property type="double" key="z">1</property>

<property type="string" key="state">floating</property>
<anchors target="3D View">
<line own="left" target="left"/>
<line own="bottom" target="bottom"/>
</anchors>
</ignition-gui>

<play_pause>true</play_pause>
<step>true</step>
<start_paused>true</start_paused>
<use_event>true</use_event>
</plugin>

<plugin filename="WorldStats" name="World stats">
<ignition-gui>
<title>World stats</title>
<property type="bool" key="showTitleBar">false</property>
<property type="bool" key="resizable">false</property>
<property type="double" key="height">110</property>
<property type="double" key="width">290</property>
<property type="double" key="z">1</property>

<property type="string" key="state">floating</property>
<anchors target="3D View">
<line own="right" target="right"/>
<line own="bottom" target="bottom"/>
</anchors>
</ignition-gui>

<sim_time>true</sim_time>
<real_time>true</real_time>
<real_time_factor>true</real_time_factor>
<iterations>true</iterations>
</plugin>

<plugin filename="ComponentInspector" name="Component inspector">
<ignition-gui>
<property type="string" key="state">docked</property>
</ignition-gui>
</plugin>

<plugin filename="EntityTree" name="Entity tree">
<ignition-gui>
<property type="string" key="state">docked</property>
</ignition-gui>
</plugin>
</gui>

<light type="directional" name="sun">
<cast_shadows>true</cast_shadows>
<pose>0 0 10 0 0 0</pose>
<diffuse>0.8 0.8 0.8 1</diffuse>
<specular>0.2 0.2 0.2 1</specular>
<attenuation>
<range>1000</range>
<constant>0.9</constant>
<linear>0.01</linear>
<quadratic>0.001</quadratic>
</attenuation>
<direction>-0.5 0.1 -0.9</direction>
</light>

<include>
<uri>
https://fuel.ignitionrobotics.org/1.0/jennuine/models/Monterey Bay
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any tips on how I would generate my own terrain DEM model? I don't see any docs added for the PR.

Copy link
Contributor Author

@jennuine jennuine Feb 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, the only tutorial available is from gazebo-classic found here: https://classic.gazebosim.org/tutorials?tut=dem&cat=build_world

It is outdated but will hopefully get you in the right direction. If you'd like to contribute, feel free to open a PR for a newer tutorial on DEMs here: https://github.com/gazebosim/docs 😄

</uri>
</include>
</world>
</sdf>
181 changes: 181 additions & 0 deletions examples/worlds/dem_volcano.sdf
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
<?xml version="1.0" ?>
<!--

Demonstrates a Digital Elevation Model (DEM) heightmap of Mount St. Helens volcano

-->
<sdf version="1.9">
<world name="dem_heightmap">
<physics name="1ms" type="ignored">
<dart>
<collision_detector>bullet</collision_detector>
</dart>
</physics>

<gui fullscreen="0">
<plugin filename="MinimalScene" name="3D View">
<ignition-gui>
<title>3D View</title>
<property type="bool" key="showTitleBar">false</property>
<property type="string" key="state">docked</property>
</ignition-gui>

<engine>ogre</engine>
<scene>scene</scene>
<ambient_light>0 0 0</ambient_light>
<background_color>0.8 0.8 0.8</background_color>
<camera_pose>-37.575569 82.272293 95.114960 0 0.566000 -0.981496</camera_pose>
</plugin>

<!-- Plugins that add functionality to the scene -->
<plugin filename="EntityContextMenuPlugin" name="Entity context menu">
<ignition-gui>
<property key="state" type="string">floating</property>
<property key="width" type="double">5</property>
<property key="height" type="double">5</property>
<property key="showTitleBar" type="bool">false</property>
</ignition-gui>
</plugin>
<plugin filename="GzSceneManager" name="Scene Manager">
<ignition-gui>
<property key="resizable" type="bool">false</property>
<property key="width" type="double">5</property>
<property key="height" type="double">5</property>
<property key="state" type="string">floating</property>
<property key="showTitleBar" type="bool">false</property>
</ignition-gui>
</plugin>
<plugin filename="InteractiveViewControl" name="Interactive view control">
<ignition-gui>
<property key="resizable" type="bool">false</property>
<property key="width" type="double">5</property>
<property key="height" type="double">5</property>
<property key="state" type="string">floating</property>
<property key="showTitleBar" type="bool">false</property>
</ignition-gui>
</plugin>
<plugin filename="CameraTracking" name="Camera Tracking">
<ignition-gui>
<property key="resizable" type="bool">false</property>
<property key="width" type="double">5</property>
<property key="height" type="double">5</property>
<property key="state" type="string">floating</property>
<property key="showTitleBar" type="bool">false</property>
</ignition-gui>
</plugin>
<plugin filename="WorldControl" name="World control">
<ignition-gui>
<title>World control</title>
<property type="bool" key="showTitleBar">false</property>
<property type="bool" key="resizable">false</property>
<property type="double" key="height">72</property>
<property type="double" key="width">121</property>
<property type="double" key="z">1</property>

<property type="string" key="state">floating</property>
<anchors target="3D View">
<line own="left" target="left"/>
<line own="bottom" target="bottom"/>
</anchors>
</ignition-gui>

<play_pause>true</play_pause>
<step>true</step>
<start_paused>true</start_paused>
<use_event>true</use_event>

</plugin>

<plugin filename="WorldStats" name="World stats">
<ignition-gui>
<title>World stats</title>
<property type="bool" key="showTitleBar">false</property>
<property type="bool" key="resizable">false</property>
<property type="double" key="height">110</property>
<property type="double" key="width">290</property>
<property type="double" key="z">1</property>

<property type="string" key="state">floating</property>
<anchors target="3D View">
<line own="right" target="right"/>
<line own="bottom" target="bottom"/>
</anchors>
</ignition-gui>

<sim_time>true</sim_time>
<real_time>true</real_time>
<real_time_factor>true</real_time_factor>
<iterations>true</iterations>
</plugin>

<plugin filename="ComponentInspector" name="Component inspector">
<ignition-gui>
<property type="string" key="state">docked</property>
</ignition-gui>
</plugin>

<plugin filename="EntityTree" name="Entity tree">
<ignition-gui>
<property type="string" key="state">docked</property>
</ignition-gui>
</plugin>
</gui>

<light type="directional" name="sun">
<cast_shadows>true</cast_shadows>
<pose>0 0 10 0 0 0</pose>
<diffuse>0.8 0.8 0.8 1</diffuse>
<specular>0.2 0.2 0.2 1</specular>
<attenuation>
<range>1000</range>
<constant>0.9</constant>
<linear>0.01</linear>
<quadratic>0.001</quadratic>
</attenuation>
<direction>-0.5 0.1 -0.9</direction>
</light>

<model name="sphere">
<pose>0 15 70 0 0 0</pose>
<link name="sphere_link">
<inertial>
<inertia>
<ixx>0.1</ixx>
<ixy>0</ixy>
<ixz>0</ixz>
<iyy>0.1</iyy>
<iyz>0</iyz>
<izz>0.1</izz>
</inertia>
<mass>1.0</mass>
</inertial>
<collision name="sphere_collision">
<geometry>
<sphere>
<radius>2</radius>
</sphere>
</geometry>
</collision>

<visual name="sphere_visual">
<geometry>
<sphere>
<radius>2</radius>
</sphere>
</geometry>
<material>
<ambient>0 0 1 1</ambient>
<diffuse>0 0 1 1</diffuse>
<specular>0 0 1 1</specular>
</material>
</visual>
</link>
</model>

<include>
<uri>
https://fuel.ignitionrobotics.org/1.0/jennuine/models/Volcano
</uri>
</include>
</world>
</sdf>
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@
#include <vector>

#include <ignition/common/Console.hh>
#include <ignition/common/HeightmapData.hh>
#include <ignition/common/ImageHeightmap.hh>
#include <ignition/common/geospatial/Dem.hh>
#include <ignition/common/geospatial/HeightmapData.hh>
#include <ignition/common/geospatial/ImageHeightmap.hh>
#include <ignition/common/MeshManager.hh>
#include <ignition/common/Profiler.hh>
#include <ignition/common/StringUtils.hh>

#include <ignition/gui/Application.hh>
#include <ignition/gui/GuiEvents.hh>
Expand Down Expand Up @@ -1253,12 +1255,33 @@ rendering::GeometryPtr VisualizationCapabilitiesPrivate::CreateGeometry(
return geom;
}

auto data = std::make_shared<common::ImageHeightmap>();
if (data->Load(fullPath) < 0)
std::shared_ptr<common::HeightmapData> data;
std::string lowerFullPath = common::lowercase(fullPath);
// check if heightmap is an image
if (common::EndsWith(lowerFullPath, ".png")
|| common::EndsWith(lowerFullPath, ".jpg")
|| common::EndsWith(lowerFullPath, ".jpeg"))
{
ignerr << "Failed to load heightmap image data from [" << fullPath << "]"
<< std::endl;
return geom;
auto img = std::make_shared<common::ImageHeightmap>();
if (img->Load(fullPath) < 0)
{
ignerr << "Failed to load heightmap image data from ["
<< fullPath << "]" << std::endl;
return geom;
}
data = img;
}
// DEM
else
{
auto dem = std::make_shared<common::Dem>();
if (dem->Load(fullPath) < 0)
{
ignerr << "Failed to load heightmap dem data from ["
<< fullPath << "]" << std::endl;
return geom;
}
data = dem;
}

rendering::HeightmapDescriptor descriptor;
Expand Down
Loading