Home | Tutorials | Wiki | Issues
Ask Your Question
0

What does the sensor tag do?

asked 2018-11-02 07:58:01 -0600

kumpakri gravatar image

updated 2018-11-02 09:54:18 -0600

I understand a link tag adds a block of matter into the simulation. The joint tag adds a connection between the two links. But what does the sensor tag actually do?

When look at this chunk of code for example

<sensor name='contact_sensor' type='contact'>
    <always_on>true</always_on>
    <update_rate>10</update_rate>
    <contact>
        <collision>caster_link_collision</collision>
        <topic>/gazebo/caster_bumper</topic>
    </contact>
    <plugin name="gazebo_ros_bumper_controller" filename="libgazebo_ros_bumper.so">
        <frameName>world</frameName>
        <bumperTopicName>/gazebo/caster_bumper</bumperTopicName>
    </plugin>
</sensor>

This sensor loads a plugin. This plugin has a bumperTopicName tag with the same topic name as the sensor tag has in its contacts/topic tag. I can look into the plugin's source code and see what it does with it's tags. But I have no idea what happens with the information inside the sensor tag.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2018-11-02 12:12:54 -0600

updated 2018-11-02 17:19:33 -0600

The <sensor> tag adds a sensor to the link, which usually publishes the sensor readings to a Gazebo Transport topic.

According to the configurations of your contact sensor, it will publish messages to the /gazebo/caster_bumper Gazebo topic whenever the link's caster_link_collision touches something. That's the sensor's basic functionality and it will work even if you remove the <plugin> tag.

Adding a plugin to a sensor lets the user extend the sensor's functionality directly in the C++ code. The referenced plugin library will be loaded together with the sensor and can tie callbacks to specific simulation events.

The functionality of plugin in your example is to publish ROS messages with the sensor readings. So the sensor on your example is _publishing to 2 different transport systems: Gazebo's and ROS_. The parameters inside the plugin tag only affect the plugin - in this case, they're setting the TF frame name for the readings, and the ROS topic name.

Update

Source code:

edit flag offensive delete link more

Comments

So is there a source code of the sensor available?

kumpakri gravatar imagekumpakri ( 2018-11-02 16:57:55 -0600 )edit

updated the answer with links to the source code

chapulina gravatar imagechapulina ( 2018-11-02 17:19:53 -0600 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2018-11-02 07:58:01 -0600

Seen: 257 times

Last updated: Nov 02