직접 패키지를 만들고, 이동 로봇을 만들어서 키보드를 활용해 맵에서 움직여보자.
URDF의 확장으로 사용되며, XML 형식을 통해 로봇 모델을 더 간결하고 가독성이 높게 표현할 수 있도록 도와준다. Xacro 파일은 XML 형식을 가지고 있지만, 일반적으로 URDF 파일에서 반복되는 부분을 매크로로 정의하여 재사용할 수 있다.
URDF (Unified Robot Description Format)
:
SDF (Simulation Description Format)
:
link
: 로봇의 각 부분을 나타내는 링크를 정의하는 요소visual
: 시각적으로 표현되는 부분을 정의하는 요소collision
: 충돌 감지를 위해 사용되는 부분을 정의하는 요소inertial
: 링크의 관성 특성을 정의하는 요소, 질량과 관성 텐서를 정의joint
: 두 링크를 연결하는 구조를 정의, 두 링크 사이의 상대적인 운동 정의
body_rf_wheel
조인트의 경우:
body_rb_wheel
조인트의 경우:
transmission
: 각 바퀴의 관절과 해당 관절을 제어하기 위한 엑추에이터 및 하드웨어 인터페이스에 대한 정보 제어gazebo
: Gazebo 시뮬레이션 환경에서 skid steer 드라이브 컨트롤러를 사용하는 플러그인을 정의 → 로봇의 움직임을 제어하고 시뮬레이션에서 로봇을 움직이게 함
<?xml version="1.0"?>
<robot xmlns:xacro="<http://www.ros.org/wiki/xacro>" name="mobile_robot">
<link name="body">
<visual>
<geometry>
<box size="2 1 0.7"/>
</geometry>
</visual>
<collision>
<geometry>
<box size="2 1 0.7"/>
</geometry>
</collision>
<inertial>
<mass value="4"/>
<inertia ixx="0.4967" ixy="0.0" ixz="0" iyy="1.4967" iyz="0" izz="1.6667"/>
</inertial>
</link>
<!--............................................rf_wheel...................................................... -->
<link name= "rf_wheel">
<visual>
<origin rpy="1.570795 0 0" xyz="0 0 0"/>
<geometry>
<cylinder length="0.2" radius="0.5"/>
</geometry>
</visual>
<collision>
<origin rpy="1.570795 0 0" xyz="0 0 0"/>
<geometry>
<cylinder length="0.2" radius="0.5"/>
</geometry>
</collision>
<inertial>
<origin rpy="1.570795 0 0" xyz="0 0 0"/>
<mass value="1"/>
<inertia ixx="0.06583" ixy="0.0" ixz="0.0" iyy="0.06583" iyz="0.0" izz="0.125"/>
</inertial>
</link>
<joint name="body_rf_wheel" type="continuous">
<axis xyz="0 1 0"/>
<parent link="body"/>
<child link="rf_wheel"/>
<origin rpy="0 0 0" xyz="0.7 -0.6 0"/>
<limit effort="100" velocity="1.0"/>
</joint>
<!--............................................rb_wheel...................................................... -->
<link name= "rb_wheel">
<visual>
<origin rpy="1.570795 0 0" xyz="0 0 0"/>
<geometry>
<cylinder length="0.2" radius="0.5"/>
</geometry>
</visual>
<collision>
<origin rpy="1.570795 0 0" xyz="0 0 0"/>
<geometry>
<cylinder length="0.2" radius="0.5"/>
</geometry>
</collision>
<inertial>
<origin rpy="1.570795 0 0" xyz="0 0 0"/>
<mass value="1"/>
<inertia ixx="0.06583" ixy="0.0" ixz="0.0" iyy="0.06583" iyz="0.0" izz="0.125"/>
</inertial>
</link>
<joint name="body_rb_wheel" type="continuous">
<axis xyz="0 1 0"/>
<parent link="body"/>
<child link="rb_wheel"/>
<origin rpy="0 0 0" xyz="-0.7 -0.6 0"/>
<limit effort="100" velocity="1.0"/>
</joint>
<!--............................................lf_wheel...................................................... -->
<link name= "lf_wheel">
<visual>
<origin rpy="1.570795 0 0" xyz="0 0 0"/>
<geometry>
<cylinder length="0.2" radius="0.5"/>
</geometry>
</visual>
<collision>
<origin rpy="1.570795 0 0" xyz="0 0 0"/>
<geometry>
<cylinder length="0.2" radius="0.5"/>
</geometry>
</collision>
<inertial>
<origin rpy="1.570795 0 0" xyz="0 0 0"/>
<mass value="1"/>
<inertia ixx="0.06583" ixy="0.0" ixz="0.0" iyy="0.06583" iyz="0.0" izz="0.125"/>
</inertial>
</link>
<joint name="body_lf_wheel" type="continuous">
<axis xyz="0 1 0"/>
<parent link="body"/>
<child link="lf_wheel"/>
<origin rpy="0 0 0" xyz="0.7 0.6 0"/>
<limit effort="100" velocity="1.0"/>
</joint>
<!--............................................lb_wheel...................................................... -->
<link name= "lb_wheel">
<visual>
<origin rpy="1.570795 0 0" xyz="0 0 0"/>
<geometry>
<cylinder length="0.2" radius="0.5"/>
</geometry>
</visual>
<collision>
<origin rpy="1.570795 0 0" xyz="0 0 0"/>
<geometry>
<cylinder length="0.2" radius="0.5"/>
</geometry>
</collision>
<inertial>
<origin rpy="1.570795 0 0" xyz="0 0 0"/>
<mass value="1"/>
<inertia ixx="0.06583" ixy="0.0" ixz="0.0" iyy="0.06583" iyz="0.0" izz="0.125"/>
</inertial>
</link>
<joint name="body_lb_wheel" type="continuous">
<axis xyz="0 1 0"/>
<parent link="body"/>
<child link="lb_wheel"/>
<origin rpy="0 0 0" xyz="-0.7 0.6 0"/>
<limit effort="100" velocity="1.0"/>
</joint>
<!--............................................trnasmission...................................................... -->
<transmission name="rf_transmission">
<type>transmission_interface/SimpleTransmission</type>
<actuator name="rf_motor">
<mechanicalReduction>1</mechanicalReduction>
</actuator>
<joint name="body_rf_wheel">
<hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
</joint>
</transmission>
<transmission name="rb_transmission">
<type>transmission_interface/SimpleTransmission</type>
<actuator name="rb_motor">
<mechanicalReduction>1</mechanicalReduction>
</actuator>
<joint name="body_rb_wheel">
<hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
</joint>
</transmission>
<transmission name="lf_transmission">
<type>transmission_interface/SimpleTransmission</type>
<actuator name="lf_motor">
<mechanicalReduction>1</mechanicalReduction>
</actuator>
<joint name="body_lf_wheel">
<hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
</joint>
</transmission>
<transmission name="lb_transmission">
<type>transmission_interface/SimpleTransmission</type>
<actuator name="lb_motor">
<mechanicalReduction>1</mechanicalReduction>
</actuator>
<joint name="body_lb_wheel">
<hardwareInterface>hardware_interface/PositionJointInterface</hardwareInterface>
</joint>
</transmission>
<gazebo>
<plugin name="skid_steer_drive_controller" filename="libgazebo_ros_skid_steer_drive.so">
<updateRate>100.0</updateRate>
<robotNamespace>/</robotNamespace>
<leftFrontJoint>body_lf_wheel</leftFrontJoint>
<rightFrontJoint>body_rf_wheel</rightFrontJoint>
<leftRearJoint>body_lb_wheel</leftRearJoint>
<rightRearJoint>body_rb_wheel</rightRearJoint>
<wheelSeparation>0.2</wheelSeparation>
<wheelDiameter>0.4</wheelDiameter>
<torque>100</torque>
<robotBaseFrame>body</robotBaseFrame>
<topicName>cmd_vel</topicName>
<broadcastTF>false</broadcastTF>
</plugin>
</gazebo>
</robot>