Search code examples
rosgazebo-simu

Project a line laser visible on camera sensor on Gazebo simulation


I am trying to create an one line laser sensor to project in a object and being capable to visualize the laser over a camera image on Gazebo simulation environment but I am not being able to make it work.

The only example I found in internet was this on Gazebo answers but unfortunately it is not working and not even generating some ERROR LOG. Does anyone already made a line laser visible on camera images for Gazebo?

Below is the example found on link above.

    <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>

Solution

  • I find a way to work it.

    I am using a gazebo sensor called projection as code present below but when you call the texture you must add it to gazebo root files. As I am using Gazebo 7 I create a texture and move it to folder /usr/share/gazebo-7/media/materials/textures and it works as it should.

    I am able to project a texture over objects surfaces and being able to see this texture projected at camera sensor.

        <gazebo reference="projector_sensor_link">
            <!--sensor type="projector" name="projector_tester"-->
            <projector name="projector_test">
                <pose>0 0 0 0 0 0</pose>
                <texture>your_texture.png</texture>
                <fov>${fov}</fov>
                <near_clip>0.1</near_clip>
                <far_clip>10</far_clip>
            </projector>
        </gazebo>