Gazebo | Ignition | Community
Ask Your Question

Publish a Gazebo message into a ROS topic?

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

Mansan gravatar image

I've been following this toturial ( 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

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

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 You can find the source code from here:

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>
  <plugin name="sensor_plugin" filename="">

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


Thanks for answering! I've been trying to solve it in the easy way, and its not working for me. I add the "" , 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 -0500 )edit

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

Raskkii gravatar imageRaskkii ( 2018-04-02 08:42:57 -0500 )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 -0500 )edit

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

Raskkii gravatar imageRaskkii ( 2018-04-03 01:28:51 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


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

Seen: 3,642 times

Last updated: Apr 02 '18