Gazebo使用笔记(6) —— 摩擦力特性与碰撞位掩码

文章目录

  • 1. 平移摩擦
        • 摩擦力的工作原理
        • SDF中指定摩擦
  • 2. 转动摩擦
        • 转动摩擦方程:
            • SDF参数
            • 默认值
        • SDF中的设置
  • 3. 碰撞位掩码
        • 介绍
        • 碰撞位掩码设置
        • 默认值

1. 平移摩擦

Gazebo的物理引擎(如ODE,Bullet,Simbody,DART)都有不同的摩擦模型,摩擦力参数列表可参见传送门。

假设使用的默认物理引擎ODE

摩擦力的工作原理

ODE中由两部分组成,mumu2,ODE将自动计算第一、第二摩擦方向:

  • mu是第一摩擦方向的库伦摩擦系数
  • mu2是垂直于第一摩擦方向的第二摩擦方向摩擦系数

两个对象发生碰撞,Gazebo将从两个对象中选择最小的mumu2

mumu2的范围为任何非负数,where,0表示无摩擦接触,较大值表示具有无限摩擦的表面。

各种材料的摩擦特性可从工程工具箱获取

SDF中指定摩擦

栗子1:

<model name="box">
  <pose>0 0 0.5 0 0 0pose>
  <link name="link">
    <collision name="collision">
      <geometry>
        <box>
          <size>1 1 1size>
        box>
      geometry>
      <surface>
 
        <friction>
          <ode>
            <mu>0.01mu>
            <mu2>0.01mu2>
          ode>
        friction>

      surface>
    collision>
    <visual name="visual">
      <geometry>
        <box>
          <size>1 1 1size>
        box>
      geometry>
    visual>
  link>
model>

栗子2:

<sdf version="1.4">
  <world name="default">
    <scene>
      <ambient>1.000000 1.000000 1.000000 1.000000ambient>
      <background>0.700000 0.700000 0.700000 1.000000background>
      <shadows>1shadows>
    scene>
    <physics type="ode">
      <gravity>0.000000 -1.000000 -1.000000gravity>
      <ode>
        <solver>
          <type>quicktype>
          <iters>50iters>
          <precon_iters>0precon_iters>
          <sor>1.300000sor>
        solver>
        <constraints>
          <cfm>0.000000cfm>
          <erp>0.200000erp>
          <contact_max_correcting_vel>100.000000contact_max_correcting_vel>
          <contact_surface_layer>0.001000contact_surface_layer>
        constraints>
      ode>
      <real_time_update_rate>0.000000real_time_update_rate>
      <max_step_size>0.001000max_step_size>
    physics>
    <model name="gplane">
      <pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000pose>
      <link name="plane">
        <pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000pose>
        <collision name="plane">
          <pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000pose>
          <geometry>
            <plane>
              <normal>0.000000 0.000000 1.000000normal>
            plane>
          geometry>
          <surface>
            <friction>
              <ode>
                <mu>50.000000mu>
                <mu2>50.000000mu2>
                <fdir1>0.000000 0.000000 0.000000fdir1>
                <slip1>0.000000slip1>
                <slip2>0.000000slip2>
              ode>
            friction>
            <bounce>
              <restitution_coefficient>0.000000restitution_coefficient>
              <threshold>100000.000000threshold>
            bounce>
            <contact>
              <ode>
                <soft_cfm>0.000000soft_cfm>
                <soft_erp>0.200000soft_erp>
                <kp>1000000000.000000kp>
                <kd>1.000000kd>
                <max_vel>100.000000max_vel>
                <min_depth>0.001000min_depth>
              ode>
            contact>
          surface>
          <laser_retro>0.000000laser_retro>
        collision>
        <gravity>1gravity>
        <self_collide>0self_collide>
        <kinematic>0kinematic>
      link>
      <static>1static>
    model>
    <model name="box_01_model">
      <allow_auto_disable>0allow_auto_disable>
      <pose>2.000000 8.000000 0.500000 0.000000 -0.000000 0.000000pose>
      <link name="box_01_body">
        <pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000pose>
        <inertial>
          <pose>0.000000 0.000000 -0.500000 0.000000 -0.000000 0.000000pose>
          <inertia>
            <ixx>10.000000ixx>
            <ixy>0.000000ixy>
            <ixz>0.000000ixz>
            <iyy>10.000000iyy>
            <iyz>0.000000iyz>
            <izz>10.000000izz>
          inertia>
          <mass>1.000000mass>
        inertial>
        <collision name="box_01_geom">
          <pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000pose>
          <geometry>
            <box>
              <size>1.000000 1.000000 1.000000size>
            box>
          geometry>
          <surface>
            <friction>
              <ode>
                <mu>0.998000mu>
                <mu2>0.998000mu2>
                <fdir1>0.000000 0.000000 0.000000fdir1>
                <slip1>0.000000slip1>
                <slip2>0.000000slip2>
              ode>
            friction>
            <bounce>
              <restitution_coefficient>0.000000restitution_coefficient>
              <threshold>100000.000000threshold>
            bounce>
            <contact>
              <ode>
                <soft_cfm>0.000000soft_cfm>
                <soft_erp>0.200000soft_erp>
                <kp>100000.000000kp>
                <kd>1.000000kd>
                <max_vel>100.000000max_vel>
                <min_depth>0.001000min_depth>
              ode>
            contact>
          surface>
          <laser_retro>0.000000laser_retro>
        collision>
        <visual name="box_01_geom_visual">
          <pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000pose>
          <geometry>
            <box>
              <size>1.000000 1.000000 1.000000size>
            box>
          geometry>
          <material>
            <script>Gazebo/Rockyscript>
          material>
          <cast_shadows>1cast_shadows>
          <laser_retro>0.000000laser_retro>
          <transparency>0.000000transparency>
        visual>
        <gravity>1gravity>
        <self_collide>0self_collide>
        <kinematic>0kinematic>
      link>
      <static>0static>
    model>
    <model name="box_02_model">
      <allow_auto_disable>0allow_auto_disable>
      <pose>4.000000 8.000000 0.500000 0.000000 -0.000000 0.000000pose>
      <link name="box_02_body">
        <pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000pose>
        <inertial>
          <pose>0.000000 0.000000 -0.500000 0.000000 -0.000000 0.000000pose>
          <inertia>
            <ixx>10.000000ixx>
            <ixy>0.000000ixy>
            <ixz>0.000000ixz>
            <iyy>10.000000iyy>
            <iyz>0.000000iyz>
            <izz>10.000000izz>
          inertia>
          <mass>1.000000mass>
        inertial>
        <collision name="box_02_geom">
          <pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000pose>
          <geometry>
            <box>
              <size>1.000000 1.000000 1.000000size>
            box>
          geometry>
          <surface>
            <friction>
              <ode>
                <mu>0.998500mu>
                <mu2>0.998500mu2>
                <fdir1>0.000000 0.000000 0.000000fdir1>
                <slip1>0.000000slip1>
                <slip2>0.000000slip2>
              ode>
            friction>
            <bounce>
              <restitution_coefficient>0.000000restitution_coefficient>
              <threshold>100000.000000threshold>
            bounce>
            <contact>
              <ode>
                <soft_cfm>0.000000soft_cfm>
                <soft_erp>0.200000soft_erp>
                <kp>100000.000000kp>
                <kd>1.000000kd>
                <max_vel>100.000000max_vel>
                <min_depth>0.001000min_depth>
              ode>
            contact>
          surface>
          <laser_retro>0.000000laser_retro>
        collision>
        <visual name="box_02_geom_visual">
          <pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000pose>
          <geometry>
            <box>
              <size>1.000000 1.000000 1.000000size>
            box>
          geometry>
          <material>
            <script>Gazebo/Rockyscript>
          material>
          <cast_shadows>1cast_shadows>
          <laser_retro>0.000000laser_retro>
          <transparency>0.000000transparency>
        visual>
        <gravity>1gravity>
        <self_collide>0self_collide>
        <kinematic>0kinematic>
      link>
      <static>0static>
    model>
    <model name="box_03_model">
      <allow_auto_disable>0allow_auto_disable>
      <pose>6.000000 8.000000 0.500000 0.000000 -0.000000 0.000000pose>
      <link name="box_03_body">
        <pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000pose>
        <inertial>
          <pose>0.000000 0.000000 -0.500000 0.000000 -0.000000 0.000000pose>
          <inertia>
            <ixx>10.000000ixx>
            <ixy>0.000000ixy>
            <ixz>0.000000ixz>
            <iyy>10.000000iyy>
            <iyz>0.000000iyz>
            <izz>10.000000izz>
          inertia>
          <mass>1.000000mass>
        inertial>
        <collision name="box_03_geom">
          <pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000pose>
          <geometry>
            <box>
              <size>1.000000 1.000000 1.000000size>
            box>
          geometry>
          <surface>
            <friction>
              <ode>
                <mu>0.999000mu>
                <mu2>0.999000mu2>
                <fdir1>0.000000 0.000000 0.000000fdir1>
                <slip1>0.000000slip1>
                <slip2>0.000000slip2>
              ode>
            friction>
            <bounce>
              <restitution_coefficient>0.000000restitution_coefficient>
              <threshold>100000.000000threshold>
            bounce>
            <contact>
              <ode>
                <soft_cfm>0.000000soft_cfm>
                <soft_erp>0.200000soft_erp>
                <kp>100000.000000kp>
                <kd>1.000000kd>
                <max_vel>100.000000max_vel>
                <min_depth>0.001000min_depth>
              ode>
            contact>
          surface>
          <laser_retro>0.000000laser_retro>
        collision>
        <visual name="box_03_geom_visual">
          <pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000pose>
          <geometry>
            <box>
              <size>1.000000 1.000000 1.000000size>
            box>
          geometry>
          <material>
            <script>Gazebo/Rockyscript>
          material>
          <cast_shadows>1cast_shadows>
          <laser_retro>0.000000laser_retro>
          <transparency>0.000000transparency>
        visual>
        <gravity>1gravity>
        <self_collide>0self_collide>
        <kinematic>0kinematic>
      link>
      <static>0static>
    model>
    <model name="box_04_model">
      <allow_auto_disable>0allow_auto_disable>
      <pose>8.000000 8.000000 0.500000 0.000000 -0.000000 0.000000pose>
      <link name="box_04_body">
        <pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000pose>
        <inertial>
          <pose>0.000000 0.000000 -0.500000 0.000000 -0.000000 0.000000pose>
          <inertia>
            <ixx>10.000000ixx>
            <ixy>0.000000ixy>
            <ixz>0.000000ixz>
            <iyy>10.000000iyy>
            <iyz>0.000000iyz>
            <izz>10.000000izz>
          inertia>
          <mass>1.000000mass>
        inertial>
        <collision name="box_04_geom">
          <pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000pose>
          <geometry>
            <box>
              <size>1.000000 1.000000 1.000000size>
            box>
          geometry>
          <surface>
            <friction>
              <ode>
                <mu>0.999500mu>
                <mu2>0.999500mu2>
                <fdir1>0.000000 0.000000 0.000000fdir1>
                <slip1>0.000000slip1>
                <slip2>0.000000slip2>
              ode>
            friction>
            <bounce>
              <restitution_coefficient>0.000000restitution_coefficient>
              <threshold>100000.000000threshold>
            bounce>
            <contact>
              <ode>
                <soft_cfm>0.000000soft_cfm>
                <soft_erp>0.200000soft_erp>
                <kp>100000.000000kp>
                <kd>1.000000kd>
                <max_vel>100.000000max_vel>
                <min_depth>0.001000min_depth>
              ode>
            contact>
          surface>
          <laser_retro>0.000000laser_retro>
        collision>
        <visual name="box_04_geom_visual">
          <pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000pose>
          <geometry>
            <box>
              <size>1.000000 1.000000 1.000000size>
            box>
          geometry>
          <material>
            <script>Gazebo/Rockyscript>
          material>
          <cast_shadows>1cast_shadows>
          <laser_retro>0.000000laser_retro>
          <transparency>0.000000transparency>
        visual>
        <gravity>1gravity>
        <self_collide>0self_collide>
        <kinematic>0kinematic>
      link>
      <static>0static>
    model>
    <model name="box_05_model">
      <allow_auto_disable>0allow_auto_disable>
      <pose>10.000000 8.000000 0.500000 0.000000 -0.000000 0.000000pose>
      <link name="box_05_body">
        <pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000pose>
        <inertial>
          <pose>0.000000 0.000000 -0.500000 0.000000 -0.000000 0.000000pose>
          <inertia>
            <ixx>10.000000ixx>
            <ixy>0.000000ixy>
            <ixz>0.000000ixz>
            <iyy>10.000000iyy>
            <iyz>0.000000iyz>
            <izz>10.000000izz>
          inertia>
          <mass>1.000000mass>
        inertial>
        <collision name="box_05_geom">
          <pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000pose>
          <geometry>
            <box>
              <size>1.000000 1.000000 1.000000size>
            box>
          geometry>
          <surface>
            <friction>
              <ode>
                <mu>1.000000mu>
                <mu2>1.000000mu2>
                <fdir1>0.000000 0.000000 0.000000fdir1>
                <slip1>0.000000slip1>
                <slip2>0.000000slip2>
              ode>
            friction>
            <bounce>
              <restitution_coefficient>0.000000restitution_coefficient>
              <threshold>100000.000000threshold>
            bounce>
            <contact>
              <ode>
                <soft_cfm>0.000000soft_cfm>
                <soft_erp>0.200000soft_erp>
                <kp>100000.000000kp>
                <kd>1.000000kd>
                <max_vel>100.000000max_vel>
                <min_depth>0.001000min_depth>
              ode>
            contact>
          surface>
          <laser_retro>0.000000laser_retro>
        collision>
        <visual name="box_05_geom_visual">
          <pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000pose>
          <geometry>
            <box>
              <size>1.000000 1.000000 1.000000size>
            box>
          geometry>
          <material>
            <script>Gazebo/Rockyscript>
          material>
          <cast_shadows>1cast_shadows>
          <laser_retro>0.000000laser_retro>
          <transparency>0.000000transparency>
        visual>
        <gravity>1gravity>
        <self_collide>0self_collide>
        <kinematic>0kinematic>
      link>
      <static>0static>
    model>
    <model name="box_06_model">
      <allow_auto_disable>0allow_auto_disable>
      <pose>12.000000 8.000000 0.500000 0.000000 -0.000000 0.000000pose>
      <link name="box_06_body">
        <pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000pose>
        <inertial>
          <pose>0.000000 0.000000 -0.500000 0.000000 -0.000000 0.000000pose>
          <inertia>
            <ixx>10.000000ixx>
            <ixy>0.000000ixy>
            <ixz>0.000000ixz>
            <iyy>10.000000iyy>
            <iyz>0.000000iyz>
            <izz>10.000000izz>
          inertia>
          <mass>1.000000mass>
        inertial>
        <collision name="box_06_geom">
          <pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000pose>
          <geometry>
            <box>
              <size>1.000000 1.000000 1.000000size>
            box>
          geometry>
          <surface>
            <friction>
              <ode>
                <mu>1.010000mu>
                <mu2>1.010000mu2>
                <fdir1>0.000000 0.000000 0.000000fdir1>
                <slip1>0.000000slip1>
                <slip2>0.000000slip2>
              ode>
            friction>
            <bounce>
              <restitution_coefficient>0.000000restitution_coefficient>
              <threshold>100000.000000threshold>
            bounce>
            <contact>
              <ode>
                <soft_cfm>0.000000soft_cfm>
                <soft_erp>0.200000soft_erp>
                <kp>100000.000000kp>
                <kd>1.000000kd>
                <max_vel>100.000000max_vel>
                <min_depth>0.001000min_depth>
              ode>
            contact>
          surface>
          <laser_retro>0.000000laser_retro>
        collision>
        <visual name="box_06_geom_visual">
          <pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000pose>
          <geometry>
            <box>
              <size>1.000000 1.000000 1.000000size>
            box>
          geometry>
          <material>
            <script>Gazebo/Rockyscript>
          material>
          <cast_shadows>1cast_shadows>
          <laser_retro>0.000000laser_retro>
          <transparency>0.000000transparency>
        visual>
        <gravity>1gravity>
        <self_collide>0self_collide>
        <kinematic>0kinematic>
      link>
      <static>0static>
    model>
  world>
sdf>

2. 转动摩擦

注意:转动摩擦当前仅适用于ODE物理引擎

转动摩擦方程:

转动摩擦的扭矩是根据接触深度和表面半径计算的,具体参考传送门:

T = 3*PI/16 * a * coefficient * N
a = sqrt(R * d)

where,

  • 3*PI/16:常数≈0.589
  • T:由于转动摩擦产生的扭矩
  • N:接触时的法向力
  • 系数:转动摩擦系数,通常与平移摩擦系数mu和mu2相同
  • a:接触面半径(patch_radius in SDF),这是表面之间的接触区域的半径。平面顶部的球体会生成一个圆形的补丁区域,该区域取决于球体半径和接触深度
  • R:接触点表面半径(patch_radius in SDF)
  • d:接触深度

由上可知,与平移摩擦不同,扭转摩擦不仅取决于法向力和摩擦系数。它还取决于表面之间的接触面积。

SDF参数

SDF提供了两种参数化接触表面的方法。 用户可以定义一个patch_radius(上面的a)(与接触深度无关)总是相同的,也可以定义一个surface_radius(上面的R)(与接触深度一起使用)。 请注意,在这两种情况下,用户都为整个曲面指定了一个值,因此为非球形曲面选取值可能需要微调。

要在方法之间进行选择,可以将patch_radiususe_patch_radius标签设置为true,而将surface_radius设置为false,或反之。

默认值
  • coefficient:和mu,mu2一样,默认值为1.0
  • use_patch_radius:默认值为true,因此patch_radius使用。
  • patch_radius:默认值为0,因此即使coefficient设置为零,也不会出现扭转摩擦。
  • surface_radius:默认值为0,因此即使coefficient设置为零,也不会存在扭转摩擦。

SDF中的设置

<model ...>
 ...
  <link ...>
    <collision ...>
     ...
      <surface>

        <friction>
          <torsional>
            <coefficient>1.0coefficient>
            <surface_radius>0.5surface_radius>
            <use_patch_radius>falseuse_patch_radius>
          torsional>
        friction>

       ...
      surface>
    collision>
  link>
model>

测试:

gazebo -u worlds/torsional_friction_demo.world

3. 碰撞位掩码

介绍

位掩码是与某个对象相关联的数字,通常以十六进制指定。

假设对象是碰撞几何。当比较两个位掩码时,通过按位与运算,结果将用于控制所应用的逻辑。

  • BoxA:01
  • BoxB:10
  • BoxC:11
 gazebo -u worlds/shapes_bitmask.world

C(最顶端)→B(中)→A(最底端),仿真结果:boxA和boxB将发生碰撞。但按位及其位掩码将产生零值。这表明,以仿真引擎,碰撞也应该被忽略,其结果是盒B通过BOXA。此时,boxA和boxB都位于同一地点并搁在地面上。同时,boxC从其起始位置下降。BoxC最终会命中boxA和boxB。boxC的位掩码的按位与和以及属于boxA和boxB的位掩码将导致一个大于零的值。这个非零的结果,也被编程语言视为“ true”,它向模拟引擎指示应该生成冲突。结果是boxC将停留在boxA和boxB的顶部。

碰撞位掩码设置

<model name="box">
  <link name="link">
    <collision name="collision">
      <geometry> ... geometry>

      <surface>
        <contact>
          <collide_bitmask>0x01collide_bitmask>
        contact>
      surface>

    collision>
    <visual name="visual"> ... visual>
  link>
model>

默认值

每个几何体(包括接地平面)的碰撞位掩码的默认值为0xffff。您可以将高16位用于不想与接地层碰撞的对象以及其他默认对象。


参考文献:

  • http://gazebosim.org/tutorials?tut=friction&cat=physics
  • http://gazebosim.org/tutorials?tut=torsional_friction&cat=physics
  • http://gazebosim.org/tutorials?tut=collide_bitmask&cat=physics

你可能感兴趣的:(▶,机器人仿真,▶,机器人操作系统ROS/ROS2)