Gazebo 中为地面和车轮添加摩擦属性

Gazebo 中为地面和车轮添加摩擦属性

Link friction properties not applied from URDF to Gazebo

SDFormat Specification

Adding friction to model wheels

Gazebo中模型自行滑动(后溜)的原因探究

移动机器人在仿真时,一旦以较大的速度启动,就会翘头导致翻车

考虑是没有地面摩擦力,因此尝试地面和车轮添加摩擦属性

地面的摩擦系数在 SDF 文件中配置,参考 cafe.world 编辑 empty.world

<sdf version='1.6'>
  <world name='default'>
    <model name='ground_plane'>
      <static>1</static>
      <link name='link'>
        <collision name='collision'>
          <geometry>
            <plane>
              <normal>0 0 1</normal>
              <size>100 100</size>
            </plane>
          </geometry>
          <surface>
            <friction>
              <ode>
                <mu>1</mu>
                <mu2>0.9</mu2>
              </ode>
              <torsional>
                <ode/>
              </torsional>
            </friction>
            <contact>
              <ode/>
            </contact>
            <bounce/>
          </surface>
          <max_contacts>10</max_contacts>
        </collision>
        <visual name='visual'>
          <cast_shadows>0</cast_shadows>
          <geometry>
            <plane>
              <normal>0 0 1</normal>
              <size>100 100</size>
            </plane>
          </geometry>
          <material>
            <script>
              <uri>file://media/materials/scripts/gazebo.material</uri>
              <name>Gazebo/Grey</name>
            </script>
          </material>
        </visual>
        <self_collide>0</self_collide>
        <kinematic>0</kinematic>
      </link>
    </model>
    <light name='sun' type='directional'>
      <cast_shadows>1</cast_shadows>
      <pose frame=''>0 0 10 0 -0 0</pose>
      <diffuse>0.8 0.8 0.8 1</diffuse>
      <specular>0.2 0.2 0.2 1</specular>
      <attenuation>
        <range>1000</range>
        <constant>0.9</constant>
        <linear>0.01</linear>
        <quadratic>0.001</quadratic>
      </attenuation>
      <direction>-0.5 0.1 -0.9</direction>
    </light>
    <gravity>0 0 -9.8</gravity>
    <magnetic_field>6e-06 2.3e-05 -4.2e-05</magnetic_field>
    <atmosphere type='adiabatic'/>
    <physics name='default_physics' default='0' type='ode'>
      <max_step_size>0.001</max_step_size>
      <real_time_factor>1</real_time_factor>
      <real_time_update_rate>1000</real_time_update_rate>
    </physics>
    <scene>
      <ambient>0.4 0.4 0.4 1</ambient>
      <background>0.7 0.7 0.7 1</background>
      <shadows>1</shadows>
    </scene>
    <spherical_coordinates>
      <surface_model>EARTH_WGS84</surface_model>
      <latitude_deg>0</latitude_deg>
      <longitude_deg>0</longitude_deg>
      <elevation>0</elevation>
      <heading_deg>0</heading_deg>
    </spherical_coordinates>
    </world>
</sdf>
  • <surface>: 定义碰撞元素的物理属性
    • <friction>: 描述碰撞表面的摩擦属性
      • <ode>: 使用ODE作为物理引擎
      • <mu>1.0</mu>: 静摩擦系数
      • <mu2>1.0</mu2>: 动摩擦系数
    • <contact>: 描述碰撞元素的接触属性
  • <max_contacts>10</max_contacts>: 设置最大接触数

在URDF中配置链接(link)的摩擦属性可以使用 <gazebo> 元素,其中包含 <mu1><mu2> 元素来指定静摩擦系数和动摩擦系数

<link name="my_link">
  <!-- 其他链接属性 -->

  <gazebo>
    <mu1>0.5</mu1> <!-- 静摩擦系数 -->
    <mu2>0.3</mu2> <!-- 动摩擦系数 -->
  </gazebo>

  <!-- 其他链接元素,如碰撞、视觉等 -->
</link>

为地面和车轮添加摩擦属性后效果几乎没有,将整车质量由 100kg 调整为 150kg,并且将 base_linksteer_link 的重心下移后,在 0.5m/s 及以下速度启动不会有翘头现象

### 创建配置Gazebo中的机器人轮子 #### 定义URDF文件结构 为了在Gazebo中创建并配置机器人的轮子,首先需要定义好统一机器人描述格式(URDF)。这涉及到编写XML形式的文件来指定机械臂、底盘及其组件的位置属性。对于轮子而言,在`<robot>`标签内部添加相应的关节(joint)与链接(link),以表示物理上连接的方式。 ```xml <link name="base_link"> <!-- Base link properties --> </link> <!-- Define the wheel links and joints here --> <link name="left_wheel"/> <joints> <joint name="left_wheel_joint" type="continuous"> <parent link="base_link"/> <child link="left_wheel"/> <origin xyz="0.2 0.17 0" rpy="0 0 0"/> <axis xyz="0 1 0"/> </joint> </links> ``` 上述代码片段展示了如何通过设置父级链路(base_link)子级链路(left_wheel)之间的相对位置(`xyz`)及旋转角度(`rpy`)来建立左轮与其载体间的关联[^2]。 #### 配置物理特性 为了让轮子能够在仿真实验中有合理的动态行为表现,还需进一步设定其质量(mass)、惯性(inertia matrix)参数,并调整摩擦系数(friction parameters)等物理性质: ```xml <link name="right_wheel"> <inertial> <mass value="0.5"/> <inertia ixx="0.001" ixy="0" ixz="0" iyy="0.001" iyz="0" izz="0.001"/> </inertial> <collision> <geometry> <cylinder length="0.05" radius="0.08"/> </geometry> <surface> <friction> <ode mu="1.0" mu2="1.0"/> </friction> </surface> </collision> <visual> ... </visual> </link> ``` 此部分设置了右轮的质量为0.5千克,采用圆柱形几何形状作为碰撞检测模型,并指定了ODE引擎下的滚动平动摩擦力矩mumu2均为1.0,从而确保轮子能够稳定地接触地面并提供足够的抓地能力[^3]。 #### 添加驱动机制 最后一步是实现轮子的动力传动功能。可以通过插件(plugin)的形式引入控制器(Controller),比如差速驱动(Differential Drive Controller),它允许用户发送速度指令给前后轴两侧的不同步电机,进而完成直线行驶或转向动作: ```xml <gazebo reference="base_footprint"> <plugin filename="libgazebo_ros_diff_drive.so" name="diff_drive_controller"> <alwaysOn>true</alwaysOn> <updateRate>100.0</updateRate> <leftJoint>left_wheel_joint</leftJoint> <rightJoint>right_wheel_joint</rightJoint> <wheelSeparation>0.49</wheelSeparation> <wheelDiameter>0.16</wheelDiameter> <torque>5</torque> <commandTopic>/cmd_vel</commandTopic> <odometryTopic>/odom</odometryTopic> <odometryFrame>odom</odometryFrame> <robotBaseFrame>base_footprint</robotBaseFrame> </plugin> </gazebo> ``` 这段配置使得ROS节点可通过/cmd_vel话题向Gazebo传递线性角速度命令,同时接收来自/odom话题的姿态估计数据更新[^1]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Prejudices

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值