Here you have the ROSject as a plug and play solution for the DogBot: ROSject
Here you have the git with all the code: GIT
Here you have a video explaining all the process: VIDEO
Basically what I have done to have a pressure sensor is to use the libgazebo_ros_bumper.so that gives among other things force on the point of contact. The tricky part is to get the collision element name. This is not trivial because if you come from a XACRO or URDF, it will be most probable that you didn't even give a name to the collision element. So the best way is to convert your URDF or XACRO into SDF, and the get the collision element name.
With this script convert XACRO->URDF->SDF
echo "Cleaning sdf and urdf"
rm -rf dogbot.sdf dogbot.urdf
rosrun xacro xacro.py dogbot.xacro > dogbot.urdf
gz sdf -p dogbot.urdf > dogbot.sdf
echo "Generated SDF".
This is how you would place it in a XACRO or URDF:
<gazebo reference="${prefix}_${suffix}_foot">
<mu1 value="2000.0"/>
<mu2 value="1000.0"/>
<kp value="${kp}" />
<kd value="${kd}" />
<!-- Contact Sensor -->
<sensor name="my_foot_contactsensor_sensor" type="contact">
<always_on>true</always_on>
<contact>
<collision>parent_of_my_foot_fixed_joint_lump__my_foot_collision_5</collision>
</contact>
<plugin name="my_foot_plugin" filename="libgazebo_ros_bumper.so">
<bumperTopicName>my_foot_contactsensor_state</bumperTopicName>
<frameName>my_foot</frameName>
</plugin>
</sensor>
</gazebo>
The critical part is: parent_of_my_foot_fixed_joint_lump__my_foot_collision_5
This is normally generated by the union between the parent, the joint type and the child ( your link with the contact sensor ).
Hope it helped.
EDIT:
I hadded a tutorial also on how to represent these pressuer sensor readings in RVIZ
Check this video for all the details: VIDEO RVIZ Respresentation
I essentially had to create a world to base_link TF publisher and also an Arrow markers publisher for each contact sensor:
world_to_base_tf_publisher.py
arrows_rviz.py
