我有一个项目,我想在其中包含两个模型:mir (https://github.com/DFKI-NI/mir_robot) 和 ur10 (https://github.com/ros-industrial/通用机器人)。
我的目标是,将 ur10 固定在 mir 顶部。
到目前为止我所做的:
现在,在我的工作区中,我有 mir 和 ur10 的描述,以及 Gazebo 的启动文件和世界文件。
我可以轻松地将 ur10 臂放置在 mir 顶部,但当然它不是固定的。在研究这个问题时,我发现建议的方法是在它们之间添加固定关节。
所以,在我的世界文件中我添加了
<sdf version='1.7'>
<world name='default'>
<-- sun, ground plane etc. -->
<model name='mir'>
<-- all the specification for the mir robot I obtained from the demo -->
<joint name='connecting_joint' type='fixed'>
<parent>base_footprint</parent>
<child>ur10::base</child>
<pose> 0 0 0 0 0 0</pose>
</joint>
</model>
<model name='ur10'>
<-- all the specification for the ur10 robot -->
</model>
</world>
</sdf>
当我现在打开 Gazebo 时,该关节出现在 mir 机器人的关节列表中。但是固定不起作用,ur10还是掉下来了。
然后我转向 Gazebo 中的模型编辑器。但由于我无法同时编辑两个模型,因此我无法在它们之间添加关节。当我添加一个盒子并在它和 mir 之间添加固定接头时,它工作完美。
我也读过有关模型嵌套的内容,但这似乎只适用于 Gazebo Classic。另外,如果固定关节是正确的方法,我想这样做。
如果有人能告诉我,我做错了什么,或者还需要做什么才能完成这项工作,我将不胜感激。
看起来您的 URDF/SDF 组合是正确的。但是,您添加到世界文件中的关节需要包含在机器人 URDF 描述本身中。
世界文件不是定义关节的正确位置,因为它不知道您使用 URDF 定义的模型。 Gazebo 中的世界文件用于指定在模拟中初始加载对象、模型、物理参数、光源等的方式。另一方面,ROS 中使用 URDF (XML) 格式表示机器人模型。
话虽这么说,您需要将该关节添加到 URDF 文件中,以便指定
mir
和 ur10
之间的连接。
这是一个如何在 URDF.xml 中执行此操作的简单示例:
<robot name="mir_ur10">
<include filename="$(find mir_description)/urdf/mir.urdf.xacro"/>
<include filename="$(find ur_description)/urdf/ur10.urdf.xacro"/>
<link name="base_footprint"/>
<link name="world"/>
<joint name='connecting_joint' type='fixed'>
<origin xyz="0.5 0 0.36" rpy="0 0 0"/> <!--Adjust the origin as per your need-->
<parent link="base_footprint"/> <!--Parent link-->
<child link="ur10::base"/> <!--Child link-->
</joint>
</robot>
此示例假设
mir
机器人的 URDF 名为 mir.urdf.xacro
且位于名为 mir_description
的包中,并且 ur10
机器人的 URDF 名为 ur10.urdf.xacro
且位于名为 ur_description
的包中。确保根据您的设置将这些值替换为实际名称和位置。
然后,您需要将这个组合的 URDF 加载到 ROS 参数服务器中并在 Gazebo 中生成它。
以下是如何操作的示例:
<?xml version="1.0"?>
<launch>
<param name="robot_description"
command="$(find xacro)/xacro --inorder $(find your_package)/urdf/mir_ur10.urdf.xacro"
/>
<node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model"
args="-param robot_description -urdf -model mir_ur10"
/>
</launch>
这个
launch
文件首先读取mir_ur10.urdf.xacro
并将其加载到ROS参数服务器中名为“robot_description”的参数下。然后它使用 gazebo_ros
的 spawn_model
节点将机器人模型生成到 Gazebo 中。