# How can I simulate a line laser?

Hey!

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 close merge delete

Sort by » oldest newest most voted

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>
<texture>your_img.png</texture>
<fov>0.5</fov>
<near_clip>1</near_clip>
<far_clip>10</far_clip>
</projector>
</gazebo>
<gazebo>
<plugin name="projector" filename="libgazebo_ros_projector.so">
<projector>projector_wg6802418</projector>
<alwaysOn>true</alwaysOn>
<updateRate>10.0</updateRate>
<!-- Apparently the 2 lines below does not affect anything -->
<textureName></textureName>
<filterTextureName></filterTextureName>
<!-- end -->
<textureTopicName>/projector/image</textureTopicName>
<projectorTopicName>/projector/projector</projectorTopicName>
</plugin>
</gazebo>


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:

<exec_depend>gazebo_ros</exec_depend>
<export>
<gazebo_ros gazebo_media_path="path_to_your_image"/>
</export>


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.

more