2 minute read

1. roscore 실행

roscore

필요 패키지 설치

$ sudo apt-get install liburdfdom-tools
$ sudo apt-get install evince

urdf_exam 패키지 및 urdf 폴더 생성

$ cd ~/catkin_ws/src
$ catkin create pkg urdf_exam --catkin-deps std_msgs rospy urdf xacro roscpp
$ cd urdf_exam
$ mkdir urdf

myfirst.urdf 생성

<?xml version="1.0" ?>
<robot name= "myfirst">
    <link name="base_link">
    <visual>
        <geometry>
            <cylinder length="0.6" radius = "0.2" /> 
            <!-- 실린더 모양 링크(base_link) 생성 -->
        </geometry>
    </visual>
    </link>
</robot>

check_urdf

$ cd ~/catkin_ws/src/urdf_exam/urdf
$ check myfirst.urdf
$ urdf_to_graphiz myfirst.urdf # 확인용 pdf 생성

launch 폴더 생성 및 display.launch 파일 생성

<?xml version = "1.0" ?>

<launch>
    <arg name="model" />
    
    <param name = "robot_description" textfile = "$(arg model)" />
    <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher">
        <param name="use_gui" value="TRUE"/>
        <!-- joint_state_publisher 사용 -->
    </node>
    <node name = "robot_state_publisher" pkg= "robot_state_publisher" type = "state_publisher" />
    <node name = "rviz" pkg="rviz" type = "rviz" args = "-d $(find urdf_exam)/urdf.rviz" />

</launch>

실행

$ cd ~/catkin_ws
$ catkin build
$ source ./devel/setup.bash
$ cd ./src/urdf_exam/urdf
$ roslaunch urdf_exam display.launch model:=myfirst.urdf

해당 urdf 상세 설명

[no-alignment]

  • visual : 외형 혹은 3D 도면 파일을 연결
  • collision : 충돌방지나 충돌요소에 대한 시뮬레이션에서 사용
<?xml version = "1.0" ?>
<robot name = "pan_tilt">

    <link name="base_link">
        <visual>
            <!-- 도형은 실린더 모형으로 -->
            <geometry>
                <cylinder length= "0.01" radius = "0.2"/>
            </geometry>
            <!-- 위치는 원점으로 -->
            <origin rpy="0 0 0" xyz = "0 0 0"/>
            <!-- 색상은 노란색 -->
            <material name= "yellow">
                <color rgba= "1 1 0 1"/>
            </material>
        </visual>

        <collision>
            <!-- 도형은 실린더 모형으로 -->
            <geometry>
                <cylinder length ="0.03" radius = "0.2" />
            </geometry>
            <origin rpy="0 0 0" xyz= "0 0 0"/>
        </collision>

        <inertial>
            <mass value="1" />
            <inertia ixx= "1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
        </inertial>
        
    </link>

    <joint name="pan_joint" type = "revolute">
        <parent link = "base_link"/>
        <child link= "pan_link"/>
        <origin xyz = "0 0 0.1"/>
        <!-- axis : 회전 중심 축 -->
        <axis xyz = "0 0 1"/>
        <limit effort="300" velocity="0.1" lower="-3.14" upper="3.14" />
        <dynamics damping="50" friction = "1" />
    </joint>

    <link name="pan_link">
        <visual>
            <geometry>
                <cylinder length="0.3" radius="0.04" />
            </geometry>
            <origin rpy="0 0 0" xyz = "0 0 0.09" />
            <material name="blue">
                <color rgba = "0 0 1 1"/>
            </material>
        </visual>

        <collision>
            <geometry>
                <cylinder length = "0.4" radius = "0.06" />
            </geometry>
            <origin rpy = "0 0 0" xyz =  "0 0 0.09" />
        </collision>

        <inertial>
            <mass value ="1" />
            <inertia ixx = "1.0" ixy = "0.0" ixz ="0.0" iyy = "1.0" iyz="0.0" izz="1.0" />
        </inertial>

    </link>

    <joint name="tilt_joint" type = "revolute">
        <parent link="pan_link"/>
        <child link="tilt_link"/>
        <origin xyz="0 0 0.2"/>
        <axis xyz= "0 1 0"/>
        <limit effort="300" velocity="0.1" lower="-4.71239" upper= "-1.570796" />
        <dynamics damping="50" friction="1"/>
    </joint>

    <link name="tilt_link">
        <visual>
            <geometry>
                <cylinder length="0.4" radius="0.04" />
            </geometry>
            <origin rpy= "0 1.570796 0" xyz= "0 0 0"/>
            <material name = "red">
                <color rgba= "1 0 0 1" />
            </material>
        </visual>

        <collision>
            <geometry>
                <cylinder length="0.4" radius="0.06" />
            </geometry>
            <origin rpy = "0 1.570796 0" xyz = "0 0 0"/>
        </collision>

        <inertial>
            <mass value = "1" />
            <inertia ixx = "1.0" ixy = "0.0" ixz ="0.0" iyy = "1.0" iyz="0.0" izz="1.0" />
        </inertial>
    </link>

</robot>

Categories:

Updated: