Home | Tutorials | Wiki | Issues
Ask Your Question

contact sensor is not working in Gazebo8 ,Gazebo9 and Gazebo10

asked 2018-02-10 04:01:29 -0600

longwoo gravatar image

updated 2018-02-27 03:24:49 -0600

Carlos Agüero gravatar image
  • 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 of contacts.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() and this->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+_collisionautomaticlly.

edit retag flag offensive close merge delete


It would help if you shared some minimum example which someone can compile to reproduce the error

chapulina gravatar imagechapulina ( 2018-02-25 21:26:38 -0600 )edit

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.

longwoo gravatar imagelongwoo ( 2018-02-26 02:54:45 -0600 )edit

1 Answer

Sort by » oldest newest most voted

answered 2018-02-26 02:06:44 -0600

mark_vision gravatar image

If your contact sensor is attached to a link connected to another link via a fixed joint, then the problem could be related with a name change in how the merged collision volume is called:


Check the name of the collision you want to attach your sensor to by generating the SDF file from your Xacro, or check the collision properties directly from Gazebo.

edit flag offensive delete link more


Thank you. It was the name of the collision cause the problem.

longwoo gravatar imagelongwoo ( 2018-02-26 02:58:42 -0600 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-02-10 04:01:29 -0600

Seen: 199 times

Last updated: Feb 27 '18