【urdf_tutorials】Building a Movable Robot Model with URDF 用URDF建立移动机器人模型

Building a Movable Robot Model with URDF 用URDF建立移动机器人模型

原文链接: https://wiki.ros.org/urdf/Tutorials/Building a Movable Robot Model with URDF

Description: Learn how to define movable joints in URDF

描述:了解如何在URDF中定义活动关节

Keywords: URDF, Joints

关键词:URDF,关节

Tutorial Level: BEGINNER

教程级别:初学者

Next Tutorial: Adding Physical and Collision Properties to the Model

下一篇教程:向模型添加物理和碰撞特性

In this tutorial, we’re going to revise the R2D2 model we made in the previous tutorial so that it has movable joints. In the previous model, all of the joints were fixed. Now we’ll explore three other important types of joints: continuous, revolute and prismatic.

在本教程中,我们将修改上一教程中创建的R2D2模型,使其具有可移动关节。在以前的模型中,所有关节都是固定的。现在我们将探讨其他三种重要类型的关节:连续关节、旋转关节和棱柱关节。

Make sure you have installed all prerequisites before continuing. See the previous tutorial for information on what is required.

继续之前,请确保已安装所有必备组件。有关所需内容的信息,请参见上一教程。

Again, all of the robot models mentioned in this tutorial can be found in the urdf_tutorial package.

同样,本教程中提到的所有机器人模型都可以在urdf_tutorial包中找到。

Here is the new urdf with flexible joints. You can compare it to the previous version to see everything that has changed, but we’re just going to focus on three example joints.

这是带有柔性接头的新urdf。您可以将其与以前的版本进行比较,以查看所有更改,但我们将只关注三个示例关节。

To visualize and control this model, run the same command as the last tutorial: roslaunch urdf_tutorial display.launch model:=urdf/06-flexible.urdf However now this will also pop up a GUI that allows you to control the values of all the non-fixed joints. Play with the model some and see how it moves. Then, we can take a look at how we accomplished this.

要可视化和控制此模型,请运行与上一教程相同的命令:roslaunch urdf_tutorial display.launch model:=urdf/06-flexible.urdf但是现在这也将弹出一个GUI,允许您控制所有非固定关节的值。玩一下模型,看看它如何移动。然后,我们可以看看我们是如何做到这一点的。

flexible

1 The Head

1
2
3
4
5
6
<joint name="head_swivel" type="continuous">
<parent link="base_link"/>
<child link="head"/>
<axis xyz="0 0 1"/>
<origin xyz="0 0 0.3"/>
</joint>

The connection between the body and the head is a continuous joint, meaning that it can take on any angle from negative infinity to positive infinity. The wheels are also modeled like this, so that they can roll in both directions forever.

The only additional information we have to add is the axis of rotation, here specified by an xyz triplet, which specifies a vector around which the head will rotate. Since we want it to go around the z axis, we specify the vector “0 0 1”.

身体和头部之间的连接是一个连续的关节,这意味着它可以呈现从负无穷大到正无穷大的任何角度。车轮也是这样建模的,因此它们可以永远在两个方向上滚动。
我们必须添加的唯一附加信息是旋转轴,这里由xyz三元组指定,它指定头部将围绕其旋转的向量。因为我们希望它绕z轴旋转,所以我们指定向量“0 0 1”。

2 The Gripper

1
2
3
4
5
6
7
<joint name="left_gripper_joint" type="revolute">
<axis xyz="0 0 1"/>
<limit effort="1000.0" lower="0.0" upper="0.548" velocity="0.5"/>
<origin rpy="0 0 0" xyz="0.2 0.01 0"/>
<parent link="gripper_pole"/>
<child link="left_gripper"/>
</joint>

Both the right and the left gripper joints are modeled as revolute joints. This means that they rotate in the same way that the continuous joints do, but they have strict limits. Hence, we must include the limit tag specifying the upper and lower limits of the joint (in radians). We also must specify a maximum velocity and effort for this joint but the actual values don’t matter for our purposes here.

左右夹持器关节都建模为旋转关节。这意味着它们以与连续关节相同的方式旋转,但它们有严格的限制。因此,我们必须包含指定关节上限和下限(以弧度为单位)的限制标记。我们还必须指定该关节的最大速度和作用力,但实际值对我们的目的来说并不重要。

3 The Gripper Arm

1
2
3
4
5
6
<joint name="gripper_extension" type="prismatic">
<parent link="base_link"/>
<child link="gripper_pole"/>
<limit effort="1000.0" lower="-0.38" upper="0" velocity="0.5"/>
<origin rpy="0 0 0" xyz="0.19 0 0.2"/>
</joint>

The gripper arm is a different kind of joint, namely a prismatic joint. This means that it moves along an axis, not around it. This translational movement is what allows our robot model to extend and retract its gripper arm.

夹持器臂是一种不同类型的关节,即棱柱关节。这意味着它沿着轴移动,而不是围绕轴移动。这种平移运动使我们的机器人模型能够伸展和缩回其夹持臂。

The limits of the prismatic arm are specified in the same way as a revolute joint, except that the units are meters, not radians.

棱柱臂的限制以与旋转关节相同的方式指定,但单位是米,而不是弧度。

4 Other Types of Joints

There are two other kinds of joints that move around in space. Whereas the prismatic joint can only move along one dimension, a planar joint can move around in a plane, or two dimensions. Furthermore, a floating joint is unconstrained, and can move around in any of the three dimensions. These joints cannot be specified by just one number, and therefore aren’t included in this tutorial.

还有两种其他类型的关节可以在空间中移动。虽然棱柱关节只能沿一维移动,但平面关节可以在平面或二维中移动。此外,浮动关节是不受约束的,可以在任意三维空间中移动。这些关节不能仅由一个数字指定,因此不包含在本教程中。

5 Specifying the Pose

As you move the sliders around in the GUI, the model moves in Rviz. How is this done? First the GUI parses the URDF and finds all the non-fixed joints and their limits. Then, it uses the values of the sliders to publish sensor_msgs/JointState messages. Those are then used by robot_state_publisher to calculate all of transforms between the different parts. The resulting transform tree is then used to display all of the shapes in Rviz.

当您在GUI中移动滑块时,模型在Rviz中移动。这是怎么做到的?首先,GUI解析URDF并查找所有非固定关节及其限制。然后,它使用滑块的值发布sensor_msgs/JointState消息。然后,robot_state_publisher使用它们来计算不同部分之间的所有变换。然后,生成的变换树用于显示Rviz中的所有形状。

6 Next steps

Now that you have a visibly functional model, you can add in some physical properties, or start using xacro to simplify your code.

现在您已经有了一个明显的功能模型,您可以添加一些物理属性,或者开始使用xacro来简化代码。