Problem with remapping from /scan to /kobuki/laser/scan

I can’t get it to remap from /scan to /kobuki/laser/scan on the exam.

Launch file:

<launch>
    <rosparam file="$(find navigation_exam)/params/mapping.yaml" command="load" />

    <arg name="scan_topic"  default="kobuki/laser/scan" />

    <node pkg="gmapping" type="slam_gmapping" name="slam_gmapping" output="screen">
        <remap from="scan" to="$(arg scan_topic)"/>
    </node>
</launch>

Params file:

base_frame: base_link
odom_frame: odom
map_frame: map
map_update_interval: 5.0
maxUrange: 0.5
maxRange: 8.0

minimumScore: 200

linearUpdate: 0.3
angularUpdate: 0.5
temporalUpdate: -1.0
resampleThreshold: 0.5
particles: 80

xmin: -10.0
ymin: -10.0
xmax: 10.0
ymax: 10.0

The file runs fine and remaps when I run it from the Unit 2 page, but not the Exam page. Anyone know how I can fix this?

Hello @RuneTun ,

I assume you are working on the Husky robot Exam. In that case, the problem is not that launch file is not working or remapping correctly, but that the topic for the laser is different. In Unit 2, the robot provided the laser data in a topic named kobuki/laser/scan. that’s why the remapping is done. In the Husky simulation, however, the laser topic is provided in the /scan topic, as you can check by testing the simulation.

Thanks for the reply, I think I might be misunderstanding something here, is the robot not providing the scan to the /scan topic in both units, and then you remap that to the /kobuki/laser/scan topic, which the /slam_gmapping node is subscribed to and makes the map out of?

By default, the gmapping node subscribes to the /scan topic in order to get the laser data. So, if your robot uses a different topic name for the laser data, you needed to do a remap of the topic so that gmapping can get the laser data (this is what you are doing in the 1st case). For the Husky robot, since the robot is providing the data in the /scan topic already, it’s not even required to do a remap.

I see, then shouldn’t /slam_gmapping come up as a subscriber to /scan? This is what I get when I check the publishers and subscribers:

user:~$ rostopic info /scan
Type: sensor_msgs/LaserScan

Publishers: * /gazebo (http://4_simulation:42055/)
Subscribers: None
user:~$ rostopic info /kobuki/laser/scan
Type: sensor_msgs/LaserScan

Publishers: None

Subscribers:
 * /slam_gmapping (http://4_xterm:39711/)

Yes, it subscribes to the /kobuki/laser/scan because you are doing the remap:

<arg name="scan_topic" default="kobuki/laser/scan" />

What happens if you change the line to the following?

<arg name="scan_topic" default="scan" />

It works, thanks a million!