contact sensor is not working in Gazebo8 ,Gazebo9 and Gazebo10
In gazebo8 ,gazebo9 and gazebo10 (install from source), the contact atrribute in ContactSensor class is Not work. When I get a ContactSensor by
contacts =this->ContactSensor->Contacts()
, Then the results ofcontacts.contact_size()
,contacts.contact(0).position_size()
and other related values are all zero or empty.But method like
this->ContactSensor->IsActive()
,this->ContactSensor->GetCollisionName(0)
,this->ContactSensor->UpdateRate()
andthis->ContactSensor->Id()
is work. Why?By the way, gazebo4 and gazebo7 is OK.
Problem Solved.It was the name of the collision cause the problem.I had named my contact link in xacro file like this
<link name="simple">
...
<collision name="simple_collision">
...
</link>
and use it like this
<gazebo reference="simple">
...
<contact>
<collision>simple_collision</collision>
<topic>/simple_contact</topic>
</contact>
...
</gazebo>
It would Not work in this case. I should Not add a <collision name="simple_collision">
in xacro file. Just use <collision>
in xacro file, it will gives you linkname+_collision
automaticlly.
It would help if you shared some minimum example which someone can compile to reproduce the error
Thank you. You really give me a good idea to debug my code. And I solved it by simplify the model into a box. And find that it was the name of collusion cause the problem.
Hey Thanks! Huge help - I was stuck on this for a little. Would you mind discussing a little bit how you figured this out?