Gazebo | Ignition | Community
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

how to retrieve contact data from engine (NOT MESSAGE)!

how to retrieve contact data directly from physic engine (not in a message).

I tried to use the map structure but this function also use messages.

sensors::SensorPtr sensor = sensors::SensorManager::Instance()->GetSensor(this->model->GetLink("0")->GetSensorName(0));

sensors::ContactSensorPtr contactSensor = boost::dynamic_pointer_cast<sensors::ContactSensor>(sensor);

std::map<string, physics::Contact> contacts = contactSensor->GetContacts(this->contactSensor->GetCollisionName(0));

for (std::map<string, physics::Contact>::iterator iter = contacts.begin();iter != contacts.end(); ++iter)
{
  cout <<"collision name"<< iter->first<<endl;
  cout <<"collision1  " << iter->second.collision1 <<endl
       <<"collision2  " << iter->second.collision2 <<endl
       <<"count       " << iter->second.count <<endl
       <<"time        " << iter->second.time <<endl;
}

The probleme with messages, it may miss some data. I want that each time I run the simulation I get the same data sequence, but this is not the case. For instance look at this curves; data in the first run are different from the second even if its the same simulation image description image description

how to retrieve contact data from engine (NOT MESSAGE)!

how to retrieve contact data directly from physic engine (not in a message).

I tried to use the map structure but this function also use messages.

sensors::SensorPtr sensor = sensors::SensorManager::Instance()->GetSensor(this->model->GetLink("0")->GetSensorName(0));

sensors::ContactSensorPtr contactSensor = boost::dynamic_pointer_cast<sensors::ContactSensor>(sensor);

std::map<string, physics::Contact> contacts = contactSensor->GetContacts(this->contactSensor->GetCollisionName(0));

for (std::map<string, physics::Contact>::iterator iter = contacts.begin();iter != contacts.end(); ++iter)
{
  cout <<"collision name"<< iter->first<<endl;
  cout <<"collision1  " << iter->second.collision1 <<endl
       <<"collision2  " << iter->second.collision2 <<endl
       <<"count       " << iter->second.count <<endl
       <<"time        " << iter->second.time <<endl;
}

The probleme with messages, it may miss some data. I want that each time I run the simulation I get the same data sequence, but this is not the case. For instance look at this curves; data in the first run are different from the second even if its the same simulation image description image description