編寫自己的機器人的模型URDF
總之,最重要的一點是:每個部件的中點是相對於parent_frame父座標系的幾何中心的。儘管做出來的車有人說像充電寶,有人說是個滑板模型(笑哭無奈的表情哈!—)我還是要把它貼出來。
程式碼如下:agvcar.urdf
<?xml version="1.0"?> <robot name="agvcar"> <link name="base_link"> <visual> <geometry> <box size="1.46 0.45 0.08"/> </geometry> <origin rpy="0 0 1.57075" /> <material name="yellow"> <color rgba="1 0.4 0 1"/> </material> </visual> </link>
<link name="front_wheel"> <visual> <geometry> <cylinder length="0.058" radius="0.091"/> </geometry> <material name="black"> <color rgba="0 0 0 1"/> </material> </visual> </link>
<joint name="base_front_joint" type="continuous"> <axis xyz="0 0 1"/> <parent link="base_link"/> <child link="front_wheel"/> <origin rpy="0 1.57075 0" xyz="0.0 0.225 -0.04"/> <limit effort="100" velocity="100"/> <joint_properties damping="0.0" friction="0.0"/> </joint>
<link name="right_back_wheel"> <visual> <geometry> <cylinder length="0.04" radius="0.08"/> </geometry> <material name="black"> <color rgba="0 0 0 1"/> </material> </visual> </link>
<joint name="right_back_wheel_joint" type="continuous"> <axis xyz="0 0 1"/> <parent link="base_link"/> <child link="right_back_wheel"/> <origin rpy="0 1.57075 0" xyz="0.187 -0.67 -0.03"/> <limit effort="100" velocity="100"/> <joint_properties damping="0.0" friction="0.0"/> </joint>
<link name="left_back_wheel"> <visual> <geometry> <cylinder length=".04" radius="0.08"/> </geometry> <material name="black"> <color rgba="0 0 0 1"/> </material> </visual> </link>
<joint name="left_back_wheel_joint" type="continuous"> <axis xyz="0 0 1"/> <parent link="base_link"/> <child link="left_back_wheel"/> <origin rpy="0 1.57075 0" xyz="-0.187 -0.67 -0.03"/> <limit effort="100" velocity="100"/> <joint_properties damping="0.0" friction="0.0"/> </joint>
<link name="head"> <visual> <geometry> <box size=".45 .045 .08"/> </geometry> <material name="white"> <color rgba="1 1 1 1"/> </material> </visual> </link>
<joint name="tobox" type="fixed"> <parent link="base_link"/> <child link="head"/> <origin xyz="0 0.73 0.0"/> </joint> </robot>
base.urdf.rviz.launch使用RVIZ顯示車體模型檔案:
<launch> <arg name="model" /> <arg name="gui" default="False" /> <param name="robot_description" textfile="$(find agvcar_description)/urdf/agvcar.urdf" /> <param name="use_gui" value="$(arg gui)"/> <node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" > </node> <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
</launch>