ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Can't see scan in rviz

asked 2021-01-29 15:03:15 -0600

BesterJester gravatar image

updated 2021-02-03 08:10:41 -0600

I'm creating my robot model with a URDF file. I've added in the below snippet of code to model the laser scanner.

  <link name="hokuyo_link">
<collision>
  <origin xyz="0 0 0" rpy="0 0 0"/>
  <geometry>
    <box size="0.1 0.1 0.1"/>
  </geometry>
</collision>
<visual>
  <origin xyz="0 0 0" rpy="0 0 0"/>
  <geometry>
    <box size="0.1 0.1 0.1"/>
  </geometry>
</visual>
<inertial>
  <mass value="1e-5" />
  <origin xyz="0 0 0" rpy="0 0 0"/>
  <inertia ixx="1e-6" ixy="0" ixz="0" iyy="1e-6" iyz="0" izz="1e-6" />
</inertial>
</link>

<joint name="hokuyo_joint" type="fixed">
<axis xyz="0 1 0" />
<origin xyz="0 0 0.2" rpy="0 0 0"/>
<parent link="base_link"/>
<child link="hokuyo_link"/>
</joint>

<gazebo reference="hokuyo_link">
<sensor type="gpu_ray" name="hokuyo">
  <pose>0 0 0 0 0 0</pose>
  <visualize>false</visualize>
  <update_rate>40</update_rate>
  <ray>
    <scan>
      <horizontal>
        <samples>720</samples>
        <resolution>1</resolution>
        <min_angle>-1.570796</min_angle>
        <max_angle>1.570796</max_angle>
      </horizontal>
    </scan>
    <range>
      <min>0.10</min>
      <max>30.0</max>
      <resolution>0.01</resolution>
    </range>
  </ray>
  <plugin name="gpu_laser" filename="libgazebo_ros_gpu_laser.so">
    <topicName>/scan</topicName>
    <frameName>hokuyo_link</frameName>
  </plugin>
</sensor>
</gazebo>

This should enable my model to start publishing the resulting laser data onto the scan topic. I run my model in a Gazebo world and the world includes obstacles. I see from rostopic echo /scan that it is publishing laser data on the scan topic. However, it always publishes data points at -inf of the scan, which is weird because I set the minimum range at <min>0.10</min>. I've driven my robot all around the obstacles but with no change to the laser data. Am I doing something wrong with the above sensor code?

Here is the output for the rostopic echo -n1 /scan command:

header: 
  seq: 0
  stamp: 
    secs: 212
    nsecs:  10000000
  frame_id: "hokuyo_link"
angle_min: -1.57079994678
angle_max: 1.57079994678
angle_increment: 0.00436940183863
time_increment: 0.0
scan_time: 0.0
range_min: 0.10000000149
range_max: 30.0
ranges: [-inf, -inf.....]
intensities: [1.0, 1.0...]

Below is a picture of what I'm looking at in Gazebo and rviz. I'm putting my robot right in front of a wall. Rviz is able to subscribe to scan topic, and scan topic exists when I do rostopic list. For some reason, the walls don't seem to be recognized and the ranges in scan don't change.

Linux 5.3.0-62-generic #56 18.04.1-Ubuntuimage description

edit retag flag offensive close merge delete

Comments

What does it look like in Gazebo? Set <visualize>true</visualize> in your sensor configuration.

tryan gravatar image tryan  ( 2021-01-29 15:22:00 -0600 )edit

I tried changing visualize to true as you mentioned. Still had the same issue.

BesterJester gravatar image BesterJester  ( 2021-01-29 17:42:05 -0600 )edit
1

You should be able to see the laser ray in Gazebo even if it hits its maximum range. Here's an example from the Gazebo Plugins in ROS tutorial. What happens if you reduce the size of the collision element of hokuyo_link? For example:

<box size="0.05 0.05 0.05"/>
tryan gravatar image tryan  ( 2021-01-29 21:19:49 -0600 )edit

I tried changing the box size as suggested. It had no effect. I included the output to rostopic echo -n1 /scan to my above post. Also, I realized I was looking at intensities: [1.0, 1.0...] and thought that was the ranges. I corrected my above post to reflect that the ranges are being published as ranges: [-inf, -inf.....]

BesterJester gravatar image BesterJester  ( 2021-02-03 08:15:11 -0600 )edit

I also started looking through the tutorial you provided. It says that changing visualize to true should display laser scan lines in Gazebo. As seen in the Gazebo picture, this isn't happening. I'm guessing that is because the scans are a length of -inf. I just can't figure out why, it is as if the laser scanner is turned off.

BesterJester gravatar image BesterJester  ( 2021-02-03 08:26:35 -0600 )edit

You're getting messages, so it's definitely on. Please, try the non-GPU plugin (remove gpu_ everywhere in the sensor definition).

tryan gravatar image tryan  ( 2021-02-03 08:52:12 -0600 )edit

That fixed it! What made you think that the GPU plugin was causing the issue?

BesterJester gravatar image BesterJester  ( 2021-02-05 08:35:42 -0600 )edit

I've come across similar issues before but had forgotten about it. Sometimes, the root cause is an incompatibility with the graphics card/driver; what do you have? I also seem to remember having to upgrade to a newer version of Gazebo to get a GPU plugin working correctly, but that may have been specific to a different lidar model. In any case, the choice is yours whether to further pursue the GPU version of this plugin or settle for the CPU version.

tryan gravatar image tryan  ( 2021-02-05 09:43:56 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-01-30 03:30:03 -0600

miura gravatar image

This may be because the Fixed Frame in the Global Options is set to odom. If you change it to base_link or hokuyo_link, it may be displayed as intended.

edit flag offensive delete link more

Comments

That would not affect the actual data, which does not correspond to the environment according to the OP.

tryan gravatar image tryan  ( 2021-01-31 09:02:31 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2021-01-29 15:03:15 -0600

Seen: 1,467 times

Last updated: Feb 03 '21