Gazebo | Ignition | Community
Ask Your Question

How can I simulate a line laser?

asked 2015-10-05 05:48:27 -0500

NikolasE gravatar image


We are currently developing a sheet of light sensor with (several) line lasers. To create evaluation data and to simulate our robot, I'd like to simulate the laser in gazebo. So given a camera and a pose (plane equation) for the line laser, how can I find out where the laser is visible in the camera image?

One idea was to simulate a laser scanner with a very small radial resolution and then (outside of gazebo) project the laser-scan-message back into my image. This gives nice results, however, I have to notion of occlusion so the simulated view is not correct.

It's possible in gazebo to show the laser plane of a laser scanner, but this visualization does not show up in the simulated camera.

Any ideas?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-11-21 07:16:22 -0500

hbaqueiro gravatar image

updated 2018-11-21 07:19:27 -0500

Well, the laser plane from the projected line you see in Gazebo when using the laser scanner plugin is not visible by cameras.

I am not sure if this will help the problem you described but it may help other people looking for a solution based on the title you gave. The best way I've found out to simulate a laser in Gazebo was to use the projector plugin. It basically projects any image you want, so if you want a laser line just draw a line and make sure the background of the rest of the image is transparent before using it. Below is a snippet you can use:

<gazebo reference="your_link">
    <projector name="projector_wg6802418">
        <pose>0 0 0 0 0 ${pi/2}</pose>
     <plugin name="projector" filename="">
         <!-- Apparently the 2 lines below does not affect anything -->
         <!-- end -->

One disadvantage of this plugin is that the projection trespasses any object (just as occurs with all lights in Gazebo, except for the directional one), so if you have multiple objects one in front of another, the projector will project the image in all of them.

Keep in mind that (and this is another common questioned problem) the plugin will not find your image if it is not in the gazebo media path, even if it the image is on the same folder of your urdf or you try to put the full image path. In this way, add the following lines to the package.xml of your catkin package:

    <gazebo_ros gazebo_media_path="path_to_your_image"/>

And just for the sake of documentation, if the plugin cannot find your image, it will show a black image with a diagonal line in yellow, so that you know what happened.

edit flag offensive delete link more


Thanks for your tip. To understand, do you added this gazebo plugins to the link where I want to project the laser or to a camera link (example) where will project forward?

dregner gravatar imagedregner ( 2020-08-12 10:13:31 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-10-05 05:48:27 -0500

Seen: 1,171 times

Last updated: Nov 21 '18