亚博microros小车-原生ubuntu支持系列:12 URDF 模型
ros2笔记-6.2 使用urdf创建机器人模型_urdf机器人建模-CSDN博客
之前跟小鱼老师大概了解过urdf模型。再贴一下亚博的介绍
4.1、组成部分
link,连杆,可以想象成是人的手臂
joint,关节,可以想象成是人的手肘关节
link与joint的关系:两个link之间通过关节连接起来,想象成手臂有小臂(link)和大臂(link)通过肘关节(joint)连接。
4.1.1、link
1)、简介
在URDF描述性语言中,link是用来描述物理特性的,
描述视觉显示, 标签。
描述碰撞属性, 标签。
描述物理惯性, 标签不常用。
Links还可以描述连杆尺寸(size)\颜色(color)\形状(shape)\惯性矩阵(inertial matrix)\碰撞参数(collision properties)等,每个Link会成为一个坐标系。
3)、标签介绍
origin:描述的是位姿信息; xyz 属性描述的是在大环境中的坐标位置, rpy 属性描述的是自身的姿态。
mess:描述的是link的质量。
inertia:惯性参考系,由于转动惯性矩阵的对称性,只需要6个上三角元素 ixx, ixy, ixz, iyy, iyz, izz作为属性。
geometry:标签描述的是形状; mesh 属性主要的功能是去加载纹理文件的, filename 属性纹理路径的文件地址
material:标签描述的是材质; name 属性为必填项,可以为空,可以重复 。通过【color】标签中的 rgba
属性来描述红、绿、蓝、透明度,中间用空格分隔。
4.1.2、joints
1)、简介
描述两个关节之间的关系,运动位置和速度限制,运动学和动力学属性。关节类型有以下几种:
fixed:固定关节。不允许运动,起连接作用。
continuous:旋转关节。可以持续旋转,没有旋转角度的限制。
revolute:旋转关节。类似于continuous,有旋转角度的限制。
prismatic:滑动关节。沿某一轴线移动,有位置限制。
floating:悬浮关节。具备六个自由度,3T3R。
planar:平面关节。允许在平面正交上方平移或者旋转。
在【joint】标签中 name 属性是 必填项,描述关节的名称,并且是唯一。在【joint】标签中 type 属性,对应填写六大关节类型。
3)、标签介绍
origin:子标签,指的是旋转关节于 parent 所在坐标系的相对位置。
parent,child:parent,child子标签代表的是两个要连接的link;parent是参照物,child围绕着praent旋转。
axis:子标签表示child对应的link围绕哪一个轴(xyz)旋转和述绕固定轴的旋转量。
limit:子标签主要是限制child的。 lower 属性和 upper 属性限制了旋转的弧度范围, effort 属性限制的是转动过程中的受力范围。(正负value值,单位为牛或N), velocity 属性限制了转动时的速度,单位为米/秒或m/s。
mimic:描述该关节与已有关节的关系。
safety_controller:描述安全控制器参数。保护机器人关节的运动。
打开目录看了下,有meshes、urdf 文件夹
meshes:用来保存urdf中引用的机器人模型所需要的三维模型文件,这些文件为.stl格式,根据机器人的运动自由度,将机器人模型分割成了不同部分。其中.stl 无法之间文本查看
urdf:包含了一个roarm.urdf文件,这个文件用来描述meshes中的机器人模型相对位置的机构运动关系。这个urdf 是solidworks导出的。
代码相关
拷贝:
meshes文件夹,urdf文件夹、launch文件夹
src/yahboomcar_description/urdf/新建MicroROS.urdf,代码如下:
<?xml version="1.0" encoding="utf-8"?>
<!-- This URDF was automatically created by SolidWorks to URDF Exporter! Originally created by Stephen Brawner (brawner@gmail.com)
Commit Version: 1.6.0-1-g15f4949 Build Version: 1.6.7594.29634
For more information, please see http://wiki.ros.org/sw_urdf_exporter -->
<robot
name="micro4.0">
<link
name="base_link">
<inertial>
<origin
xyz="-0.0038187037800903 -0.000532399212617988 -0.00668209865413972"
rpy="0 0 0" />
<mass
value="0.222555109690442" />
<inertia
ixx="0.000160582675692647"
ixy="-8.18530574494391E-07"
ixz="-2.74575507729664E-06"
iyy="0.000176217109527607"
iyz="1.64721285063183E-07"
izz="0.000302441932451338" />
</inertial>
<visual>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://yahboomcar_description/meshes/base_link.STL" />
</geometry>
<material
name="">
<color
rgba="1 1 1 1" />
</material>
</visual>
<collision>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://yahboomcar_description/meshes/base_link.STL" />
</geometry>
</collision>
</link>
<link
name="zq_Link">
<inertial>
<origin
xyz="2.84786462870987E-05 0.00150864010556555 -6.41979491855862E-06"
rpy="0 0 0" />
<mass
value="0.0141019725825625" />
<inertia
ixx="2.6630099758609E-06"
ixy="1.26357217848149E-10"
ixz="3.48142402253186E-10"
iyy="4.6848091087889E-06"
iyz="1.13495192666687E-11"
izz="2.66447797487454E-06" />
</inertial>
<visual>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://yahboomcar_description/meshes/zq_Link.STL" />
</geometry>
<material
name="">
<color
rgba="0.647058823529412 0.619607843137255 0.588235294117647 1" />
</material>
</visual>
<collision>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://yahboomcar_description/meshes/zq_Link.STL" />
</geometry>
</collision>
</link>
<joint
name="zq_Joint"
type="continuous">
<origin
xyz="0.0455 0.0675 -0.02125"
rpy="0 0 0" />
<parent
link="base_link" />
<child
link="zq_Link" />
<axis
xyz="0 1 0" />
</joint>
<link
name="yq_Link">
<inertial>
<origin
xyz="2.46503405071305E-05 -0.00150864013768208 1.56400066804556E-05"
rpy="0 0 0" />
<mass
value="0.0141019726622963" />
<inertia
ixx="2.66339752604607E-06"
ixy="-1.22792569566631E-10"
ixz="-7.34799731138498E-10"
iyy="4.68480910880912E-06"
iyz="-3.18889570074274E-11"
izz="2.66409042506092E-06" />
</inertial>
<visual>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://yahboomcar_description/meshes/yq_Link.STL" />
</geometry>
<material
name="">
<color
rgba="0.647058823529412 0.619607843137255 0.588235294117647 1" />
</material>
</visual>
<collision>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://yahboomcar_description/meshes/yq_Link.STL" />
</geometry>
</collision>
</link>
<joint
name="yq_Joint"
type="continuous">
<origin
xyz="0.0455 -0.0675 -0.02125"
rpy="0 0 0" />
<parent
link="base_link" />
<child
link="yq_Link" />
<axis
xyz="0 -1 0" />
</joint>
<link
name="yh_Link">
<inertial>
<origin
xyz="-3.70764732487289E-06 -0.00150864010086474 -2.89569007898387E-05"
rpy="0 0 0" />
<mass
value="0.0141019725703797" />
<inertia
ixx="2.66453003257312E-06"
ixy="5.38819271008195E-11"
ixz="-2.05112988374728E-10"
iyy="4.68480910877904E-06"
iyz="1.14855312609176E-10"
izz="2.66295791816006E-06" />
</inertial>
<visual>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://yahboomcar_description/meshes/yh_Link.STL" />
</geometry>
<material
name="">
<color
rgba="0.647058823529412 0.619607843137255 0.588235294117647 1" />
</material>
</visual>
<collision>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://yahboomcar_description/meshes/yh_Link.STL" />
</geometry>
</collision>
</link>
<joint
name="yh_Joint"
type="continuous">
<origin
xyz="-0.0495 -0.0675 -0.02125"
rpy="0 0 0" />
<parent
link="base_link" />
<child
link="yh_Link" />
<axis
xyz="0 -1 0" />
</joint>
<link
name="zh_Link">
<inertial>
<origin
xyz="2.71005454374126E-05 0.00150864011455075 -1.08539409463503E-05"
rpy="0 0 0" />
<mass
value="0.0141019726113614" />
<inertia
ixx="2.66315588150881E-06"
ixy="1.26558270834104E-10"
ixz="5.60449660674614E-10"
iyy="4.68480910884624E-06"
iyz="-8.82832301592923E-12"
izz="2.66433206935428E-06" />
</inertial>
<visual>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://yahboomcar_description/meshes/zh_Link.STL" />
</geometry>
<material
name="">
<color
rgba="0.647058823529412 0.619607843137255 0.588235294117647 1" />
</material>
</visual>
<collision>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://yahboomcar_description/meshes/zh_Link.STL" />
</geometry>
</collision>
</link>
<joint
name="zh_Joint"
type="continuous">
<origin
xyz="-0.0495 0.0675 -0.02125"
rpy="0 0 0" />
<parent
link="base_link" />
<child
link="zh_Link" />
<axis
xyz="0 1 0" />
</joint>
<link
name="imu_Link">
<inertial>
<origin
xyz="-0.0316761324986627 0.00132159782250217 -0.000479349648167576"
rpy="0 0 0" />
<mass
value="0.0132101454078263" />
<inertia
ixx="2.09255982058915E-06"
ixy="-1.5860144299643E-08"
ixz="-3.27485068549135E-10"
iyy="4.73790359695282E-06"
iyz="-2.29375131893769E-10"
izz="6.79434472621533E-06" />
</inertial>
<visual>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://yahboomcar_description/meshes/imu_Link.STL" />
</geometry>
<material
name="">
<color
rgba="0.149019607843137 0.149019607843137 0.149019607843137 1" />
</material>
</visual>
<collision>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://yahboomcar_description/meshes/imu_Link.STL" />
</geometry>
</collision>
</link>
<joint
name="imu_Joint"
type="fixed">
<origin
xyz="-0.002999 -0.0030001 0.031701"
rpy="0 0 0" />
<parent
link="base_link" />
<child
link="imu_Link" />
<axis
xyz="0 0 0" />
</joint>
<link
name="radar_Link">
<inertial>
<origin
xyz="2.50028066700073E-05 9.8943368066196E-05 -0.0175251744352531"
rpy="0 0 0" />
<mass
value="0.0384696758414604" />
<inertia
ixx="8.81880784590578E-06"
ixy="-1.66165059019566E-07"
ixz="-1.11024960466139E-07"
iyy="1.44967275960782E-05"
iyz="-3.88415222298422E-08"
izz="2.24335777017028E-05" />
</inertial>
<visual>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://yahboomcar_description/meshes/radar_Link.STL" />
</geometry>
<material
name="">
<color
rgba="0.180392156862745 0.180392156862745 0.180392156862745 1" />
</material>
</visual>
<collision>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://yahboomcar_description/meshes/radar_Link.STL" />
</geometry>
</collision>
</link>
<joint
name="radar_Joint"
type="fixed">
<origin
xyz="0 0 0.078933557468359"
rpy="0 0 0" />
<parent
link="base_link" />
<child
link="radar_Link" />
<axis
xyz="0 0 0" />
</joint>
<link
name="jq1_Link">
<inertial>
<origin
xyz="0.0110585433790032 -0.00605208841063553 0.015781881952638"
rpy="0 0 0" />
<mass
value="0.0115074341427154" />
<inertia
ixx="1.61581689683415E-06"
ixy="1.00926034806027E-09"
ixz="-2.6905085628935E-07"
iyy="9.62368700578607E-07"
iyz="7.36350494885753E-09"
izz="1.35577194148353E-06" />
</inertial>
<visual>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://yahboomcar_description/meshes/jq1_Link.STL" />
</geometry>
<material
name="">
<color
rgba="0.776470588235294 0.756862745098039 0.737254901960784 1" />
</material>
</visual>
<collision>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://yahboomcar_description/meshes/jq1_Link.STL" />
</geometry>
</collision>
</link>
<joint
name="jq1_Joint"
type="revolute">
<origin
xyz="0.064 0 0.014"
rpy="0 0 0" />
<parent
link="base_link" />
<child
link="jq1_Link" />
<axis
xyz="0 0 1" />
<limit
lower="-1.57"
upper="1.57"
effort="0"
velocity="0" />
</joint>
<link
name="jq2_Link">
<inertial>
<origin
xyz="0.0135058163511177 0.000857671482029795 0.00288177408889561"
rpy="0 0 0" />
<mass
value="0.0133313425901211" />
<inertia
ixx="1.96303534926057E-06"
ixy="3.68224074620386E-09"
ixz="2.60821852145315E-07"
iyy="1.5250310537691E-06"
iyz="5.421881574463E-09"
izz="1.9926579435283E-06" />
</inertial>
<visual>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://yahboomcar_description/meshes/jq2_Link.STL" />
</geometry>
<material
name="">
<color
rgba="0.298039215686275 0.298039215686275 0.298039215686275 1" />
</material>
</visual>
<collision>
<origin
xyz="0 0 0"
rpy="0 0 0" />
<geometry>
<mesh
filename="package://yahboomcar_description/meshes/jq2_Link.STL" />
</geometry>
</collision>
</link>
<joint
name="jq2_Joint"
type="revolute">
<origin
xyz="0.016864 8.4892E-05 0.023959"
rpy="0 0 0" />
<parent
link="jq1_Link" />
<child
link="jq2_Link" />
<axis
xyz="0.0037845 -0.99999 0" />
<limit
lower="-1.57"
upper="1.57"
effort="0"
velocity="0" />
</joint>
</robot>
from ament_index_python.packages import get_package_share_path
from launch import LaunchDescription
from launch.actions import DeclareLaunchArgument
from launch.substitutions import Command, LaunchConfiguration
from launch_ros.actions import Node
from launch_ros.parameter_descriptions import ParameterValue
def generate_launch_description():
urdf_tutorial_path = get_package_share_path('yahboomcar_description')
default_model_path = urdf_tutorial_path / 'urdf/MicroROS.urdf'
model_arg = DeclareLaunchArgument(name='model', default_value=str(default_model_path),
description='Absolute path to robot urdf file')
robot_description = ParameterValue(Command(['xacro ', LaunchConfiguration('model')]),
value_type=str)
robot_state_publisher_node = Node(
package='robot_state_publisher',
executable='robot_state_publisher',
parameters=[{'robot_description': robot_description}]
)
joint_state_publisher_gui_node = Node(
package='joint_state_publisher_gui',
executable='joint_state_publisher_gui'
)
tf_base_footprint_to_base_link = Node(
package='tf2_ros',
executable='static_transform_publisher',
arguments=['0', '0', '0.05', '0.0', '0.0', '0.0', 'base_footprint', 'base_link'],
)
return LaunchDescription([
model_arg,
joint_state_publisher_gui_node,
robot_state_publisher_node,
tf_base_footprint_to_base_link
])
-
model_arg:加载模型参数,加载的模型为MicroROS.urdf
-
joint_state_publisher_gui_node:发布sensor_msgs/JointState消息
-
robot_state_publisher_node:机器人状态发布
-
tf_base_footprint_to_base_link:发布base_footprint到base_link的静态变换
修改setup.py,增加urdf跟meshes文件夹拷贝。
安装下依赖:
sudo apt install ros-$ROS_DISTRO-joint-state-publisher-gui
运行:
ros2 launch yahboomcar_description display_launch.py
rivz2
如果提示:
[ERROR] [1737795000.757657365] [rviz2]: Error retrieving file [package://yahboomcar_description/meshes/zq_Link.STL]: Package [yahboomcar_description] does not exist
需要重新配置下环境变量。
进入rviz,选择将【Fixed Frame】改成base_linke,即可显示小车模型,
这是带TF模型
可见这种软件导出的urdf模型,比直接定义几何体形状精确多了。基本上1:1复原了真实小车。