How to detect multiple collisions for an object using gazebo's contact sensor?
I am trying to attach a contact sensor to a box object and read data from the topic /gazebo/default/my_box/link/my_contact
according to this tutorial. The purpose was to detect when a gripper grasps the box object. Naturally, I need the contact sensor data for the box object's colision with each finger. I expected that the collision field of this gazebo message will give me the names of all the links which are in contact/collision with the my_box
link. However, the collision field is just showing 2 links irrespective of the number of objects in collision with the my_box
.
To inspect the situation more thoroughly, I have similarly attached a contact sensor on gazebo's cafe_table model, and placed 2 box objects on the table. Technically, the collision field of gazebo's contact message should have the ground plane as well as the two objects on the table. However, all I am getting now is the collision corresponding to the one of the objects as follows:
contact {
collision1: "my_box1::link::collision"
collision2: "cafe_table::link::surface"
position {
x: 1.1247714292393083
y: -0.30755282288907909
z: 0.8890258873213015
}
position {
x: 1.194770947406262
y: -0.23755344002309878
z: 0.88863364405976741
}
position {
x: 1.1947698823446495
y: -0.30755340182594937
z: 0.88856052453361978
}
normal {
x: 0
y: 0
z: 1
}
normal {
x: 0
y: 0
z: 1
}
normal {
x: 0
y: 0
z: 1
}
depth: 7.3116053275080334e-05
depth: 0.00046535931480918072
depth: 0.000538478840956761
wrench {
body_1_name: "my_box1::link::collision"
body_1_id: 120
body_2_name: "cafe_table::link::surface"
body_2_id: 101
body_1_wrench {
force {
x: -0.0027114184690058035
y: 0.00043022874532488455
z: 0.40656806362016379
}
torque {
x: -0.014214824220619364
y: 0.014324781873120928
z: -0.00010995765250157408
}
}
body_2_wrench {
force {
x: 1.44295713873582e-312
y: 4.45619116139268e-312
z: 4.5198510351167e-312
}
torque {
x: 4.56229095095577e-312
y: 1.08221785342934e-311
z: 2.75859455335339e-313
}
}
}
wrench {
body_1_name: "my_box1::link::collision"
body_1_id: 120
body_2_name: "cafe_table::link::surface"
body_2_id: 101
body_1_wrench {
force {
x: -0.003128570143943655
y: 0.0004924267805208859
z: 0.47007226438082916
}
torque {
x: 0.016469764190647253
y: -0.016343029298290998
z: 0.00012673489235625896
}
}
body_2_wrench {
force {
x: 1.06524188731358e-311
y: 4.66839074259887e-312
z: 1.97345608669453e-312
}
torque {
x: 2.01589600232609e-312
y: 1.05675390399211e-311
z: 6.92649961828584e-310
}
}
}
wrench {
body_1_name: "my_box1::link::collision"
body_1_id: 120
body_2_name: "cafe_table::link::surface"
body_2_id: 101
body_1_wrench {
force {
x: -0.000628255072444665
y: 9.43138380420652
e-05
z: 0.093516501136921767
}
torque {
x: -0.00326977655546079
y: -0.0032510886122566907
z: -1.8687943204091005e-05
}
}
body_2_wrench {
force {
x: 6.92649961834987e-310
y: 0
z: 0
}
torque {
x: 6.92649929861153e-310
y: 6.92649929861153e-310
z: 0
}
}
}
time {
sec: 237
nsec: 828000000
}
world: "default"
}
time {
sec: 237
nsec: 829000000
}
So why is only my_box1 listed everywhere even though both the boxes my_box1 and my_box2 are in collision with the surface of the table? I understood that the contact sensor is distributed over the entire link and should be able to detect all collisions. Is this a limitation of the contact sensor, or am I missing something here? Also, there are 2 gazebo messages, /gazebo/default/cafe_table/link/my_contact
and /gazebo/default/cafe_table/my_contact/contacts
. What is the difference between these two since they seem to ...