kinetic@vm:~$ cd catkin_ws/src/
kinetic@vm:~/catkin_ws/src$ ls
CMakeLists.txt
kinetic@vm:~/catkin_ws/src$ catkin_create_pkg mbot_description urdf xacro
Created file mbot_description/package.xml
Created file mbot_description/CMakeLists.txt
Successfully created files in /home/kinetic/catkin_ws/src/mbot_description. Please adjust the values in package.xml.
kinetic@vm:~/catkin_ws/src$ ls
CMakeLists.txt mbot_description
kinetic@vm:~/catkin_ws/src$ cd mbot_description/
kinetic@vm:~/catkin_ws/src/mbot_description$ ls
CMakeLists.txt package.xml
kinetic@vm:~/catkin_ws/src/mbot_description$ mkdir urdf meshes launch config
kinetic@vm:~/catkin_ws/src/mbot_description$ ls
CMakeLists.txt config launch meshes package.xml urdf
urdf 存放机器人模型的URDF或xacro文件
meshes 放置URDF中引用的模型渲染文件
launch 保存相关启动文件
config 保存rviz的配置文件
kinetic@vm:~/catkin_ws/src/mbot_description/launch$ cat display_mbot_base_urdf.launch
<launch>
<param name="robot_description" textfile="$(find mbot_description)/urdf/mbot_base.urdf" />
<!-- 设置GUI参数,显示关节控制插件 -->
<param name="use_gui" value="true" />
<!-- 运行 joint_state_publisher 节点,发布机器人的关节状态 -->
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />
<!-- 运行 robot_state_publisher 节点,发布tf -->
<node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
<!-- 运行 rviz 可视化界面 -->
<node name="rviz" pkg="rviz" type="rviz" args="-d $(find mbot_description)/config/mbot_urdf.rviz" required="true" />
</launch>
param 加载ros参数, 参数名为 robot_description,textfile是参数的信息,robot_description中保存了一条路径信息。
joint_state_publisher
发布每个joint(除fixed类型)的状态,而且可以通过UI界面对joint进行控制
将机器人各个links、joints之间的关系,通过TF的形式,整理三维姿态信息发布
创建机器人模型
kinetic@vm:~/catkin_ws/src/mbot_description/launch$ cat display_mbot_base_urdf.launch
<launch>
<param name="robot_description" textfile="$(find mbot_description)/urdf/mbot_base.urdf" />
<!-- 设置GUI参数,显示关节控制插件 -->
<param name="use_gui" value="true" />
<!-- 运行 joint_state_publisher 节点,发布机器人的关节状态 -->
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />
<!-- 运行 robot_state_publisher 节点,发布tf -->
<node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
<!-- 运行 rviz 可视化界面 -->
<node name="rviz" pkg="rviz" type="rviz" args="-d $(find mbot_description)/config/mbot_urdf.rviz" required="true" />
</launch>
kinetic@vm:~/catkin_ws/src/mbot_description/urdf$ cat mbot_base.urdf
<?xml version="1.0" ?>
<robot name="mbot"> <!-- 小车模型 机器人的名称 mbot -->
<link name="base_link"> <!-- 一般机器人的主体部分称为base_link,机体的一个概念 -->
<visual> <!-- 可视化的效果 -->
<origin xyz=" 0 0 0" rpy="0 0 0" /> <!-- xyz描述坐标的位置的,rpy在xyz方向上的旋转 -->
<geometry> <!-- 这里用圆柱体描述机器人的一个主体部分 -->
<cylinder length="0.16" radius="0.20"/> <!-- 圆柱体的高和半径 -->
</geometry>
<material name="yellow"> <!-- 圆柱体的颜色 -->
<color rgba="1 0.4 0 1"/> <!-- 用rgb来描述,a透明度从0到1,1是不透明,0透明 -->
</material>
</visual>
</link>
<joint name="left_wheel_joint" type="continuous"> <!-- 关节连接车轮,关节类型是可以无限旋转的 -->
<origin xyz="0 0.19 -0.05" rpy="0 0 0"/>
<parent link="base_link"/>
<child link="left_wheel_link"/>
<axis xyz="0 1 0"/> <!-- 指定y轴做具体旋转 -->
</joint>
<link name="left_wheel_link"> <!-- 左轮 -->
<visual>
<origin xyz="0 0 0" rpy="1.5707 0 0" />
<geometry>
<cylinder radius="0.06" length = "0.025"/>
</geometry>
<material name="white">
<color rgba="1 1 1 0.9"/>
</material>
</visual>
</link>
<joint name="right_wheel_joint" type="continuous">
<origin xyz="0 -0.19 -0.05" rpy="0 0 0"/>
<parent link="base_link"/>
<child link="right_wheel_link"/>
<axis xyz="0 1 0"/>
</joint>
<link name="right_wheel_link">
<visual>
<origin xyz="0 0 0" rpy="1.5707 0 0" />
<geometry>
<cylinder radius="0.06" length = "0.025"/>
</geometry>
<material name="white">
<color rgba="1 1 1 0.9"/>
</material>
</visual>
</link>
<joint name="front_caster_joint" type="continuous">
<origin xyz="0.18 0 -0.095" rpy="0 0 0"/>
<parent link="base_link"/>
<child link="front_caster_link"/>
<axis xyz="0 1 0"/>
</joint>
<link name="front_caster_link"> <!-- 支撑轮,一般是万向轮,这里用球体代替 -->
<visual>
<origin xyz="0 0 0" rpy="0 0 0"/>
<geometry>
<sphere radius="0.015" />
</geometry>
<material name="black">
<color rgba="0 0 0 0.95"/>
</material>
</visual>
</link>
<joint name="back_caster_joint" type="continuous">
<origin xyz="-0.18 0 -0.095" rpy="0 0 0"/>
<parent link="base_link"/>
<child link="back_caster_link"/>
<axis xyz="0 1 0"/>
</joint>
<link name="back_caster_link">
<visual>
<origin xyz="0 0 0" rpy="0 0 0"/>
<geometry>
<sphere radius="0.015" />
</geometry>
<material name="black">
<color rgba="0 0 0 0.95"/>
</material>
</visual>
</link>
</robot>
运行
kinetic@vm:~$ roslaunch mbot_description display_mbot_base_urdf.launch
检查URDF模型整体结构
kinetic@vm:~/catkin_ws/src/mbot_description/urdf$ urdf_to_graphiz mbot_base.urdf
Created file mbot.gv
Created file mbot.pdf
参考
HRMRP机器人的设计: http://www.guyuehome.com/275
创建简单的机器人模型smartcar: http://www.guyuehome.com/234
ROS URDF Tutorials: http://wiki.ros.org/urdf/Tutorials
ARM端安装ROS: http://wiki.ros.org/indigo/Installation/UbuntuARM