Visual Lightmap - modulabs/gazebo-tutorial GitHub Wiki
๋ผ์ดํธ ๋งต์ ์ผ๋ฐ์ ์ผ๋ก ๋ณต์กํ ์ฅ๋ฉด์ ๋ ๋๋ง ์ฑ๋ฅ์ ํฅ์์ํค๋ ๋ฐ ์ฌ์ฉ๋ฉ๋๋ค. ๋ผ์ดํธ ๋งต์ ์กฐ๋ช ์ ๋ณด๊ฐ ํ ์ค์ฒ์ ๋ฏธ๋ฆฌ ๊ตฌ์์ง ํ ์ค์ฒ ๋งต์ผ๋ก ์๊ฐํ ์ ์์ต๋๋ค. ๊ฒฐ๊ณผ ๋ชจ๋ธ์ ๋ง์น ํ๊ฒฝ์ ์กฐ๋ช ์ผ๋ก ์์ ์ฒ๋ฆฌ ๋ ๊ฒ์ฒ๋ผ ๋ณด์ ๋๋ค. ์กฐ๋ช ์ด ๋ฏธ๋ฆฌ ๊ณ์ฐ๋๋ฏ๋ก ๋ผ์ดํธ ๋งต์ ์ฅ๋ฉด์ ์กฐ๋ช ํฌ์ฆ์ ๊ด๋ จํ์ฌ ์์ง์ด์ง ์๋ ๋ชจ๋ธ์ ์ ํฉํฉ๋๋ค. ์๋ฅผ ๋ค์ด, ๊ฑด๋ฌผ, ๊ฐ๊ตฌ,์ง๋ฉด ๋ฐ ์งํ์ด ๋ฐฉํฅ์ฑ์ ์ง๋ ํ๊ฒฝ์์ ์ ์ ์ธ ๊ฒฝ์ฐ.
๋ผ์ดํธ ๋งต์ ๋๋ฆฌ ์ฌ์ฉ๋๋ 3D ๋ชจ๋ธ๋ง ๋๊ตฌ๋ฅผ ์ฌ์ฉํ์ฌ ๋ง๋ค ์ ์์ต๋๋ค. ์ : ๋ฏน์๊ธฐ. ์ด ํํ ๋ฆฌ์ผ์์๋ ๋ฉ์ฌ์ ๋ฏธ๋ฆฌ ์์ฑ ๋ ๋ผ์ดํธ ๋งต์ ์ ๊ณตํ์ฌ ์๊ฐ์ ์ ์ฝ ํ ๊ฒ์ ๋๋ค.
Gazebo์์๋ ๋ผ์ดํธ ๋งต์ด ๋ชจํ์ ์๊ฐ์ ์ ์ฉ๋ฉ๋๋ค.
๋จผ์ ํ ์ด๋ธ ๋ชจ๋ธ์ ๋ง๋ญ๋๋ค. ๋ชจ๋ธ์ ์์ง ๋ผ์ดํธ ๋งต์ ์ฌ์ฉํ์ง ์์ต๋๋ค.
mkdir -p ~/.gazebo/models/my_lightmap_table
Download the mesh and texture files.
mkdir -p ~/.gazebo/models/my_lightmap_table/meshes
cd ~/.gazebo/models/my_lightmap_table/meshes
wget http://gazebosim.org/models/table_marble/meshes/table_lightmap.dae
mkdir -p ~/.gazebo/models/my_lightmap_table/materials/scripts
mkdir -p ~/.gazebo/models/my_lightmap_table/materials/textures
cd ~/.gazebo/models/my_lightmap_table/materials/textures
wget http://gazebosim.org/models/table_marble/materials/textures/marble.png
wget http://gazebosim.org/models/table_marble/materials/textures/table_lightmap.png
Create a material script that will be used by the table model:
gedit ~/.gazebo/models/my_lightmap_table/materials/scripts/table_lightmap.material
Paste the following contents:
material Table/Marble_Lightmap
{
technique
{
pass
{
texture_unit
{
texture marble.png
}
}
}
}
Create a model.config file:
gedit ~/.gazebo/models/my_lightmap_table/model.config
Paste the following contents:
<?xml version="1.0"?>
<model>
<name>Lightmap Table</name>
<version>1.0</version>
<sdf version="1.5">model.sdf</sdf>
<author>
<name>Joe</name>
<email>[email protected]</email>
</author>
<description>
A table with lightmap.
</description>
</model>
Create a model.sdf file
gedit ~/.gazebo/models/my_lightmap_table/model.sdf
Paste the following:
<?xml version="1.0" ?>
<sdf version="1.5">
<model name="my_lightmap_table">
<static>true</static>
<pose>0 0 0.648 0 0 0</pose>
<link name="link">
<collision name="collision">
<geometry>
<mesh>
<uri>model:///my_lightmap_table/meshes/table_lightmap.dae</uri>
<scale>0.25 0.25 0.25</scale>
</mesh>
</geometry>
</collision>
<visual name="visual">
<geometry>
<mesh>
<uri>model://my_lightmap_table/meshes/table_lightmap.dae</uri>
<scale>0.25 0.25 0.25</scale>
</mesh>
</geometry>
<material>
<script>
<uri>model://my_lightmap_table/materials/scripts</uri>
<uri>model://my_lightmap_table/materials/textures</uri>
<name>Table/Marble_Lightmap</name>
</script>
</material>
</visual>
</link>
</model>
</sdf>
Run gazebo:
gazebo
Insert the Lightmap Table model into the scene:
์ด์ ์์ฃผ์๋ฅผ ๊ธฐ์ธ ์๋ค๋ฉด ์์ง table_lightmap.png๋ฅผ ์ฌ์ฉํ์ง ์์๋ค๋ ๊ฒ์ ์ ์ ์์ต๋๋ค. ์ ์ฉ ํ ๋ผ์ดํธ ๋งต์ ๋๋ค. ๊ทธ๋ฌ๋ ๋จผ์ , Gazebo์๊ฒ lightmaps๋ฅผ ์ฌ์ฉํ๊ธฐ๋ฅผ ์ํ๊ธฐ ๋๋ฌธ์ ๋ค์ด๋ด๋ฏน ๋ผ์ดํ ์ ๋ชจ๋ธ์ ์ ์ฉํด์๋ ์๋๋ค๊ณ ์ค๋ช ํด์ผํฉ๋๋ค.
Edit the model.sdf file:
gedit ~/.gazebo/models/my_lightmap_table/model.sdf
Locate the material SDF element in the model.sdf and set lighting to be false
<material>
<script>
<uri>model://my_lightmap_table/materials/scripts</uri>
<uri>model://my_lightmap_table/materials/textures</uri>
<name>Table/Marble_Lightmap</name>
</script>
<lighting>false</lighting>
</material>
If you insert my_lightmap_table into the scene again, you should notice that the model now only has a texture but is no longer shaded.
Then tell the material script to blend the lightmap with the existing texture.
gedit ~/.gazebo/models/my_lightmap_table/materials/scripts/table_lightmap.material
Add a texture_unit that uses the table_lightmap.png texture
material Table/Marble_Lightmap
{
technique
{
pass
{
texture_unit
{
texture marble.png
}
texture_unit
{
texture table_lightmap.png
}
}
}
}
Finally, relaunch Gazebo and insert the table model: