1. 平移摩擦
Gazebo的物理引擎(如ODE,Bullet,Simbody,DART)都有不同的摩擦模型,摩擦力参数列表可参见传送门。
假设使用的默认物理引擎ODE
摩擦力的工作原理
ODE中由两部分组成,mu
和mu2
,ODE将自动计算第一、第二摩擦方向:
mu
是第一摩擦方向的库伦摩擦系数mu2
是垂直于第一摩擦方向的第二摩擦方向摩擦系数
两个对象发生碰撞,Gazebo将从两个对象中选择最小的mu
和mu2
。
mu
和mu2
的范围为任何非负数,where,0表示无摩擦接触,较大值表示具有无限摩擦的表面。
各种材料的摩擦特性可从工程工具箱获取
SDF中指定摩擦
栗子1:
<model name="box">
<pose>0 0 0.5 0 0 0</pose>
<link name="link">
<collision name="collision">
<geometry>
<box>
<size>1 1 1</size>
</box>
</geometry>
<surface>
<!--###########################-->
<friction>
<ode>
<mu>0.01</mu>
<mu2>0.01</mu2>
</ode>
</friction>
<!--###########################-->
</surface>
</collision>
<visual name="visual">
<geometry>
<box>
<size>1 1 1</size>
</box>
</geometry>
</visual>
</link>
</model>
栗子2:
<sdf version="1.4">
<world name="default">
<scene>
<ambient>1.000000 1.000000 1.000000 1.000000</ambient>
<background>0.700000 0.700000 0.700000 1.000000</background>
<shadows>1</shadows>
</scene>
<physics type="ode">
<gravity>0.000000 -1.000000 -1.000000</gravity>
<ode>
<solver>
<type>quick</type>
<iters>50</iters>
<precon_iters>0</precon_iters>
<sor>1.300000</sor>
</solver>
<constraints>
<cfm>0.000000</cfm>
<erp>0.200000</erp>
<contact_max_correcting_vel>100.000000</contact_max_correcting_vel>
<contact_surface_layer>0.001000</contact_surface_layer>
</constraints>
</ode>
<real_time_update_rate>0.000000</real_time_update_rate>
<max_step_size>0.001000</max_step_size>
</physics>
<model name="gplane">
<pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000</pose>
<link name="plane">
<pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000</pose>
<collision name="plane">
<pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000</pose>
<geometry>
<plane>
<normal>0.000000 0.000000 1.000000</normal>
</plane>
</geometry>
<surface>
<friction>
<ode>
<mu>50.000000</mu>
<mu2>50.000000</mu2>
<fdir1>0.000000 0.000000 0.000000</fdir1>
<slip1>0.000000</slip1>
<slip2>0.000000</slip2>
</ode>
</friction>
<bounce>
<restitution_coefficient>0.000000</restitution_coefficient>
<threshold>100000.000000</threshold>
</bounce>
<contact>
<ode>
<soft_cfm>0.000000</soft_cfm>
<soft_erp>0.200000</soft_erp>
<kp>1000000000.000000</kp>
<kd>1.000000</kd>
<max_vel>100.000000</max_vel>
<min_depth>0.001000</min_depth>
</ode>
</contact>
</surface>
<laser_retro>0.000000</laser_retro>
</collision>
<gravity>1</gravity>
<self_collide>0</self_collide>
<kinematic>0</kinematic>
</link>
<static>1</static>
</model>
<model name="box_01_model">
<allow_auto_disable>0</allow_auto_disable>
<pose>2.000000 8.000000 0.500000 0.000000 -0.000000 0.000000</pose>
<link name="box_01_body">
<pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000</pose>
<inertial>
<pose>0.000000 0.000000 -0.500000 0.000000 -0.000000 0.000000</pose>
<inertia>
<ixx>10.000000</ixx>
<ixy>0.000000</ixy>
<ixz>0.000000</ixz>
<iyy>10.000000</iyy>
<iyz>0.000000</iyz>
<izz>10.000000</izz>
</inertia>
<mass>1.000000</mass>
</inertial>
<collision name="box_01_geom">
<pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000</pose>
<geometry>
<box>
<size>1.000000 1.000000 1.000000</size>
</box>
</geometry>
<surface>
<friction>
<ode>
<mu>0.998000</mu>
<mu2>0.998000</mu2>
<fdir1>0.000000 0.000000 0.000000</fdir1>
<slip1>0.000000</slip1>
<slip2>0.000000</slip2>
</ode>
</friction>
<bounce>
<restitution_coefficient>0.000000</restitution_coefficient>
<threshold>100000.000000</threshold>
</bounce>
<contact>
<ode>
<soft_cfm>0.000000</soft_cfm>
<soft_erp>0.200000</soft_erp>
<kp>100000.000000</kp>
<kd>1.000000</kd>
<max_vel>100.000000</max_vel>
<min_depth>0.001000</min_depth>
</ode>
</contact>
</surface>
<laser_retro>0.000000</laser_retro>
</collision>
<visual name="box_01_geom_visual">
<pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000</pose>
<geometry>
<box>
<size>1.000000 1.000000 1.000000</size>
</box>
</geometry>
<material>
<script>Gazebo/Rocky</script>
</material>
<cast_shadows>1</cast_shadows>
<laser_retro>0.000000</laser_retro>
<transparency>0.000000</transparency>
</visual>
<gravity>1</gravity>
<self_collide>0</self_collide>
<kinematic>0</kinematic>
</link>
<static>0</static>
</model>
<model name="box_02_model">
<allow_auto_disable>0</allow_auto_disable>
<pose>4.000000 8.000000 0.500000 0.000000 -0.000000 0.000000</pose>
<link name="box_02_body">
<pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000</pose>
<inertial>
<pose>0.000000 0.000000 -0.500000 0.000000 -0.000000 0.000000</pose>
<inertia>
<ixx>10.000000</ixx>
<ixy>0.000000</ixy>
<ixz>0.000000</ixz>
<iyy>10.000000</iyy>
<iyz>0.000000</iyz>
<izz>10.000000</izz>
</inertia>
<mass>1.000000</mass>
</inertial>
<collision name="box_02_geom">
<pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000</pose>
<geometry>
<box>
<size>1.000000 1.000000 1.000000</size>
</box>
</geometry>
<surface>
<friction>
<ode>
<mu>0.998500</mu>
<mu2>0.998500</mu2>
<fdir1>0.000000 0.000000 0.000000</fdir1>
<slip1>0.000000</slip1>
<slip2>0.000000</slip2>
</ode>
</friction>
<bounce>
<restitution_coefficient>0.000000</restitution_coefficient>
<threshold>100000.000000</threshold>
</bounce>
<contact>
<ode>
<soft_cfm>0.000000</soft_cfm>
<soft_erp>0.200000</soft_erp>
<kp>100000.000000</kp>
<kd>1.000000</kd>
<max_vel>100.000000</max_vel>
<min_depth>0.001000</min_depth>
</ode>
</contact>
</surface>
<laser_retro>0.000000</laser_retro>
</collision>
<visual name="box_02_geom_visual">
<pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000</pose>
<geometry>
<box>
<size>1.000000 1.000000 1.000000</size>
</box>
</geometry>
<material>
<script>Gazebo/Rocky</script>
</material>
<cast_shadows>1</cast_shadows>
<laser_retro>0.000000</laser_retro>
<transparency>0.000000</transparency>
</visual>
<gravity>1</gravity>
<self_collide>0</self_collide>
<kinematic>0</kinematic>
</link>
<static>0</static>
</model>
<model name="box_03_model">
<allow_auto_disable>0</allow_auto_disable>
<pose>6.000000 8.000000 0.500000 0.000000 -0.000000 0.000000</pose>
<link name="box_03_body">
<pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000</pose>
<inertial>
<pose>0.000000 0.000000 -0.500000 0.000000 -0.000000 0.000000</pose>
<inertia>
<ixx>10.000000</ixx>
<ixy>0.000000</ixy>
<ixz>0.000000</ixz>
<iyy>10.000000</iyy>
<iyz>0.000000</iyz>
<izz>10.000000</izz>
</inertia>
<mass>1.000000</mass>
</inertial>
<collision name="box_03_geom">
<pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000</pose>
<geometry>
<box>
<size>1.000000 1.000000 1.000000</size>
</box>
</geometry>
<surface>
<friction>
<ode>
<mu>0.999000</mu>
<mu2>0.999000</mu2>
<fdir1>0.000000 0.000000 0.000000</fdir1>
<slip1>0.000000</slip1>
<slip2>0.000000</slip2>
</ode>
</friction>
<bounce>
<restitution_coefficient>0.000000</restitution_coefficient>
<threshold>100000.000000</threshold>
</bounce>
<contact>
<ode>
<soft_cfm>0.000000</soft_cfm>
<soft_erp>0.200000</soft_erp>
<kp>100000.000000</kp>
<kd>1.000000</kd>
<max_vel>100.000000</max_vel>
<min_depth>0.001000</min_depth>
</ode>
</contact>
</surface>
<laser_retro>0.000000</laser_retro>
</collision>
<visual name="box_03_geom_visual">
<pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000</pose>
<geometry>
<box>
<size>1.000000 1.000000 1.000000</size>
</box>
</geometry>
<material>
<script>Gazebo/Rocky</script>
</material>
<cast_shadows>1</cast_shadows>
<laser_retro>0.000000</laser_retro>
<transparency>0.000000</transparency>
</visual>
<gravity>1</gravity>
<self_collide>0</self_collide>
<kinematic>0</kinematic>
</link>
<static>0</static>
</model>
<model name="box_04_model">
<allow_auto_disable>0</allow_auto_disable>
<pose>8.000000 8.000000 0.500000 0.000000 -0.000000 0.000000</pose>
<link name="box_04_body">
<pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000</pose>
<inertial>
<pose>0.000000 0.000000 -0.500000 0.000000 -0.000000 0.000000</pose>
<inertia>
<ixx>10.000000</ixx>
<ixy>0.000000</ixy>
<ixz>0.000000</ixz>
<iyy>10.000000</iyy>
<iyz>0.000000</iyz>
<izz>10.000000</izz>
</inertia>
<mass>1.000000</mass>
</inertial>
<collision name="box_04_geom">
<pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000</pose>
<geometry>
<box>
<size>1.000000 1.000000 1.000000</size>
</box>
</geometry>
<surface>
<friction>
<ode>
<mu>0.999500</mu>
<mu2>0.999500</mu2>
<fdir1>0.000000 0.000000 0.000000</fdir1>
<slip1>0.000000</slip1>
<slip2>0.000000</slip2>
</ode>
</friction>
<bounce>
<restitution_coefficient>0.000000</restitution_coefficient>
<threshold>100000.000000</threshold>
</bounce>
<contact>
<ode>
<soft_cfm>0.000000</soft_cfm>
<soft_erp>0.200000</soft_erp>
<kp>100000.000000</kp>
<kd>1.000000</kd>
<max_vel>100.000000</max_vel>
<min_depth>0.001000</min_depth>
</ode>
</contact>
</surface>
<laser_retro>0.000000</laser_retro>
</collision>
<visual name="box_04_geom_visual">
<pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000</pose>
<geometry>
<box>
<size>1.000000 1.000000 1.000000</size>
</box>
</geometry>
<material>
<script>Gazebo/Rocky</script>
</material>
<cast_shadows>1</cast_shadows>
<laser_retro>0.000000</laser_retro>
<transparency>0.000000</transparency>
</visual>
<gravity>1</gravity>
<self_collide>0</self_collide>
<kinematic>0</kinematic>
</link>
<static>0</static>
</model>
<model name="box_05_model">
<allow_auto_disable>0</allow_auto_disable>
<pose>10.000000 8.000000 0.500000 0.000000 -0.000000 0.000000</pose>
<link name="box_05_body">
<pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000</pose>
<inertial>
<pose>0.000000 0.000000 -0.500000 0.000000 -0.000000 0.000000</pose>
<inertia>
<ixx>10.000000</ixx>
<ixy>0.000000</ixy>
<ixz>0.000000</ixz>
<iyy>10.000000</iyy>
<iyz>0.000000</iyz>
<izz>10.000000</izz>
</inertia>
<mass>1.000000</mass>
</inertial>
<collision name="box_05_geom">
<pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000</pose>
<geometry>
<box>
<size>1.000000 1.000000 1.000000</size>
</box>
</geometry>
<surface>
<friction>
<ode>
<mu>1.000000</mu>
<mu2>1.000000</mu2>
<fdir1>0.000000 0.000000 0.000000</fdir1>
<slip1>0.000000</slip1>
<slip2>0.000000</slip2>
</ode>
</friction>
<bounce>
<restitution_coefficient>0.000000</restitution_coefficient>
<threshold>100000.000000</threshold>
</bounce>
<contact>
<ode>
<soft_cfm>0.000000</soft_cfm>
<soft_erp>0.200000</soft_erp>
<kp>100000.000000</kp>
<kd>1.000000</kd>
<max_vel>100.000000</max_vel>
<min_depth>0.001000</min_depth>
</ode>
</contact>
</surface>
<laser_retro>0.000000</laser_retro>
</collision>
<visual name="box_05_geom_visual">
<pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000</pose>
<geometry>
<box>
<size>1.000000 1.000000 1.000000</size>
</box>
</geometry>
<material>
<script>Gazebo/Rocky</script>
</material>
<cast_shadows>1</cast_shadows>
<laser_retro>0.000000</laser_retro>
<transparency>0.000000</transparency>
</visual>
<gravity>1</gravity>
<self_collide>0</self_collide>
<kinematic>0</kinematic>
</link>
<static>0</static>
</model>
<model name="box_06_model">
<allow_auto_disable>0</allow_auto_disable>
<pose>12.000000 8.000000 0.500000 0.000000 -0.000000 0.000000</pose>
<link name="box_06_body">
<pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000</pose>
<inertial>
<pose>0.000000 0.000000 -0.500000 0.000000 -0.000000 0.000000</pose>
<inertia>
<ixx>10.000000</ixx>
<ixy>0.000000</ixy>
<ixz>0.000000</ixz>
<iyy>10.000000</iyy>
<iyz>0.000000</iyz>
<izz>10.000000</izz>
</inertia>
<mass>1.000000</mass>
</inertial>
<collision name="box_06_geom">
<pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000</pose>
<geometry>
<box>
<size>1.000000 1.000000 1.000000</size>
</box>
</geometry>
<surface>
<friction>
<ode>
<mu>1.010000</mu>
<mu2>1.010000</mu2>
<fdir1>0.000000 0.000000 0.000000</fdir1>
<slip1>0.000000</slip1>
<slip2>0.000000</slip2>
</ode>
</friction>
<bounce>
<restitution_coefficient>0.000000</restitution_coefficient>
<threshold>100000.000000</threshold>
</bounce>
<contact>
<ode>
<soft_cfm>0.000000</soft_cfm>
<soft_erp>0.200000</soft_erp>
<kp>100000.000000</kp>
<kd>1.000000</kd>
<max_vel>100.000000</max_vel>
<min_depth>0.001000</min_depth>
</ode>
</contact>
</surface>
<laser_retro>0.000000</laser_retro>
</collision>
<visual name="box_06_geom_visual">
<pose>0.000000 0.000000 0.000000 0.000000 -0.000000 0.000000</pose>
<geometry>
<box>
<size>1.000000 1.000000 1.000000</size>
</box>
</geometry>
<material>
<script>Gazebo/Rocky</script>
</material>
<cast_shadows>1</cast_shadows>
<laser_retro>0.000000</laser_retro>
<transparency>0.000000</transparency>
</visual>
<gravity>1</gravity>
<self_collide>0</self_collide>
<kinematic>0</kinematic>
</link>
<static>0</static>
</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_radius
的use_patch_radius
标签设置为true
,而将surface_radius
设置为false
,或反之。
默认值
coefficient
:和mu,mu2一样,默认值为1.0use_patch_radius
:默认值为true,因此patch_radius
使用。patch_radius
:默认值为0,因此即使coefficient
设置为零,也不会出现扭转摩擦。surface_radius
:默认值为0,因此即使coefficient
设置为零,也不会存在扭转摩擦。
SDF中的设置
<model ...>
...
<link ...>
<collision ...>
...
<surface>
<!--##################################-->
<friction>
<torsional>
<coefficient>1.0</coefficient>
<surface_radius>0.5</surface_radius>
<use_patch_radius>false</use_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>0x01</collide_bitmask>
</contact>
</surface>
</collision>
<visual name="visual"> ... </visual>
</link>
</model>
默认值
每个几何体(包括接地平面)的碰撞位掩码的默认值为0xffff。您可以将高16位用于不想与接地层碰撞的对象以及其他默认对象。
参考文献: