Add contact sensor or example


#1

Did someone already use a contact sensor in the NRP or knows an experiment with an example?

I already added the sensor to my robot, can stream the data via "gz topic -e “/gazebo/default/robot/base_link/my_contact” and set a topic in my model.sdf. But I can’t see it with “rostopic list”, so I think that my sensor plugin is not working.

How can I find the needed argument/attributes to get it into the TF?


[SOLVED] Contact sensor - transfer function issue
#2

Hello, @FloAui!

To get sensor data for contact (bumper-style) sensors in a transfer function, I’d recommend to use a ROS-based solution instead: The bumper sensor plugin included in GazeboRosPackages. This plugin publishes ROS messages (type gazebo_msgs/ContactsState) that you can subscribe to from a transfer function.
As of now, transfer functions don’t have support for subscribing to Gazebo topics.

Putting something like:

<!-- contact sensor -->
<sensor type="contact" name="your_link_contact_sensor">
  <update_rate>1000.0</update_rate>
  <always_on>1</always_on>
  <contact>
    <collision>bumper_collision</collision>
    <topic>/bumper_contact</topic>
  </contact>
<plugin name="gazebo_ros_bumper_controller" filename="libgazebo_ros_bumper.so">
        <alwaysOn>true</alwaysOn>
        <updateRate>1000.0</updateRate>
        <bumperTopicName>/robot_bumper</bumperTopicName>
        <frameName>world</frameName>
</plugin>
</sensor>

(taken from: https://answers.ros.org/question/240076/gazebo-ros-collision-detection/)

in each link you want to act as a contact sensor (take care to keep the sensor names unique) should get you started.

With best regards,
Fabian


#3

Hello, @faichele!

thank for your help! I implemented the code into the sdf-model and are able to listen to it via

 rostopic echo /robot_bumper/states   <img src="/uploads/default/original/1X/00dc558d62ec7a789b8ea1939d57a97254fdc003.png" width="690" height="421"> 

an example output is attached.

I tried to subscribe and print the sensor data with the following TF:

# Imported Python Transfer Function
@nrp.MapRobotSubscriber("collision2_name", Topic('/robot_bumper/states/collision2_name', gazebo_msgs.msg.ContactsState))
@nrp.Robot2Neuron()
def read_sensor(t, collision2_name):
    clientLogger.info(collision2_name)

I checked the data format with the following command.

rosmsg show gazebo_msgs/ContactsState 

I thought that I could print it directly, since collision2_name has the format string, but the output is:

  [17:52:17]
  <hbp_nrp_cle.robotsim.RosCommunicationAdapter.RosSubscribedTopic object at 0x7fe89d1c0410>

I assume that I either only get the address or missed a converting step. Am I subscribing the topic correct? Do you know what I missed?

With best regards,
Florian


#4

Hi, @FloAui!

Transfer function that worked for me is:

# Imported Python Transfer Function
@nrp.MapRobotSubscriber("bumper", Topic('/robot_bumper', gazebo_msgs.msg.ContactsState))
@nrp.Robot2Neuron()
def read_sensor(t, bumper):
    clientLogger.info(bumper.value) # type(bumper.value) = gazebo ContactsState

#5

Hi,

I am working on the same topic. I implemented the contact sensor in all links I need, and I can listen to all of them via

rostopic echo /robot_bumper/states

as well as in a transfer function as suggested.
However, the “states” tab of the contact sensor output remains empty, even if there is an obvious collision.

Do you have any ideas on how to fix this issue?

Thanks,
Michael


#6

Hi cyb3,

Could you share your robot sdf file on this forum? It would help us figure out what the culprit is.
Best regards,
Luc


#7

Hi Luc,

thanks for answering!
I already got a solution on one of my other posts:

That solved the problem for me :smile:

Have a nice day!
Michael