urdf实践:圆形机器人小车

我们进行搭建一个机器人小车的模型实践。

机器人的参数如下:底盘为圆柱形,半径为10cm,高8cm,四轮由两个驱动轮和两个万向支撑轮组成,两个驱动轮半径为3.25cm,轮胎宽度为1.5cm,两个万向轮为球状,半径为0.75cm,底盘离地间距为1.5cm(与万向轮直径一致)。

编写.urdf文件:

<robot name="practice">
 
    <link name="base_footprint">
        <visual>
            <geometry>
                <sphere radius="0.0001" />
            </geometry>
        </visual>
    </link>

    <link name="base_link">
        <visual>
            <geometry>
                <cylinder radius="0.1" length="0.08" />
            </geometry>
            <origin xyz="0 0 0" rpy="0 0 0" />
            <material name="orange">
                <color rgba="0.99 0.6 0.0625 0.5" />
            </material>
        </visual>
    </link>

    <link name="left_wheel">
        <visual>
            <geometry>
                <cylinder radius="0.0325" length="0.015" />
            </geometry>
            <material name="black">
                <color rgba="0 0 0 1" />
            </material>
            <origin xyz="0 0 0" rpy="1.5708 0 0" />
        </visual>
    </link>

    <link name="right_wheel">
        <visual>
            <geometry>
                <cylinder radius="0.0325" length="0.015" />
            </geometry>
            <material name="black">
                <color rgba="0 0 0 1" />
            </material>
            <origin xyz="0 0 0" rpy="1.5708 0 0" />
        </visual>
    </link>


    <link name="front_wheel">
        <visual>
            <geometry>
                <sphere radius="0.0075" />
            </geometry>
            <material name="black">
                <color rgba="0 0 0 1" />
            </material>
        </visual>
    </link>

    <link name="back_wheel">
        <visual>
            <geometry>
                <sphere radius="0.0075" />
            </geometry>
            <material name="black">
                <color rgba="0 0 0 1" />
            </material>
        </visual>
    </link>

    <joint name="link2footprint" type="fixed">
        <parent link="base_footprint" />
        <child link="base_link" />
        <origin xyz="0 0 0.055" rpy="0 0 0" />
    </joint>

    <joint name="left2link" type="continuous">
        <parent link="base_link" />
        <child link="left_wheel" />
        <origin xyz="0 0.1075 -0.0225" rpy="0 0 0" />
        <!--  The y=the radius of the base_link ; the z = the radius of the wheel - (the height of the base_link/2 + the distance to the ground ) -->
        <axis xyz="0 1 0" />
    </joint>

     <joint name="right2link" type="continuous">
        <parent link="base_link" />
        <child link="right_wheel" />
        <origin xyz="0 -0.1075 -0.0225" rpy="0 0 0" />
        <!--  The y = - the radius of the base_link ; the z = the radius of the wheel - (the height of the base_link/2 + the distance to the ground ) -->
        <axis xyz="0 1 0" />
    </joint>

    <joint name="front2link" type="continuous">
        <parent link="base_link" />
        <child link="front_wheel" />
        <origin xyz="0.08 0 -0.0475" rpy="0 0 0" />
        <axis xyz="0 1 0" />
    </joint>

<joint name="back2link" type="continuous">
        <parent link="base_link" />
        <child link="back_wheel" />
        <origin xyz="-0.08 0 -0.0475" rpy="0 0 0" />
        <axis xyz="0 1 0" />
    </joint>

</robot>

PS:注意,轮子的joint中origin.xyz的z数值取值为=车轮半径-(底盘高度的一半+底盘离地高度),这个数值应该是负值。

注意各种车轮的位置和轴的位置以及正负数值。

然后我们再编写.launch文件

<launch>
    <param name="robot_description" textfile="$(find urdf01_rviz)/urdf/urdf/demo05_practice01.urdf" />
    <node pkg="robot_state_publisher" type="robot_state_publisher" name="robot_state_publisher" />
    <node pkg="joint_state_publisher" type="joint_state_publisher" name="joint_state_publisher" />
    <node pkg="joint_state_publisher_gui" type="joint_state_publisher_gui" name="joint_state_publisher_gui" />
    <node pkg="rviz" type="rviz" name="rviz" />
</launch>

然后我们配置环境变量,再roslaunch运行程序。

--------------------------------------------------------------------------------

接下来提供两个urdf工具:

check_urdf [filename]:检查复杂的urdf1文件是否存在语法问题:

如果语法编写正确,那我们会在终端中有如下信息:

robot name is: practice
---------- Successfully Parsed XML ---------------
root Link: base_footprint has 1 child(ren)
    child(1):  base_link
        child(1):  back_wheel
        child(2):  front_wheel
        child(3):  left_wheel
        child(4):  right_wheel

如果有语法错误则会主动报错显示;

urdf_to_graphiz [filename]  :查看urdf模型结构,显示不同link的层级关系,它会在.urdf文件存在的文件夹中生成一个.gv文件和一个pdf文件,可以清晰查看这个关系,由于是图像,会比较便于理解。

注意:使用这些工具之前,需要安装工具,安装命令为:sudo apt install liburdfom-tools。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值