collision_wiki - socrob/mbot_documentation GitHub Wiki

Collisions

It is possible to change the collision box of each object simulated on Gazebo. In this way, the interaction with them will be changed as well. In order to visualize this feature on Gazebo you need to launch the environment and then select the option View >> Collisions on the top menu.

Collision

If you need to change the shape of the collision models you need to access the mbot_simulation_environment package and edit some files. Those files are located on the following path:

mbot_simulation_environments/models/isr-testbed.

Each object has its own folder with all the information necessary to spawn them. For each object/folder, you might find a SDF file. In this file you will be able to add and remove the collision elements. These files are written in XML format with many components relate to different characteristics of the object. One of the tags should be similar to the following:

      <collision name='collision'>
        <laser_retro>0</laser_retro>
        <max_contacts>10</max_contacts>
        <pose frame=''>0.05 0 0.25 0 0 0</pose>
        <geometry>
          <box>
            <size>0.93 1.83 0.37</size>
          </box>
        </geometry>
        <surface>
          <friction>
            <ode>
              <mu>1</mu>
              <mu2>1</mu2>
              <fdir1>0 0 0</fdir1>
              <slip1>0</slip1>
              <slip2>0</slip2>
            </ode>
            <torsional>
              <coefficient>1</coefficient>
              <patch_radius>0</patch_radius>
              <surface_radius>0</surface_radius>
              <use_patch_radius>1</use_patch_radius>
              <ode>
                <slip>0</slip>
              </ode>
            </torsional>
          </friction>
          <bounce>
            <restitution_coefficient>0</restitution_coefficient>
            <threshold>1e+06</threshold>
          </bounce>
          <contact>
            <collide_without_contact>0</collide_without_contact>
            <collide_without_contact_bitmask>1</collide_without_contact_bitmask>
            <collide_bitmask>1</collide_bitmask>
            <ode>
              <soft_cfm>0</soft_cfm>
              <soft_erp>0.2</soft_erp>
              <kp>1e+13</kp>
              <kd>1</kd>
              <max_vel>0.01</max_vel>
              <min_depth>0</min_depth>
            </ode>
            <bullet>
              <split_impulse>1</split_impulse>
              <split_impulse_penetration_threshold>-0.01</split_impulse_penetration_threshold>
              <soft_cfm>0</soft_cfm>
              <soft_erp>0.2</soft_erp>
              <kp>1e+13</kp>
              <kd>1</kd>
            </bullet>
          </contact>
        </surface>
      </collision>

It seems a little bit complex but the only part that needs to be edited, in order to fix a collision-shape issue, is the following:

<pose frame=''>0.05 0 0.25 0 0 0</pose>
<geometry>
  <box>
    <size>0.93 1.83 0.37</size>
  </box>
</geometry>

A collision element encapsulates a geometry that is used to collision checking. This can be a simple shape (which is preferred), or a triangle mesh (which consumes greater resources) (1). The element can be represented by different shapes (2), the most simple and common is BOX. In order to change the shape of the model you will need to edit only the SIZE tag. If necessary, you can fix his pose editing the POSE tag. It is important to say that you are allowed to apply, if necessary, many collision elements in the same file.

The shape of the visual object can be one of the following (3):

*Box: Size attribute contains the three side lengths of the box. The origin of the box is in its center. 
*Cylinder: Specify the radius and length. The origin of the cylinder is in its center. cylinder_coordinates.png 
*Sphere: Specify the radius. The origin of the sphere is in its center. 
*Mesh: A trimesh element specified by a filename, and an optional scale that scales the mesh's axis-aligned-bounding-box. The recommended format for best texture and color support is Collada .dae files, though .stl files are also supported. The mesh file is not transferred between machines referencing the same model. It must be a local file. 
⚠️ **GitHub.com Fallback** ⚠️