1
$\begingroup$

I'm using Ubuntu 20.04 on a Raspberry Pi 4 B and I'm trying to use the /map topic with my LiDAR. However, when I open Rviz to visualize it, a "Warn" error appears that says "No map received". Also, even though /map appears when I do rostopic list, nothing comes out when I do rostopic echo /map. These are the launch files I use (I run them using roslaunch lidar lidar_gmapping.launch): lidar_gmapping.launch:

<launch>
  <!-- Launch SLAM GMapping -->
  <include file="$(find gmapping)/launch/slam_gmapping_pr2.launch" />

  <!-- Launch your LiDAR driver -->
  <include file="$(find lidar)/launch/X4.launch" />

  <!-- Launch RViz with the desired configuration -->
  <node name="rviz" pkg="rviz" type="rviz" args="-d $(find lidar)/launch/mapping.rviz" />
</launch>

X4.launch:

<launch>
  <node name="ydlidar_lidar_publisher"  pkg="ydlidar_ros_driver"  type="ydlidar_ros_driver_node" output="screen" respawn="false" >
    <!-- string property -->
    <param name="port"         type="string" value="/dev/ydlidar"/>  
    <param name="frame_id"     type="string" value="map"/>
    <param name="ignore_array"     type="string" value=""/>

    <!-- int property -->
    <param name="baudrate"         type="int" value="128000"/>  
    <!-- 0:TYPE_TOF, 1:TYPE_TRIANGLE, 2:TYPE_TOF_NET -->
    <param name="lidar_type"       type="int" value="1"/>  
    <!-- 0:YDLIDAR_TYPE_SERIAL, 1:YDLIDAR_TYPE_TCP -->
    <param name="device_type"         type="int" value="0"/>  
    <param name="sample_rate"         type="int" value="5"/>  
    <param name="abnormal_check_count"         type="int" value="4"/>  

    <!-- bool property -->
    <param name="resolution_fixed"    type="bool"   value="true"/>
    <param name="auto_reconnect"    type="bool"   value="true"/>
    <param name="reversion"    type="bool"   value="false"/>
    <param name="inverted"    type="bool"   value="true"/>
    <param name="isSingleChannel"    type="bool"   value="false"/>
    <param name="intensity"    type="bool"   value="false"/>
    <param name="support_motor_dtr"    type="bool"   value="true"/>
    <param name="invalid_range_is_inf"    type="bool"   value="false"/>
    <param name="point_cloud_preservative"    type="bool"   value="false"/>

    <!-- float property -->
    <param name="angle_min"    type="double" value="-180" />
    <param name="angle_max"    type="double" value="180" />
    <param name="range_min"    type="double" value="0.1" />
    <param name="range_max"    type="double" value="12.0" />
    <!-- frequency is invalid, External PWM control speed -->
    <param name="frequency"    type="double" value="10.0"/>
  </node>
  <node pkg="tf" type="static_transform_publisher" name="base_footprint_to_laser_frame"
    args="0.0 0.0 0.2 0.0 0.0 0.0 /base_footprint /laser_frame 40" />
</launch>

mapping.rviz:

<launch>
  <node pkg="gmapping" type="slam_gmapping" name="slam_gmapping">
    <param name="base_frame" value="base_link"/>
    <param name="odom_frame" value="odom"/>
    <param name="map_frame" value="map"/>
    <param name="map_update_interval" value="5.0"/>
    <param name="maxUrange" value="10.0"/>
    <param name="maxRange" value="12.0"/>
    <param name="sigma" value="0.05"/>
    <param name="kernelSize" value="1"/>
    <param name="lstep" value="0.05"/>
    <param name="astep" value="0.05"/>
    <param name="iterations" value="5"/>
    <param name="lsigma" value="0.075"/>
    <param name="ogain" value="3.0"/>
    <param name="lskip" value="0"/>
    <param name="minimumScore" value="50.0"/>
    <param name="srr" value="0.1"/>
    <param name="srt" value="0.2"/>
    <param name="str" value="0.1"/>
    <param name="stt" value="0.2"/>
    <param name="linearUpdate" value="0.2"/>
    <param name="angularUpdate" value="0.1"/>
    <param name="temporalUpdate" value="-1.0"/>
    <param name="resampleThreshold" value="0.5"/>
    <param name="particles" value="30"/>
    <param name="xmin" value="-50.0"/>
    <param name="ymin" value="-50.0"/>
    <param name="xmax" value="50.0"/>
    <param name="ymax" value="50.0"/>
    <param name="delta" value="0.05"/>
    <param name="llsamplerange" value="0.01"/>
    <param name="llsamplestep" value="0.01"/>
    <param name="lasamplerange" value="0.005"/>
    <param name="lasamplestep" value="0.005"/>
  </node>
</launch>

slam_gmapping_pr2.launch:

<launch>
    <param name="use_sim_time" value="false"/>
    <node pkg="gmapping" type="slam_gmapping" name="slam_gmapping" output="screen">
      <remap from="scan" to="base_scan"/>
      <param name="map_update_interval" value="5.0"/>
      <param name="maxUrange" value="16.0"/>
      <param name="sigma" value="0.05"/>
      <param name="kernelSize" value="1"/>
      <param name="lstep" value="0.05"/>
      <param name="astep" value="0.05"/>
      <param name="iterations" value="5"/>
      <param name="lsigma" value="0.075"/>
      <param name="ogain" value="3.0"/>
      <param name="lskip" value="0"/>
      <param name="srr" value="0.1"/>
      <param name="srt" value="0.2"/>
      <param name="str" value="0.1"/>
      <param name="stt" value="0.2"/>
      <param name="linearUpdate" value="1.0"/>
      <param name="angularUpdate" value="0.5"/>
      <param name="temporalUpdate" value="3.0"/>
      <param name="resampleThreshold" value="0.5"/>
      <param name="particles" value="30"/>
      <param name="xmin" value="-50.0"/>
      <param name="ymin" value="-50.0"/>
      <param name="xmax" value="50.0"/>
      <param name="ymax" value="50.0"/>
      <param name="delta" value="0.05"/>
      <param name="llsamplerange" value="0.01"/>
      <param name="llsamplestep" value="0.01"/>
      <param name="lasamplerange" value="0.005"/>
      <param name="lasamplestep" value="0.005"/>
    </node>
    <node pkg="tf" type="static_transform_publisher" name="map_to_odom"
    args="0.0 0.0 0.0 0.0 0.0 0.0 /map /odom 100" />
</launch>
$\endgroup$
5
  • $\begingroup$ Welcome to Robotics, Flamethrower. It sounds like your rviz is subscribing to the /map topic, which is why you would see it in rostopic list - that command shows all the topics, regardless of whether or not there's a node publishing those topics. I'm not positive what the expected behavior is here, but I do see that it looks like you've given the same node name out to rviz and your SLAM package: name="slam_gmapping". What happens if you change the name for your rviz node? If you remove the rviz call from your lidar_gmapping launch file then do you get updates on /map? $\endgroup$
    – Chuck
    Mar 6 at 20:01
  • $\begingroup$ You mean if I run Rviz from the terminal command instead of the launch file? If I remove the <node name="rviz" pkg="rviz" type="rviz" args="-d $(find lidar)/launch/mapping.rviz" /> </launch> ? $\endgroup$ Mar 7 at 14:41
  • $\begingroup$ I tried launching just slam_gmapping_pr2.launch and then Rviz manually, but the map still isn't being received. I also tried using slam_gmapping_pr2.launch as an rviz file (which worked), but the map isn't received. $\endgroup$ Mar 7 at 17:36
  • $\begingroup$ If you kill everything, restart your roscore, and run only the slam_gmapping package, do you see /map in a rostopic list? Can you see it on rostopic echo /map? $\endgroup$
    – Chuck
    Mar 7 at 17:56
  • $\begingroup$ I assume you mean slam_gmapping_pr2.launch. Yes, it does appear. But rostopic echo /map doesn't output anything (as before). By the way, I've noticed that base_footprint and laser_frame aren't being transformed into map. I tried to add the transformations but they don't seem to make any difference... $\endgroup$ Mar 7 at 18:41

2 Answers 2

0
$\begingroup$

can you share the frame_id relation. I think changing something in X4.launch might help.

 <node pkg="tf" type="static_transform_publisher"
 name="base_footprint_to_laser_frame"
     args="0.0 0.0 0.2 0.0 0.0 0.0 /base_footprint /laser_frame 40" />
$\endgroup$
4
  • $\begingroup$ Can you say why you think this would be helpful? And what's different than what they already have included? This doesn't look like it answers their question. $\endgroup$
    – Tully
    Mar 4 at 23:21
  • $\begingroup$ I think the chosen frame (global) on rviz creates this problem.it doesn't find relation to the base_footprint directly. map->odom->basefootprint-works fine map->base_footprint-might not $\endgroup$ Mar 5 at 13:15
  • $\begingroup$ Please edit your answer to explain how all this connects. Your comment and answer don't seem connected nor answer the question effectively. Also a map not being produced likely doesn't connect to the use of rviz parameters. $\endgroup$
    – Tully
    Mar 5 at 17:32
  • $\begingroup$ The frame_id relation is in X4.launch (<param name="frame_id" type="string" value="map"/>) $\endgroup$ Mar 7 at 17:39
0
$\begingroup$

It's difficult to help here without being able to run your code, so I'll give you steps here to help get you started troubleshooting your own code.

In general:

  1. rostopic echo /scan --noarr and verify you're getting messages there
  2. Check the slam_gmapping terminal output and verify the mapper initialized
  3. Change your log level and see where the last ROS_DEBUG statement is printed.

First possible issue: Your lidar isn't publishing anything, or isn't publishing on /scan. Your slam_gmapping package won't output a map if it doesn't get a message on /scan. You can see that the mapper is expecting to get lidar inputs on the scan topic

scan_filter_sub_ = new message_filters::Subscriber<sensor_msgs::LaserScan>(node_, "scan", 5);

This is then used to setup the callback:

scan_filter_ = new tf::MessageFilter<sensor_msgs::LaserScan>(*scan_filter_sub_, tf_, odom_frame_, 5);
scan_filter_->registerCallback(boost::bind(&SlamGMapping::laserCallback, this, _1));

which invokes laserCallback whenever a message is received on /scan.

Second possible issue: There is an initialization step that happens on the first scan that could fail, but whether it fails or succeeds you should see something on your console output. Failure to initialize would look like this

 ROS_WARN("Failed to compute laser pose, aborting initialization (%s)",
         e.what());

or some other ROS_WARN, or you should see this success message

ROS_INFO("Initialization complete");

Both ROS_WARN and ROS_INFO should appear in your console output with the default log levels set.

Third possible issue: There are issues with underlying gmapping calls. This could be now a range of issues, from a failure to process the scan (do you get this message in your output?) to a failure to update the map (do you see this message?), etc.

Ultimately, at the end of the updateMap step the map is published, so if you're not seeing content coming across the /map topic then your slam_gmapping package is failing somehow. You need to check the logs and the inputs to troubleshoot why the map isn't getting updated.

$\endgroup$
7
  • $\begingroup$ rostopic echo /scan --noarr does give me an output, but how can I check the slam_gmapping terminal output to verify if the mapper is initialized? Also, /scan is fine, the problem is with /map, and I'm not getting the errors or any of the ROS messages you mentioned, for some reason. It's just the "No map received" one in Rviz. $\endgroup$ Mar 9 at 17:53
  • $\begingroup$ @Flamethrower I just use ROS packages directly (rosrun my_pkg my_pkg), I haven't used launch files, but try launching just slam_gmapping_pr2.launch in one console. $\endgroup$
    – Chuck
    Mar 10 at 2:12
  • $\begingroup$ "Your node's log file will be in ~/. ros/log unless you override it with the ROS_HOME or ROS_LOG_DIR environment variables. If you are using roslaunch, you can use the roslaunch-logs command to tell you the location of the log directory." From the documentation. $\endgroup$
    – Chuck
    Mar 10 at 2:16
  • $\begingroup$ Running slam_gmapping_pr2.launch by itself (and then LiDAR and rviz, I assume) doesn't really make a difference. And I can never seem to find these log files; already searching ROS_ or .ros ends up with no results. $\endgroup$ Mar 10 at 13:09
  • $\begingroup$ cd ~/.ros/log && ls? $\endgroup$
    – Chuck
    Mar 11 at 14:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.