总之,最重要的一点是:每个部件的中点是相对于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>