Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

What is the meaning of contacts returned from GetContact (contact sensor)?

When I use Contact sensor in Gazebo 1.3, I am basically using following code.

  // Get all the contacts.
  msgs::Contacts contacts;
  contacts = this->parentSensor->GetContacts();
  for (int i = 0; i < contacts.contact_size(); ++i)
  {
    for (int j = 0; j < contacts.contact(i).position_size(); ++j)
    {
      std::cout << j << "  Position:"
                << contacts.contact(i).position(j).x() << " "
                << contacts.contact(i).position(j).y() << " "
                << contacts.contact(i).position(j).z() << "\n";
    }
  }

The GetContacts function returns many contacts information (in my case, contact_size was 30~50). And each contact includes a bunch of contact positions. I have looked the position data. All contacts includes quite similar position data.

What is the difference between contacts? Is it a group of contact points by position?

I thought if there is two bodies and two contact points between bodies, the contact_size is 2 and each contact includes a bunch of positions that are located in each contact point. Am I correct?

What is the meaning of contacts returned from GetContact (contact sensor)?

When I use Contact sensor in Gazebo 1.3, I am basically using following code.

  // Get all the contacts.
  msgs::Contacts contacts;
  contacts = this->parentSensor->GetContacts();
  for (int i = 0; i < contacts.contact_size(); ++i)
  {
    for (int j = 0; j < contacts.contact(i).position_size(); ++j)
    {
      std::cout << j << "  Position:"
                << contacts.contact(i).position(j).x() << " "
                << contacts.contact(i).position(j).y() << " "
                << contacts.contact(i).position(j).z() << "\n";
    }
  }

The GetContacts 'GetContacts' function returns many contacts information contact informations (in my case, contact_size was 30~50). And each contact includes a bunch of contact positions. I have looked the position data. All contacts includes quite similar position data.

What is the difference between contacts? Is it a group of contact points by position?

I thought if there is two bodies and two contact points between bodies, the contact_size is 2 and each contact includes a bunch of positions that are located in each contact point. Am I correct?

click to hide/show revision 3
Added SDF information and additional question

What is the meaning of contacts returned from GetContact (contact sensor)?

When I use Contact sensor in Gazebo 1.3, I am basically using following code.

  // Get all the contacts.
  msgs::Contacts contacts;
  contacts = this->parentSensor->GetContacts();
  for (int i = 0; i < contacts.contact_size(); ++i)
  {
    for (int j = 0; j < contacts.contact(i).position_size(); ++j)
    {
      std::cout << j << "  Position:"
                << contacts.contact(i).position(j).x() << " "
                << contacts.contact(i).position(j).y() << " "
                << contacts.contact(i).position(j).z() << "\n";
    }
  }

The 'GetContacts' function returns many contact informations (in my case, contact_size was 30~50). And each contact includes a bunch of contact positions. I have looked the position data. All contacts includes quite similar position data.

What is the difference between contacts? Is it a group of contact points by position?

I thought if there is two bodies and two contact points between bodies, the contact_size is 2 and each contact includes a bunch of positions that are located in each contact point. Am I correct?

===== Update 1 ======

I use following two objects

  1. PR2's upper arm part

    <link name='l_upper_arm_roll_link'>
      <self_collide>0</self_collide>
      <gravity>0</gravity>
      <pose>0.050000 0.188000 0.790675 0.000000 -0.000000 0.000000</pose>
      <inertial>
        <mass>6.117690</mass>
        <pose>0.210551 0.016309 -0.000561 0.000000 -0.000000 0.000000</pose>
        <inertia>
          <ixx>0.025306</ixx>
          <ixy>-0.003393</ixy>
          <ixz>0.000608</ixz>
          <iyy>0.084737</iyy>
          <iyz>-0.000200</iyz>
          <izz>0.086016</izz>
        </inertia>
      </inertial>
      <collision name='l_upper_arm_roll_link_geom'>
        <geometry>
          <mesh>
            <uri>model://pr2_arm/meshes/shoulder_v0/upper_arm_roll_L.stl</uri>
          </mesh>
        </geometry>
      </collision>
      <visual name='l_upper_arm_roll_link_geom_visual'>
        <geometry>
          <mesh>
            <uri>model://pr2_arm/meshes/shoulder_v0/upper_arm_roll.stl</uri>
          </mesh>
        </geometry>
      </visual>
      <collision name='l_upper_arm_roll_link_geom_l_upper_arm_link'>
        <geometry>
          <mesh>
            <uri>model://pr2_arm/meshes/upper_arm_v0/upper_arm.stl</uri>
          </mesh>
        </geometry>
      </collision>
      <visual name='l_upper_arm_roll_link_geom_l_upper_arm_link_visual'>
        <geometry>
          <mesh>
            <uri>model://pr2_arm/meshes/upper_arm_v0/upper_arm.dae</uri>
          </mesh>
        </geometry>
      </visual>
      <sensor name='l_upper_arm_roll_tactile_sensor' type=contact>
        <contact>
          <collision>l_upper_arm_roll_link_geom_l_upper_arm_link</collision>
          <topic>__default_topic__</topic>
        </contact>
        <plugin name="ros_tactile_plugin" filename="libros_tactile_plugin.so" />
        <always_on>1</always_on>
        <update_rate>100.0</update_rate>
        <visualize>false</visualize>
      </sensor>
      <velocity_decay/>
    </link>
    
  2. Desk

    <link name="link">
      <inertial>
        <mass>50.0</mass>
      </inertial>
      <collision name="surface">
        <pose>0 0 0.6 0 0 0</pose>
        <geometry>
          <box>
            <size>1.5 0.8 0.03</size>
          </box>
        </geometry>
        <surface>
          <friction>
            <ode>
              <mu>500.000000</mu>
              <mu2>500.000000</mu2>
              <slip1>0.000000</slip1>
              <slip2>0.000000</slip2>
            </ode>
          </friction>
          <contact>
            <ode>
              <soft_cfm>0.04</soft_cfm>
              <soft_erp>0.9</soft_erp>
              <kp>50000.0</kp>
              <kd>1.000</kd>
              <max_vel>10.000000</max_vel>
              <min_depth>0.000000</min_depth>
            </ode>
          </contact>
        </surface>
      </collision>
      <visual name="surface">
        <pose>0 0 0.6 0 0 0</pose>
        <geometry>
          <box>
            <size>1.4 0.8 0.04</size>
          </box>
        </geometry>
        <material>
          <script>
            <uri>file://media/materials/scripts/gazebo.material</uri>
            <name>Gazebo/Wood</name>
          </script>
        </material>
      </visual>
    

As we can see, one is mesh object and another one is a box. Could you kindly answer followings?

  1. Each triangle of the mesh gives one contact object like 'contacts.contact(0)' when a box and the triangle collide.
  2. One contact object like 'contacts.contact(0)' includes several positions like 'contacts.contact(0).position(~)'. The positions are only limited in the collision area between one triangle and a box.