Visual Lightmap - modulabs/gazebo-tutorial GitHub Wiki

Introduction

๋ผ์ดํŠธ ๋งต์€ ์ผ๋ฐ˜์ ์œผ๋กœ ๋ณต์žกํ•œ ์žฅ๋ฉด์˜ ๋ Œ๋”๋ง ์„ฑ๋Šฅ์„ ํ–ฅ์ƒ์‹œํ‚ค๋Š” ๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. ๋ผ์ดํŠธ ๋งต์€ ์กฐ๋ช… ์ •๋ณด๊ฐ€ ํ…์Šค์ฒ˜์— ๋ฏธ๋ฆฌ ๊ตฌ์›Œ์ง„ ํ…์Šค์ฒ˜ ๋งต์œผ๋กœ ์ƒ๊ฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ฒฐ๊ณผ ๋ชจ๋ธ์€ ๋งˆ์น˜ ํ™˜๊ฒฝ์˜ ์กฐ๋ช…์œผ๋กœ ์Œ์˜ ์ฒ˜๋ฆฌ ๋œ ๊ฒƒ์ฒ˜๋Ÿผ ๋ณด์ž…๋‹ˆ๋‹ค. ์กฐ๋ช…์ด ๋ฏธ๋ฆฌ ๊ณ„์‚ฐ๋˜๋ฏ€๋กœ ๋ผ์ดํŠธ ๋งต์€ ์žฅ๋ฉด์˜ ์กฐ๋ช… ํฌ์ฆˆ์™€ ๊ด€๋ จํ•˜์—ฌ ์›€์ง์ด์ง€ ์•Š๋Š” ๋ชจ๋ธ์— ์ ํ•ฉํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ๊ฑด๋ฌผ, ๊ฐ€๊ตฌ,์ง€๋ฉด ๋ฐ ์ง€ํ˜•์ด ๋ฐฉํ–ฅ์„ฑ์„ ์ง€๋‹Œ ํ™˜๊ฒฝ์—์„œ ์ •์  ์ธ ๊ฒฝ์šฐ.

Create a model with lightmap

๋ผ์ดํŠธ ๋งต์€ ๋„๋ฆฌ ์‚ฌ์šฉ๋˜๋Š” 3D ๋ชจ๋ธ๋ง ๋„๊ตฌ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ : ๋ฏน์„œ๊ธฐ. ์ด ํŠœํ† ๋ฆฌ์–ผ์—์„œ๋Š” ๋ฉ”์‰ฌ์™€ ๋ฏธ๋ฆฌ ์ƒ์„ฑ ๋œ ๋ผ์ดํŠธ ๋งต์„ ์ œ๊ณตํ•˜์—ฌ ์‹œ๊ฐ„์„ ์ ˆ์•ฝ ํ•  ๊ฒƒ์ž…๋‹ˆ๋‹ค.

Gazebo์—์„œ๋Š” ๋ผ์ดํŠธ ๋งต์ด ๋ชจํ˜•์˜ ์‹œ๊ฐ์— ์ ์šฉ๋ฉ๋‹ˆ๋‹ค.

Create Table Model

๋จผ์ € ํ…Œ์ด๋ธ” ๋ชจ๋ธ์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค. ๋ชจ๋ธ์€ ์•„์ง ๋ผ์ดํŠธ ๋งต์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

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:

Apply Lightmap

์ด์ „์—์ฃผ์˜๋ฅผ ๊ธฐ์šธ ์˜€๋‹ค๋ฉด ์•„์ง 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:

โš ๏ธ **GitHub.com Fallback** โš ๏ธ