Gazebo | Ignition | Community
Ask Your Question
0

Publish a Gazebo message into a ROS topic?

asked 2018-04-01 08:57:32 -0600

Mansan gravatar image

I've been following this toturial (http://gazebosim.org/tutorials?tut=gu...) to create a pulgin in Gazebo and to be able to control it with ROS. Now i would like to publish the sensor scan data (that i think is only available as a Gazebo message ) into a ROS node. It is posible to edit this plugin to add this functionality?Is there any tutorial/resource/code explained that I can take a look to understand how it works?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2018-04-02 05:24:39 -0600

Raskkii gravatar image

It is definitely possible to edit the plugin you already have. Another option is to use an already existing plugin in the gazebo_ros_pkgs library that publishes your laser data to a ROS topic. The plugin you are looking for is libgazebo_ros_laser.so. You can find the source code from here:

http://docs.ros.org/jade/api/gazebo_plugins/html/gazebo__ros__laser_8cpp_source.html

So you have two options here:

1) Modify your existing plugin to also have the functionality of advertising the laser scan data to a ROS topic by using the given source code as a reference.

2) Adding the existing gazebo_ros_laser plugin to your SDF file like so:

<sensor type="ray" name="sensor">
  <pose>0 0 -0.004645 1.5707 0 0</pose>
  <visualize>true</visualize>
  <update_rate>30</update_rate>
  <ray>
    <scan>
      <horizontal>
        <samples>32</samples>
        <resolution>1</resolution>
        <min_angle>-0.53529248</min_angle>
        <max_angle>0.18622663</max_angle>
      </horizontal>
    </scan>
    <range>
      <min>0.05</min>
      <max>70</max>
      <resolution>0.02</resolution>
    </range>
  </ray>
  <plugin name="sensor_plugin" filename="libgazebo_ros_laser.so">
    <topicName>/your/sensor/topic/name</topicName>
    <frameName>/your/frame/name</frameName>
  </plugin>
</sensor>

Notice the plugin tag at the end of the sensor tag. The libgazebo_ros_laser come inside the gazebo_ros_pkgs package which you probably already have installed.

edit flag offensive delete link more

Comments

Thanks for answering! I've been trying to solve it in the easy way, and its not working for me. I add the "libgazebo_ros_laser.so" , and set the topic and framename, but i can´t see the rostopic. And I think that the problem is that Gazebo doesn't even try to load the plugin, because no matter what I write in the "filename" field, I don't get an error which is weird. Any idea why this happends? Anyway, the code of the plugin is being useful and maybe I can adapt my own gazebo plugi

Mansan gravatar imageMansan ( 2018-04-02 08:15:48 -0600 )edit

Can you launch Gazebo with --verbose option to possibly see more error messages?

Raskkii gravatar imageRaskkii ( 2018-04-02 08:42:57 -0600 )edit

Ok, I get the error message(gazebo cannot find the plugin).But I've tried with rosrun gazebo_ros gazebo, and when I add my model I can see the laserscan topic. The only thing is ,that I cannot run the .world (so the model doesn,t rotate ) but I think that it can be solved creating a launch file with my .world file, and then using roslaunch.

Mansan gravatar imageMansan ( 2018-04-02 10:01:59 -0600 )edit

To run a .world file you can just do rosrun gazebo gazebo_ros your.world. But you're right you can also use a .launch file for this.

Raskkii gravatar imageRaskkii ( 2018-04-03 01:28:51 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-04-01 08:57:32 -0600

Seen: 5,033 times

Last updated: Apr 02 '18