gz-sim icon indicating copy to clipboard operation
gz-sim copied to clipboard

Some ranges of lidar sensor return always 0.0

Open lucaslbmp opened this issue 2 years ago • 2 comments

Environment

  • OS Version:
  • Source or binary build?: Binary, Ignition Fortress (Gazebo 6.8.0)

Description

I am spawning a model (teste_bot) containing a lidar sensor and echoing the lidar topic to check the ranges returned.

  • Expected behavior: In the absence of any obstacle in the range of detection of the sensor, it is expected that all ranges return inf. In case of any detection, the range value should be a value between the minimum range and the maximum range.
  • Actual behavior: All ranges return inf except the ones corresponding to the last (upper) horizontal layer and to the last ray in each horizontal layer, which return 0.0 invariably. It should be impossible even if any ray collision happened, since the values of ranges returned by the sensor should not be below the minimum range parameter, which is not zero in this case.

Steps to reproduce

  1. Add a sensor component to the xacro file of any model, using the plugin "ignition::gazebo::systems::Sensors":
<gazebo reference="base_lidar">
        <sensor name="${name}" type='gpu_lidar'>
            <pose>0 0 ${body_height*0.6} 0 0 0</pose>
            <topic>${name}/lidar</topic>
            <update_rate>10</update_rate>
            <ray>
                <scan>
                    <horizontal>
                        <samples>5</samples>
                        <min_angle>${-radians(20)}</min_angle>
                        <max_angle>${radians(20)}</max_angle>
                    </horizontal>
                    <vertical>
                        <samples>5</samples>
                        <min_angle>${-radians(10)}</min_angle>
                        <max_angle>${radians(10)}</max_angle>
                    </vertical>
                </scan>
                <range>
                    <min>0.1</min>
                    <max>2.0</max>
                    <resolution>0.01</resolution>
                </range>
            </ray>
            <always_on>1</always_on>
            <visualize>true</visualize>

            <plugin filename="libignition-gazebo-sensors-system.so" name="ignition::gazebo::systems::Sensors">
                <render_engine>ogre</render_engine>
            </plugin>
        </sensor>
    </gazebo>
  1. Build the workspace: colcon build
  2. Launch the simulator: ign gazebo empty.sdf --render-engine ogre
  3. Spawn the robot: ign service -s /world/empty/create --reqtype ignition.msgs.EntityFactory --reptype ignition.msgs.Boolean --timeout 300 --req 'sdf_filename: "/home/lucas/ros2_ntu_ws/src/ntu_gazebo/models/teste_bot/urdf/teste_bot.urdf" '

Output

lidar_bug_picture

A screenshot of the point cloud of the lidar sensor, which was configured to have 5 samples in the layer and 5 samples in the layer. The point cloud was generated using the "Visualize Lidar" plugin. It is possible to see that the distribuition becomes asymetric and the points corresponding to the "zeroed" ranges can be seen in the origin of the scan.

Could someone help me clarify why is this happening?

Gratefully,

Lucas

lucaslbmp avatar May 08 '22 04:05 lucaslbmp

I'm having issues trying to reproduce this, here is what I have so far

I created a static robot with a single link and the sensor much like yours (I went ahead and converted the xacro macros in this case):

<?xml version="1.0" ?>
<robot name="vehicle">
  <gazebo>
    <static>true</static>
  </gazebo>
  <link name="base_link">
    <inertial>
      <mass value="1"/>
      <inertia ixx="1" ixy="0" ixz="0" iyy="1" iyz="0" izz="1"/>
    </inertial>
  </link>

  <gazebo reference="base_link">
    <sensor name="lidar" type='gpu_lidar'>
            <pose>0 0 1.0 0 0 0</pose>
            <topic>scan</topic>
            <update_rate>10</update_rate>
            <ray>
                <scan>
                    <horizontal>
                        <samples>5</samples>
                        <min_angle>-0.349066</min_angle>
                        <max_angle>0.349066</max_angle>
                    </horizontal>
                    <vertical>
                        <samples>5</samples>
                        <min_angle>-0.174533</min_angle>
                        <max_angle>0.174533</max_angle>
                    </vertical>
                </scan>
                <range>
                    <min>0.1</min>
                    <max>2.0</max>
                    <resolution>0.01</resolution>
                </range>
            </ray>
            <always_on>1</always_on>
            <visualize>true</visualize>

            <plugin filename="libignition-gazebo-sensors-system.so" name="ignition::gazebo::systems::Sensors">
                <render_engine>ogre</render_engine>
            </plugin>
        </sensor>
    </gazebo>
</robot>

I execute with:

ign gazebo empty.sdf --render-engine ogre
ign service -s /world/empty/create --reqtype ignition.msgs.EntityFactory --reptype ignition.msgs.Boolean --timeout 300 --req 'sdf_filename: "/home/mjcarroll/diff_drive.urdf" '

And I get the resulting screenshot: Screenshot from 2022-05-25 12-43-14

All of my ranges are inf.

The same happens with a basic SDF model.

Can you include more information? Maybe a link to your model so that I can execute exactly what you have? Or a minimally reproducable example so that I can try that?

mjcarroll avatar May 25 '22 17:05 mjcarroll

@lucaslbmp friendly ping.

mjcarroll avatar Jun 15 '22 13:06 mjcarroll

@lucaslbmp I'm going to close this as I haven't heard back from you. If you have any other problems, feel free to either re-open this issue or open a new issue.

mjcarroll avatar Oct 14 '22 12:10 mjcarroll

For some reason this doesn't work when I am trying to run it via a ros node. The camera and other sensors work fine but the lidar ends up giving a 0 reading in range, no matter what. On a stand alone gazebo instance it works perfectly well. Any thoughts?

jetag avatar Nov 03 '23 04:11 jetag