Skip to content

Make a Mobile Robot

Taehun Lim edited this page Feb 5, 2018 · 3 revisions

1. Overview

이 튜토리얼은 Gazebo의 기본적인 모델 관리에 관해 설명하고 움직임을 위해 differential drive mechanism을 사용하는 tow wheeled mobile robot을 생성하는 과정을 통해 사용자가 얻는 모델의 데이터베이스내에 모델의 기본적인 모델 표현에 익숙해지도록 연습한다.

2. Setup your model directory

당신은 당신의 모델을 생성할 것 이다. 당신의 모델은 가제보 모델 데이터베이스 폴더 구조에 따른 포맷의 규칙을 따라야 한다.

  1. 모델 폴더를 생성해라.
$ mkdir -p ~/.gazebo/models/my_robot
  1. 모델 config 파일을 생성해라.
$ gedit ~/.gazebo/models/my_robot/model.config
  1. 다음의 내용을 복사해라.
    <?xml version="1.0"?>
     <model>
      <name>My Robot</name>
      <version>1.0</version>
      <sdf version='1.4'>model.sdf</sdf>

      <author>
       <name>My Name</name>
       <email>me@my.email</email>
      </author>

      <description>
        My awesome robot.
      </description>
    </model>
  1. model.sdf 파일을 생성해라.

    $ gedit ~/.gazebo/models/my_robot/model.sdf

  2. 다음의 내용을 복사해라.

    <?xml version='1.0'?>
    <sdf version='1.4'>
      <model name="my_robot">
      </model>
    </sdf>

3. Build the Model's Structure

이번 step은 두개의 바퀴를 가진 사각형 베이스를 생성 할 것 이다. 간단히 시작하고 step들에서 모델을 생성하는 것은 중요하다. 첫 step에서 모델의 간단한 형태의 레이아웃이다. 이것을 하기위해 우리의 모델은 static이 될 것이고 이것의 의미는 물리엔진에 영향을 받지 않는 다는 것이다. 모델이 한 장소에서 머물러 있을 수 있게 되고 이것은 우리가 모든 요소들을 적절히 정렬할 수 있도록 해준다.

  1. true을 model.sdf 파일에 추가하므로 모델이 static하게 한다.
    <?xml version='1.0'?>
    <sdf version='1.4'>
      <model name="my_robot">

        <static>true</static>

      </model>
    </sdf>
  1. model.sdf 파일을 수정하여 사각형 베이스를 추가한다.
    <?xml version='1.0'?>
      <sdf version='1.4'>
        <model name="my_robot">
        <static>true</static>

          <link name='chassis'>
            <pose>0 0 .1 0 0 0</pose>

            <collision name='collision'>
              <geometry>
                <box>
                  <size>.4 .2 .1</size>
                </box>
              </geometry>
            </collision>

            <visual name='visual'>
              <geometry>
                <box>
                  <size>.4 .2 .1</size>
                </box>
              </geometry>
            </visual>
          </link>

      </model>
    </sdf>

여기에서 우리는 0.4 x 0.2 x 0.1(m) 크기의 박스를 만들었다. collision 요소는 충돌 감지 엔진에 의해 형태가 명시된다. visual 요소는 렌더링 엔진에 위해 형태가 명시 된다. 대개의 경우에 collision과 visual 요소는 같다. 하지만 복잡한 mesh를 사용하는 visual 요소와 단순한 형태의 collision요소를 사용하는 경우가 일반적이다. 이것은 성능 향상에 도움을 줄 것 이다.

  1. gazebo를 동작하여 당신의 모델을 불러오자. 가제보 GUI 인터페이스의 Insert Model을 통해 당신의 모델을 불러올 수 있다.

    $ gazebo

당신은 흰색 박스가 지면에서 1미터 정도 떠있는 것을 볼 수 있다.

  1. 이제 우리는 바퀴를 로봇에 추가 할 것이다. 바퀴는 마찰을 가지지 않는 구이다. 이런 종류의 바퀴가 조인트를 가지는 바퀴를 추가하는 것보다 낫다. 왜냐하면 이것은 물리엔진에서 더 적은 구속 조건을 가지기 때문이다.
    <?xml version='1.0'?>
    <sdf version='1.4'>
      <model name="my_robot">
        <static>true</static>
        <link name='chassis'>
          <pose>0 0 .1 0 0 0</pose>
          <collision name='collision'>
            <geometry>
              <box>
                <size>.4 .2 .1</size>
              </box>
            </geometry>
          </collision>

          <visual name='visual'>
            <geometry>
              <box>
                <size>.4 .2 .1</size>
              </box>
            </geometry>
          </visual>

          <collision name='caster_collision'>
            <pose>-0.15 0 -0.05 0 0 0</pose>
            <geometry>
                <sphere>
                <radius>.05</radius>
              </sphere>
            </geometry>

            <surface>
              <friction>
                <ode>
                  <mu>0</mu>
                  <mu2>0</mu2>
                  <slip1>1.0</slip1>
                  <slip2>1.0</slip2>
                </ode>
              </friction>
            </surface>
          </collision>

          <visual name='caster_visual'>
            <pose>-0.15 0 -0.05 0 0 0</pose>
            <geometry>
              <sphere>
                <radius>.05</radius>
              </sphere>
            </geometry>
          </visual>

        </link>
      </model>
    </sdf>

당신의 모델이 로봇의 끝에 바퀴가 나타나는지 시험해봐라. 당신은 가제보를 다시 시작 할 필요가 없다. 당신의 수정된 모델을 가제보에 삽입할 때 매번 디스크로 부터 재로드 하기 때문이다.

  • Tip : 메뉴창의 View를 클릭하고 Collisions를 클릭하면 충돌 영역이 주황색으로 표시 되는걸 확인하실 수 있습니다.

5.이제 왼쪽 바퀴를 추가 해보자 다음과 같이 model.sdf파일을 수정해라.

    <?xml version='1.0'?>
    <sdf version='1.4'>
      <model name="my_robot">
        <static>true</static>
        <link name='chassis'>
          <pose>0 0 .1 0 0 0</pose>
          <collision name='collision'>
            <geometry>
              <box>
                <size>.4 .2 .1</size>
              </box>
            </geometry>
          </collision>

          <visual name='visual'>
            <geometry>
              <box>
                <size>.4 .2 .1</size>
              </box>
            </geometry>
          </visual>

          <collision name='caster_collision'>
            <pose>-0.15 0 -0.05 0 0 0</pose>
            <geometry>
              <sphere>
              <radius>.05</radius>
            </sphere>
          </geometry>

          <surface>
            <friction>
              <ode>
                <mu>0</mu>
                <mu2>0</mu2>
                <slip1>1.0</slip1>
                <slip2>1.0</slip2>
              </ode>
            </friction>
          </surface>
        </collision>

        <visual name='caster_visual'>
          <pose>-0.15 0 -0.05 0 0 0</pose>
          <geometry>
            <sphere>
              <radius>.05</radius>
            </sphere>
          </geometry>
        </visual>
      </link>

      <link name="left_wheel">
        <pose>0.1 0.13 0.1 0 1.5707 1.5707</pose>
        <collision name="collision">
          <geometry>
            <cylinder>
              <radius>.1</radius>
              <length>.05</length>
            </cylinder>
          </geometry>
        </collision>
        <visual name="visual">
          <geometry>
            <cylinder>
              <radius>.1</radius>
              <length>.05</length>
            </cylinder>
          </geometry>
        </visual>
      </link>

      </model>
    </sdf>

다시 Gazebo를 실행 시키고 당신의 로봇 모델을 삽입시켜라. 정확한 위치에 바퀴가 나타나는지 확인해라.

6.우리는 왼쪽 바퀴를 복사 함으로써 오른쪽 바퀴를 만들 수 있다 그리고 바퀴 링크위 우치를 조정 할 수 있다.

    <?xml version='1.0'?>
    <sdf version='1.4'>
      <model name="my_robot">
        <static>true</static>
        <link name='chassis'>
          <pose>0 0 .1 0 0 0</pose>
          <collision name='collision'>
            <geometry>
              <box>
                <size>.4 .2 .1</size>
              </box>
            </geometry>
          </collision>

          <visual name='visual'>
            <geometry>
              <box>
                <size>.4 .2 .1</size>
              </box>
            </geometry>
          </visual>

          <collision name='caster_collision'>
            <pose>-0.15 0 -0.05 0 0 0</pose>
            <geometry>
              <sphere>
              <radius>.05</radius>
            </sphere>
          </geometry>

          <surface>
            <friction>
              <ode>
                <mu>0</mu>
                <mu2>0</mu2>
                <slip1>1.0</slip1>
                <slip2>1.0</slip2>
              </ode>
            </friction>
          </surface>
        </collision>

        <visual name='caster_visual'>
          <pose>-0.15 0 -0.05 0 0 0</pose>
          <geometry>
            <sphere>
              <radius>.05</radius>
            </sphere>
          </geometry>
        </visual>
      </link>
      <link name="left_wheel">
        <pose>0.1 0.13 0.1 0 1.5707 1.5707</pose>
        <collision name="collision">
          <geometry>
            <cylinder>
              <radius>.1</radius>
              <length>.05</length>
            </cylinder>
          </geometry>
        </collision>
        <visual name="visual">
          <geometry>
            <cylinder>
              <radius>.1</radius>
              <length>.05</length>
            </cylinder>
          </geometry>
        </visual>
      </link>

      <link name="right_wheel">
        <pose>0.1 -0.13 0.1 0 1.5707 1.5707</pose>
        <collision name="collision">
          <geometry>
            <cylinder>
              <radius>.1</radius>
              <length>.05</length>
            </cylinder>
          </geometry>
        </collision>
        <visual name="visual">
          <geometry>
            <cylinder>
              <radius>.1</radius>
              <length>.05</length>
            </cylinder>
          </geometry>
        </visual>
      </link>

      </model>
    </sdf>

현시점까지 로봇은 하나의 샤시에 하나의 구 바퀴와 두개의 휠바퀴를 가진 로봇이다.

  1. <static>을 false로 셋팅하여 모델을 dynamic하게 만든다. 왼쪽, 오른쪽 휠 바퀴에 hinge 조인트를 추가한다.
    <?xml version='1.0'?>
    <sdf version='1.4'>
      <model name="my_robot">

        <static>false</static>

        <link name='chassis'>
          <pose>0 0 .1 0 0 0</pose>
          <collision name='collision'>
            <geometry>
              <box>
                <size>.4 .2 .1</size>
              </box>
            </geometry>
          </collision>

          <visual name='visual'>
            <geometry>
              <box>
                <size>.4 .2 .1</size>
              </box>
            </geometry>
          </visual>

          <collision name='caster_collision'>
            <pose>-0.15 0 -0.05 0 0 0</pose>
            <geometry>
              <sphere>
              <radius>.05</radius>
            </sphere>
          </geometry>

          <surface>
            <friction>
              <ode>
                <mu>0</mu>
                <mu2>0</mu2>
                <slip1>1.0</slip1>
                <slip2>1.0</slip2>
              </ode>
            </friction>
          </surface>
        </collision>

        <visual name='caster_visual'>
          <pose>-0.15 0 -0.05 0 0 0</pose>
          <geometry>
            <sphere>
              <radius>.05</radius>
            </sphere>
          </geometry>
        </visual>
      </link>
      <link name="left_wheel">
        <pose>0.1 0.13 0.1 0 1.5707 1.5707</pose>
        <collision name="collision">
          <geometry>
            <cylinder>
              <radius>.1</radius>
              <length>.05</length>
            </cylinder>
          </geometry>
        </collision>
        <visual name="visual">
          <geometry>
            <cylinder>
              <radius>.1</radius>
              <length>.05</length>
            </cylinder>
          </geometry>
        </visual>
      </link>

      <link name="right_wheel">
        <pose>0.1 -0.13 0.1 0 1.5707 1.5707</pose>
        <collision name="collision">
          <geometry>
            <cylinder>
              <radius>.1</radius>
              <length>.05</length>
            </cylinder>
          </geometry>
        </collision>
        <visual name="visual">
          <geometry>
            <cylinder>
              <radius>.1</radius>
              <length>.05</length>
            </cylinder>
          </geometry>
        </visual>
      </link>

      <joint type="revolute" name="left_wheel_hinge">
        <pose>0 0 -0.03 0 0 0</pose>
        <child>left_wheel</child>
        <parent>chassis</parent>
        <axis>
          <xyz>0 1 0</xyz>
        </axis>
      </joint>

      <joint type="revolute" name="right_wheel_hinge">
        <pose>0 0 0.03 0 0 0</pose>
        <child>right_wheel</child>
        <parent>chassis</parent>
        <axis>
          <xyz>0 1 0</xyz>
        </axis>
      </joint>

      </model>
    </sdf>

두개의 조인트는 y축 0 1 0 에 대하여 회전한다. 그리고 각 휠 바퀴는 샤시에 연결된다.

  1. 가제보를 시작하고 당신의 모델을 삽입한다. 스크린 오른쪽의 점들을 클릭하고 왼쪽으로 그것을 드래그하여라.

  2. 새로운 창이 나타나며 이 창은 각 조인트에 대한 다양한 컨트롤러들을 포함한다.(Note 당신이 제어하기 원하는 모델이 선택되어있는지 확인 한다.)

  3. Force 탭 아래에 각조인트에 약 0.1Nm의 힘을 가해라. 로봇이 주변을 움직인다.

  4. 축하합니다. 당신은 이제 기본적인 모바일 로봇을 가졌습니다.

Table of Contents




Clone this wiki locally