Digital Elevation Models - modulabs/gazebo-tutorial GitHub Wiki
๋์งํธ ๊ณ ๋ ๋ชจ๋ธ(DEM)์ ์งํํ๋ฉด์ ๋ํ 3D ํํ์ ๋๋ค. ์ด ์งํํ๋ฉด์ ๋น๋ฉ์ด๋ ์ด๋ชฉ๋ค์ด ์๋์ํ์ ๋๋ค. DEMS๋ ๋ผ์ด๋ค,๋ ์ด๋,์นด๋ฉ๋ผ๊ฐ์ ์ผ์๋ฅผ ์ฌ์ฉํด์ ๋ง๋ค์ด์ง๋๋ค. ์งํ๊ณ ๋๋ ๊ฐ์ ๊ณ ๋๋ฅผ ์ด์ ์ ์ผ๋ก ์ํ๋ง ๋ฉ๋๋ค. Wikipedia๋ DEMS์ ๊ด๋ จํ ๋ ์์ธํ๊ฒ๋ค์ ์ป๊ธฐ์ํ ์์ค์ ๋๋ค. The term DEM is just a generic denomination, not a specific format. In fact, the DEMs can be represented as a grid of elevations (raster) or as a vector-based triangular irregular network (TIN). Currently, Gazebo only supports raster data in the supported formats available in GDAL.
DEMS๋ฅผ ๊ฐ์ ๋ณด์์ ์ฌ์ฉํ๊ฒ๋ ๋๊ธฐ๋ ์ค์ ์ ์งํ์์ ์๋ฌผ๋ ์ด์ ์ ํ ์์๋ค๋ ์ ์ด๋ค. ๊ตฌ์กฐ๋ ๋์ ์ ์์ด์, ๊ทธ๋ค์ ๋ก๋ด์ด ์ค๋ค์ ์งํ์์ ํ ์คํ ๋๋๊ฒ์ ๊ด์ฌ์ด ์์๊ฒ ์ ๋๋ค.
DEM ํ์ผ์ ์ฌ์ฉํ๊ธฐ ์ํด์๋ GDAL ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ค์นํด์ผ ํฉ๋๋ค.
$ sudo apt-get install gdal-bin libgdal-dev python-gdal
๊ณ ๋๋ฐ์ดํฐ๋ฅผ ์ ๊ณตํ๋ ๊ธฐ๊ด์ ๋ง์ด ์์ต๋๋ค. ์๋ฅผ๋ค์ด, Mount St.helens (80๋ ๋ ํ์ฐํญ๋ฐ ์ ํ)DEM ํ์ผ์ ๋ค์ด๋ก๋ ๋ฐ์ผ์ธ์ ์ด ํ์ผ๋ค์ ๊ณต๊ฐ๋ ๋๋ฉ์ธ์ด๊ณ ,USGS์์ ๋ฐฐํฌํฉ๋๋ค.
์์ถ์ ํธ์๊ณ ์ด๋ฆ์ "mtsthelens.dem" ๋ก ํ์ธ์~
$ cd ~/Downloads
$ wget https://bitbucket.org/osrf/gazebo_tutorials/raw/default/dem/files/mtsthelens_before.zip
$ unzip ~/Downloads/mtsthelens_before.zip -d /tmp
$ mv /tmp/30.1.1.1282760.dem /tmp/mtsthelens.dem
๋ณดํต, DEM ํ์ผ์ ํฐ ํด์๋๋ฅผ ๊ฐ๊ณ ์์ต๋๋ค. ๊ทธ๋์ ๊ฐ์ ๋ณด๋ก ๋ค๋ฃฐ์ ์์ต๋๋ค. ๊ทธ๋์ DEํ์ผ์ ํด์๋๋ฅผ ์ต์ ํ ํ๊ธฐ์ํ ์ข์ ๋ฐฉ๋ฒ์ด ์์ต๋๋ค. ๋ค์ ๋ช ๋ น์ด๋ ์งํ๋๋ฅผ 129*129๋ก ์ค์ผ์ผ๋ง ํฉ๋๋ค ๋ํ media/dem ๋๋ ํ ๋ฆฌ๋ก ๋ณต์ฌ๋ฅผ ํฉ๋๋ค.
$ mkdir -p /tmp/media/dem/
$ gdalwarp -ts 129 129 /tmp/mtsthelens.dem /tmp/media/dem/mtsthelens_129.dem
๊ฐ์ ๋ณด์์์ DEM ํ์ผ์ Heightmap image๋ฅผ ๋ก๋ํ๋ ๋ฐฉ๋ฒ๊ณผ ๊ฐ์ ๋ฐฉ๋ฒ์ผ๋ก ๋ก๋ ๋ฉ๋๋ค. ๊ฐ์ ๋ณด๋ ์ด ํ์ผ์ด ํ๋ฉด ์ด๋ฏธ์ง ๋๋ DEM ํ์ผ์์ ์๋์ผ๋ก ๊ฐ์งํฉ๋๋ค. volcano.world ํ์ผ์ ์์ฑํฉ๋๋ค. ๊ทธ๋ฆฌ๊ณ ๋ค์ ์ฝํ ์ธ ๋ก ๋ณต์ฌํฉ๋๋ค. ๋น์ ์ด ์ํ๋ ๊ณณ์ผ๋ก ํ์ผ์ ์ ์ฅํฉ๋๋ค.
<?xml version="1.0" ?>
<sdf version="1.4">
<world name="default">
<!-- A global light source -->
<include>
<uri>model://sun</uri>
</include>
<model name="heightmap">
<static>true</static>
<link name="link">
<collision name="collision">
<geometry>
<heightmap>
<uri>file://media/dem/mtsthelens_129.dem</uri>
<size>150 150 50</size>
<pos>0 0 -685</pos>
</heightmap>
</geometry>
</collision>
<visual name="visual_abcedf">
<geometry>
<heightmap>
<texture>
<diffuse>file://media/materials/textures/dirt_diffusespecular.png</diffuse>
<normal>file://media/materials/textures/flat_normal.png</normal>
<size>1</size>
</texture>
<texture>
<diffuse>file://media/materials/textures/grass_diffusespecular.png</diffuse>
<normal>file://media/materials/textures/flat_normal.png</normal>
<size>1</size>
</texture>
<texture>
<diffuse>file://media/materials/textures/fungus_diffusespecular.png</diffuse>
<normal>file://media/materials/textures/flat_normal.png</normal>
<size>1</size>
</texture>
<blend>
<min_height>2</min_height>
<fade_dist>5</fade_dist>
</blend>
<blend>
<min_height>4</min_height>
<fade_dist>5</fade_dist>
</blend>
<uri>file://media/dem/mtsthelens_129.dem</uri>
<size>150 150 50</size>
<pos>0 0 -685</pos>
</heightmap>
</geometry>
</visual>
</link>
</model>
</world>
</sdf>
The element in the code above tells Gazebo whether to load the DEM with the original dimensions (when is not present) or to scale it (when is present). In case you prefer to scale the DEM, the element tells Gazebo the size in meters that the terrain will have in the simulation. If you want to maintain the correct aspect ratio, be sure to properly calculate its size in all three dimensions. In our example, the DEM will be scaled to a square of 150 x 150 meters and a height of 50 meters. The minimum elevation for this particular DEM file is 685 meters, so in the element, we translate the entire DEM in negative z direction so that it sits at z=0 in the world.
ekdtlsdml DEMํ์ผ์ ํฌํจํ WORLD๋ฅผ ๋ฐ์นญํ์ธ์ ๋น์ ์ VOLCANO๋ฅผ ๋ณผ์์์ด์ผ ํฉ๋๋ค. ์ฐ๋ฆฌ์ ๊ฒฝ์ฐ์๋ ์ด ํ์ผ์ /tmp ๋๋ ํ ๋ฆฌ์ ์์ต๋๋ค.
# Be sure of sourcing gazebo setup.sh in your own installation path
$ source /usr/share/gazebo/setup.sh
$ GAZEBO_RESOURCE_PATH="$GAZEBO_RESOURCE_PATH:/tmp" gazebo /tmp/volcano.world
ํ์ฐํญ๋ฐ ์ดํ์ DEM ํ์ผ๋ ๋์ผํ ๋ฐฉ๋ฒ์ผ๋ก ๋ก๋ ํด ๋ณด์ธ์ ๋น์ ์ ์๋๊ทธ๋ฆผ๊ณผ ๊ฐ์ heightmap์ ๊ฐ์ ๋ณด ์์์ ์ป์์ ์์ด์ผ ํฉ๋๋ค.
๋ค์,์ฐ๋ฆฌ๋ ํน์ ์ง์ญ์ DEM ํ์ผ์ ์ป๋ ํ๊ฐ์ง ๋ฐฉ๋ฒ์ ๋ํด ๊ธฐ์ ์ ํ ๊ฒ์ ๋๋ค.
Global Land Cover Facility ๋ ๋์ ํด์๋์ ๋์งํธ ์ฌ์ง๊ทธ๋ํฝ ๋ฐ์ดํฐ ๋ฒ ์ด์ค(์ง๊ตฌ)๋ฅผ ์ ์ง๊ด๋ฆฌํ๊ณ ์์ต๋๋ค. ๊ทธ๊ฒ์ "Search and Preview tool"๋ก ๊ฐ์ธ์, ๋น์ ์ ์๋์ ๋น์ทํ ์ด๋ฏธ์ง๋ฅผ ๋ณด๊ฒ๋ ๊ฒ์ ๋๋ค. ๋ชจ๋ ์งํPATH๋ ํด์ ์ด์ฉํ๊ธฐ ์ ์ ์๊ณ ์์ด์ผํ ์ ์ผํ ๊ณ ์ ์ PATH์ ROW๋ฅผ ๊ฐ์ต๋๋ค ์ฐ๋ฆฌ๋ ๊ด์ฌ์ง์ญ์ PATH,ROW๋ฅผ ์๊ธฐ์ํด์ QGIS๋ฅผ ์ฌ์ฉํฉ๋๋ค.
QGIS๋ ๊ต์ฐจํ๋ซํผ ์คํ์์ค ์ง๋ฆฌํ ์ ๋ณด ์์คํ ํ๋ก๊ทธ๋จ ์ ๋๋ค(๋ฐ์ดํ๋ฅผ ๋ณด๊ณ , ํธ์งํ๊ณ ,ํด์) QGIS๋ฅผ ๋ค์์ instructions detailed on the QGIS website .๋ฅผ ๋ฐ๋ผํด์ ๋ค์ด์ ๋ฐ์ผ์ธ์
QGIS๋ฅผ ์ด๊ณ , ์ข์ธก ์นผ๋ผ ์์ด์ฝ "WMS/WMTS layer"๋ฅผ ํด๋ฆญํ์ธ์ default servers ๋ฅผ ํด๋ฆญํ์ธ์ Lizardtech server๋ฅผ ์ ํํ์ธ์ ๊ทธ๋ฆฌ๊ณ CONNECT๋ฅผ ๋๋ฅด์ธ์ ๊ทธ๋ฆฌ๊ณ MODIS๋ฅผ ์ ํํ๊ณ ADD๋ฅผ ๋๋ฅด์ธ์ ํ์ ์๋์ฐ๋ฅผ ๋ซ์ต๋๋ค. ๋ค์ ์คํ ์ ๋ค๋ฅธ ๊ฐ๋ฅํ PATH ๋ก ๋ค๋ฅธ LAYER๋ฅผ ์ถ๊ฐํ์ธ์ this shapefile ๋ฅผ ๋ค์ด๋ก๋ ํ๊ณ , ์์ถ์ ํธ์ธ์ QGIS๋ก ๋๋์๊ฐ์ Add Vector Layer ๋ฅผ ๋๋ฅด์ธ์ Browse๋ฅผ ํด๋ฆญํ๊ณ , ๋น์ ์ ์์ ์์ถํผ wrs2descending.shp file. ์ ์ ํํ์ธ์ ์๋์ฐ์์ ์คํ์ ๋๋ฆ ๋๋ค ์ด์ ๋น์ ์ MAIN WINDOWDP E๋ LAYER๋ฅผ ๋ณด๊ฒ๋ ๊ฒ์ ๋๋ค. wrs2descending layer์ ํฌ๋ช ๋๋ฅผ ๋ณ๊ฒฝํ์ธ์(๋ LAYER๋ฅผ ๋์์ ๋ณผ์์๋๋ก) on wrs2_descending layer,๋ฅผ ๋๋ธํด๋ฆญํ์ธ์ ๊ทธ๋ฆฌ๊ณ ๊ทธ๊ฒ์ ํฌ๋ช ๋๋ฅผ ์์ ํ์ธ์(์ฝ 85%)
์คํฌ๋กค, ์ข์ธก ๋ฒํผ์ ์ด์ฉํด์ ๊ด์ฌ์ง์ญ์ผ๋ก ์ด๋์ด ๊ฐ๋ฅํฉ๋๋ค. ์๋จ BAR์ the icon labeled Identify Features๋ฅผ ํด๋ฆญํฉ๋๋ค. ๋น์ ์ ๊ด์ฌ์ง์ญ์ ํด๋ฆญํ๊ณ , ๊ทธ์ง์ญ์ ๋ชจ๋ ์งํํจ์น๊ฐ ํ์ผ๋ผ์ดํธ ๋ฉ๋๋ค. ์๋ก์ด ํ์ ์๋์ฐ๊ฐ ํ์ด๋ผ์ดํธ๋ ํจ์น๋ง๋ค PATH/ROW๋ฅผ ๋ณด์ฌ์ค๋๋ค. ๋น์ ์ด PATH,ROW(DEM PATCH:LAS Palmas๋ฅผ ํฌํจํ)๋ฅผ ๋ณผ์์์์ต๋๋ค
GLCF ์์นํด์ ๊ฐ์ง ๋น์ ์ ๋ธ๋ก์ฐ์ ธ๋ก ๋๋์ ๊ฐ์ธ์ ๊ทธ๋ฆฌ๊ณ PATH/ROW๋ฅผ ๋ฐธ๋ฅ๋ฅผ Start Path and Start Row์ ์ ๋ ฅํ์ธ์ ๊ทธ๋ค์ Submit Query๋ฅผ ๋๋ฅด์ธ์ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๊ธฐ์ํด Preview and Download๋ฅผ ๋๋ฅด์ธ์ ๋น์ ์ ์ง์ญ์ ํ์ผ์ ์ ํํ๊ณ ๋ค์ด๋ก๋๋ฅผ ๋๋ฅด์ธ์ ๋ง์ง๋ง์ผ๋ก ๋น์ ์ ํ์ผ( .GZ)๋ฅผ ์ ํํ๊ณ , ๊ทธ๊ฒ์ ์ข์ํ๋ ํด๋์ ์์ถ์ ํ์ด๋์ต๋๋ค. Global Land Cover Facility files ์ GeoTiff format, ์ ๋๋ค. ๊ฐ์ฅ ์ผ๋ฐ์ ์ธ DEMํ์ผ FORMAT ์ ๋๋ค
DEM data๋ ๋ณดํต ๋งค์ฐ๋์ ํด์๋๋ฅผ ๊ฐ์ต๋๋ค. ๊ฐ์ ๋ณด์์ ์ฌ์ฉํ ์์์์ ๋์ ์์ค์ผ๋ก ํด์๋๋ฅผ ์ค์ด๊ธฐ ์ํด gdalwarp๋ฅผ ์ฌ์ฉํฉ๋๋ค.
$ gdalwarp -ts <width> <height> <srcDEM> <targetDEM>
DEM DATA๋ ์ข ์ข "holes" or "void" ์ง์ญ์ ํฌํจํฉ๋๋ค. ์ด ์น์ ์ DEMํ์ผ ์์ฑ์ค์ ๋ฐ์ดํ๊ฐ ์์ง๋์ง ์์ ์ง์ญ๊ณผ ์ฐ๊ด์ด ์์ต๋๋ค. HOLE CASE์ ๊ฒฝ์ฐ์, THE HOLE์ DEM์์ ์ฌ์ฉ๋๋ ๋ฐ์ดํ ํ์ ์ค์์ ์ต๋ ๋๋ ์ต์์์น์ ํด๋น์ด ๋ฉ๋๋ค.
ํญ์ DEMํ์ผ ์ต์ข ๋ฒ์ ์ ๋ค์ด ๋ฐ์ผ์ธ์ HOLES๋ค์ ์ฑ์์ง๋๋ค. ์์์ ์ผ๋ก ์์ ๋ ์๋ํ์ธ์ ,gdal tools ,gdal_fillnodata.py. ๋ฅผ ์ด์ฉํฉ๋๋ค.
๊ฐ์ ๋ณด๊ฐ์ ์ง์ ์ ์ผ๋ก DEM์ ์ง์ํ์ง๋ ์์น๋ง, GDAL์ DEMS ์ ์ ํ๋๋ก ํฉ์น๊ธฐ ์ํ ์ ํธ๋ฆฌํฐ ์ ์ ๊ฐ์ง๊ณ ์์ต๋๋ค. ์ฒซ๋ฒ์งธ๋ก ํฉ์น๊ธฐ๋ฅผ ์ํ๋ DEMS ์ ์ ๋ค์ด๋ก๋ ํฉ๋๋ค. ํจ์น๋ ๋ค๋ฅธ๊ฒ์ ์ค๋ฒ๋ฉ ๋์ด์์ต๋๋ค,GDAL์ ๊ทธ๋ค์ ๊ท ์ผํ๊ฒ ํฉ์น ๊ฒ์ ๋๋ค. ๋น์ ์ ํ์ฌ ๋๋ ํ ๋ฆฌ๊ฐ ํฉ์ณ์ง ์ค๋น๊ฐ ๋ Geotiff files๋ฅผ ํฌํจํ๊ณ ์๋ค๋ฉด, ๋ค์ ๋ช ๋ น์ด๋ฅผ ์ํํ์ธ์
$ gdal_merge.py *.tif -o dem_merged.tif
์ด์ ๋น์ ์ dem_merged.tif๋ฅผ ๋น์ ์ WORLD FILE์์์ ์ฌ์ฉํ ์์์ต๋๋ค. ๊ฐ์ ๋ณด๋ ์์ญ์ ๋ชจ๋ ํฉ์ณ์ง ํจ์น์ ํจ๊ป ๋ก๋ํ ๊ฒ์ ๋๋ค.
๋ค์ ์คํฌ๋ฆฐ์ฟ์์ ๋น์ ์ 4๊ฐ์ง ์ง์ญ์ด ํฉ์ณ์ง ๊ฒฐ๊ณผ๋ฅผ ๋ณผ์๊ฐ ์์ต๋๋ค.




