link标签
用于描述机器人某个刚体部分的外观和物理属性(比如尺寸(size)、颜色(color)、形状(shape)、惯性矩阵(inertial matrix)、碰撞属性(collision properties)等)
xml的格式的描述
<link name="">
<inertial>......inertial>
<visual>......visual>
<collision>......collision>
link>
joint标签
描述机器人关节的运动学和动力学属性,包括关节运动的位置和速度限制。根据关节的运动形式,可以将其分为六种类型
关节类型 | 描述 |
---|---|
continuous | 旋转关节,可以围绕单轴无限旋转 |
revolute | 旋转关节,类似于continuous,但是有旋转的角度限制 |
prismatic | 滑动关节,沿某一轴线移动的关节,带有位置极限 |
planar | 平面关节,允许在平面正交方向上平移或者旋转 |
floating | 浮动关节,允许进行平移、旋转运动 |
fixed | 固定关节,不允许运动的特殊关节 |
xml格式的描述
<joint name="" type="" >
<parent link="parent_link"/>
<child link="child_link"/>
<calibration ....../>
<dynamics damping ....../>
<limit effort ....../>
......
joint>
robot标签
完整机器人模型的最顶层标签,< link > 和 < joint >标签必须包含在 < robot > 标签内
xml格式描述
<robot name="name of the robot">
<link>......link>
<link>......link>
<joint>......joint>
<joint>......joint>
robot>
1.创建一个机器人建模的功能包
#进入工作空间
cd ./catkin_ws/src/
#创建功能包
catkin_create_pkg mbot_description urdf xacro
2.创建机器人建模的功能包的文件结构
cd ./catkin_ws/src/mbot_description
mkdir urdf
mkdir meshes
mkdir launch
mkdir config
目录名称 | 描述 |
---|---|
urdf | 存放机器人模型的URDF或xacro文件 |
meshes | 放置URDF中引用的模型渲染文件,机器人外观纹理,让外观和实际更相似 |
launch | 保存相关启动文件 |
config | 保存rviz的配置文件、功能包的配置文件 |
cd ./catkin_ws/src/mbot_description/launch
sudo gedit display_mbot_base_urdf.launch
display_mbot_base_urdf.launch文件内容
<launch>
<param name="robot_description" textfile="$(find mbot_description)/urdf/mbot_base.urdf" />
<param name="use_gui" value="true"/>
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />
<node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
<node name="rviz" pkg="rviz" type="rviz" args="-d $(find mbot_description)/config/mbot_urdf.rviz" required="true" />
launch>
cd ./catkin_ws/src/mbot_description/urdf
sudo gedit mbot_base.urdf
mbot_base.urdf文件内容
<robot name="mbot">
<link name="base_link">
<visual>
<origin xyz=" 0 0 0" rpy="0 0 0" />
<geometry>
<cylinder length="0.16" radius="0.20"/>
geometry>
<material name="yellow">
<color rgba="1 0.4 0 1"/>
material>
visual>
link>
robot>
查看显示的效果
roslaunch mbot_description display_mbot_base_urdf.launch
问题描述
1.Could not find the GUI, install the ‘joint_state_publisher_gui’ package
解决方法:
sudo apt-get install ros-melodic-joint-state-publisher-gui(melodic版本)
2.[joint_state_publisher-1] process has died [pid 12201, exit code 1, cmd /opt/
解决方法:
urdf文件第一行前面到空格全部去掉,一般格式正确后都会有颜色的,写urdf一定要注意格式,并且将其中的注释给去掉,后面再添加相应代码的时候注意去掉注释内容
3.RVIZ成功启动不显示模型
解决方法:
①将Fixed Frame改为base_link
②点击下方的Add按钮添加RobotModel
sudo gedit mbot_base.urdf
添加代码内容(添加到上面文件代码所留出的空白位置)
<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"/>
joint>
<link name="left_wheel_link">
<visual>
<origin xyz="0 0 0" rpy="1.5707 0 0" />
<geometry>
geometry>
<material name="white">
<color rgba="1 1 1 0.9"/>
material>
visual>
link>
注意:
去掉注释
查看显示效果
roslaunch mbot_description display_mbot_base_urdf.launch
查看小车主体和轮子之间的TF坐标位置
添加TF坐标,将左面robotmodel选项取消
方法跟上面类似
添加内容
<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>
geometry>
<material name="white">
<color rgba="1 1 1 0.9"/>
material>
visual>
link>
查看显示效果
roslaunch mbot_description display_mbot_base_urdf.launch
方法同上
添加内容
<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>
查看显示效果
roslaunch mbot_description display_mbot_base_urdf.launch
cd ./catkin_ws/src/mbot_description/urdf
sudo gedit mbot_with_camera.urdf
cd ./catkin_ws/src/mbot_description/launch
sudo gedit display_mbot_with_camera_urdf.launch
mbot_with_camera.urdf 文件内容
<robot name="mbot">
<link name="base_link">
<visual>
<origin xyz=" 0 0 0" rpy="0 0 0" />
<geometry>
<cylinder length="0.16" radius="0.20"/>
geometry>
<material name="yellow">
<color rgba="1 0.4 0 1"/>
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"/>
joint>
<link name="left_wheel_link">
<visual>
<origin xyz="0 0 0" rpy="1.5707 0 0" />
<geometry>
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>
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>
<link name="camera_link">
<visual>
<origin xyz=" 0 0 0 " rpy="0 0 0" />
<geometry>
<box size="0.03 0.04 0.04" />
geometry>
<material name="black">
<color rgba="0 0 0 0.95"/>
material>
visual>
link>
<joint name="camera_joint" type="fixed">
<origin xyz="0.17 0 0.10" rpy="0 0 0"/>
<parent link="base_link"/>
<child link="camera_link"/>
joint>
robot>
display_mbot_with_camera_urdf.launch文件内容和display_mbot_base_urdf.launch文件内容基本一致,需要修改urdf相关模型的路径
<param name="robot_description" textfile="$(find mbot_description)/urdf/mbot_with_camera.urdf "/>
查看显示效果
roslaunch mbot_description display_mbot_with_camera_urdf.launch
cd ./catkin_ws/src/mbot_description/urdf
sudo gedit mbot_with_laser.urdf
cd ./catkin_ws/src/mbot_description/launch
sudo gedit display_mbot_with_laser_urdf.launch
mbot_with_laser.urdf文件内容(其他内容跟未添加传感器内容一致)
<link name="laser_link">
<visual>
<origin xyz=" 0 0 0 " rpy="0 0 0" />
<geometry>
<cylinder length="0.05" radius="0.05"/>
geometry>
<material name="black"/>
visual>
link>
<joint name="laser_joint" type="fixed">
<origin xyz="0 0 0.105" rpy="0 0 0"/>
<parent link="base_link"/>
<child link="laser_link"/>
joint>
display_mbot_with_laser_urdf.launch文件内容和display_mbot_urdf.launch文件内容基本一致,需要修改urdf相关模型的路径
<param name="robot_description" textfile="$(find mbot_description)/urdf/mbot_with_laser.urdf " />
查看显示效果
roslaunch mbot_description display_mbot_with_laser_urdf.launch
cd ./catkin_ws/src/mbot_description/urdf
sudo gedit mbot_with_kinect.urdf
cd ./catkin_ws/src/mbot_description/launch
sudo gedit display_mbot_with_kinect_urdf.launch
mbot_with_kinect.urdf文件内容(其他内容跟未添加传感器内容一致)
<link name="kinect_link">
<visual>
<origin xyz="0 0 0" rpy="0 0 1.5708"/>
<geometry>
<mesh filename="package://mbot_description/meshes/kinect.dae" />
geometry>
visual>
link>
<joint name="laser_joint" type="fixed">
<origin xyz="0.15 0 0.11" rpy="0 0 0"/>
<parent link="base_link"/>
<child link="kinect_link"/>
joint>
display_mbot_with_kinect_urdf.launch文件内容和display_mbot_urdf.launch文件内容基本一致,需要修改urdf相关模型的路径
<param name="robot_description" textfile="$(find mbot_description)/urdf/mbot_with_kinect.urdf " />
在meshes文件中创建纹理描述信息。
新建文件名称: kinect.dae
文件下载可以参考该链接(下载需要VIP):
https://download.csdn.net/download/weixin_43262513/10990016
查看显示效果
roslaunch mbot_description display_mbot_with_kinect_urdf.launch
由于无法获得kinect纹理描述信息的文件,所有就无法得到它的显示效果。
urdf文件夹下执行 urdf_to_graphiz+要检查的urdf文件
urdf_to_graphiz mbot_with_camera.urdf
打开生成的pdf文件查看
整个内容比较多,但是有较多部分都是重复的,只有理解到一部分内容,其他的内容可以根据理解部分的内容去理解。
1.URDF机器人建模 理论+实践
2.ROS学习笔记------ROS机器人系统设计-----基础编程 day 7 2019/3/2 帅某(URDF机器人建模,urdf功能包的建立,urdf相关模型建立代码已经上传)
3.圆柱urdf:Could not find the GUI, install the ‘joint_state_publisher_gui’ package.RVIZ成功启动不显示圆柱模型