Elevators & Occupied Event - modulabs/gazebo-tutorial GitHub Wiki
์ด ํ์ด์ง์์๋ ๊ฐ์ ๋ณด์์ ์๋ ๋ฒ ์ดํฐ๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ ์๋ ค์ค๋ค. ๊ฐ์ ์๋ ๋ฒ ์ดํฐ๋ ๋ฌธ์ด ๋ฌ๋ฆฐ ์นธ์ผ๋ก ์์๋๋ก ์์ง์ผ ์ ์์ผ๋ฉฐ prismatic joint๋ก ์ ์ด๋๋ค.
์๋ ๋ฒ ์ดํฐ์ ๋์์ ElevatorPlugin์ ํตํด ์ด๋ฃจ์ด์ง๋ค. ์ด ํ๋ฌ๊ทธ์ธ์ 2๊ฐ์ prismatic joint๋ฅผ ์ ์ดํ๋ค. ํ๋ฌ๊ทธ์ธ์ ์ ๋ฐ์ดํธ ์ฌ์ดํด์๋ lift joint๊ฐ ์๋ ๋ฒ ์ดํฐ๋ฅผ ์์ฒญ๋ ์ธต์ผ๋ก ์ด๋์ํค๊ณ dorr joint๊ฐ ์๋ ๋ฒ ์ดํฐ์ ํ์ฌ ์ํ์ ๋ฐ๋ผ ๋ซํ ๋ฌธ์ ์ฐ๋ค. ํน์ ์ธต์ผ๋ก์ ์ด๋์ ์ธต์ ๋ฒํธ๋ฅผ string message๋ก ์๋ ๋ฒ ์ดํฐ์ ํ ํฝ์ผ๋ก ๋ณด๋ด ์ด๋ฃจ์ด์ง ์ ์๋ค. ์์ธํ ํ๋ผ๋ฏธํฐ๋ ๋ค ์น์ ์์ ์ฃผ์ด์ง๋ค. ์๋ ๋ฒ ์ดํฐ์ ์ ์ด ๊ณผ์ ์ ๋ค์๊ณผ ๊ฐ๋ค.
- Wait for a floor request.
- Close door.
- Move to requested floor.
- Open door.
- Wait for five seconds.
- Close the door.
- Go to #1.
์ธต ์ด๋ ์์ฒญ์ Queue ํํ๊ฐ ์๋๋ฉฐ ์๋ก์ด ์์ฒญ์ด ์ค๊ธฐ ์ ์ ์ด๋์ ๋ง์น ๊ฒ์ด๋ค.
lift joint, door joint, floor height, control topic์ SDF์์ ๋ช ์๋์ด์๋ค. ๋ค์์ ๊ทธ ์์ด๋ค.
<plugin filename="libElevatorPlugin.so" name="elevator_plugin">
<lift_joint>elevator::lift</lift_joint>
<door_joint>elevator::door</door_joint>
<floor_height>3.075</floor_height>
<topic>~/elevator</topic>
</plugin>์ด ์์์ elevator ๋ชจ๋ธ์ ๋ฆฌํํ ์ ์ํ lift, ๋ฌธ ๊ฐํ๋ฅผ ์ํ door joint์ ํจ๊ฒ SDFํ์ผ ์ด๋๊ฐ์ ์กด์ฌํ๋ค. ๊ฐ ์ธต์ ๋์ด๋ 3.075 ๋ฏธํฐ์ด๊ณ ์๋ ๋ฒ ์ดํฐ ํ๋ฌ๊ทธ์ธ์ ~/elevator ํ ํฝ์์ ์์ฒญ์ ์์ ํ๋ค.
์์ฑ๋ example world๋ ๊ฐ์ ๋ณด์ ํจ๊ป ๋ฐฐํฌ๋๋ค. ์๋ ์ฝ๋๋ก ์คํ์ํฌ ์ ์๋ค.
gazebo worlds/elevator.world
์ด world๋ ๋ ์ธต๊ณผ ์๋ ๋ฒ ์ดํฐ ํ๋๋ก ์ด๋ฃจ์ด์ ธ ์๋ค. ๊ฐ๋จํ ๋ํ์ ์ธต ์์ ๋๋ฉด ์ธต ์ด๋ ์์ฒญ์ด Occupied Region Event๋ก ์ธํด ๋ฐ๋์ค๋๊ฒ ๋๋ค.
์๋ ๋ฒ ์ดํฐ ํ๋ฌ๊ทธ์ธ์ SimEventsPlugin์ OccupiedEvent์ ํจ๊ป ๋์ํ๋ค. OccupiedEvent๋ 3D ๊ตฌ์ญ์ผ๋ก model์ ์ํด ๋ฉ์ธ์ง๋ฅผ ๋ฐ์กํ๊ฒ ๋๋ค.
<plugin filename="libSimEventsPlugin.so" name="event_plugin">
<region>
<name>region1</name>
<volume>
<min>0 0 0</min>
<max>0 1 1</max>
</volume>
</region>
<event>
<name>region1_event</name>
<type>occupied</type>
<region>region1</region>
<topic>~/elevator</topic>
<msg_data>0</msg_data>
</event>
</plugin>OccupiedEvent๋ฅผ libSimEventsPlugin.so๋ฅผ ์๋ก ๋ค์ด ์ค๋ช ํ๋ค. ์ด๋ ์ด๋ occupied ์ ์ ๊ฐ์ง๊ณ ์๋ ์ ์์กดํ๋ค.
๋ค์ ์์์ region์ ์ต์์ (0,0,0)๊ณผ ์ต๋์ (1,1,1)๋ก ์ด๋ฃจ์ด์ง ๊ณต๊ฐ์ด๋ค. ์ด ๊ณต๊ฐ์ ์ด๋ฆ์ region1 ์ด๋ค. occupied ์ ์ธ region1 event ๋ํ region1์ ํตํด ๋ช ์๋๋ค. ์ด๋ค ๋ชจ๋ธ์ด region1์ ์์นํ๊ฒ ๋๋ฉด ๋ฐ์ดํฐ string message ๊ฐ ๊ฐ "0"์ ๊ฐ์ง๊ณ ~/elevator๋ก ์ ์ก๋๋ค.