# Using multiple laser scanners

What is the best way to use multiple laser scanners on a robot? Currently I have two hokuyo scanners, one facing forward, and one facing backwards. I'd like to do slam as efficiently as possible using data from both scanners.

Originally posted by aarons on ROS Answers with karma: 81 on 2011-03-05

Post score: 8

I don't believe the current slam-gmapping implementation in ROS directly supports laser scans coming from lasers with different frames.

A quick solution: You could try to combine your two 180-deg lasers scans into one 360-deg laser scan. Compute the x-y coordinates from both the laser scans, then calculate the distance from each beam endpoint to a virtual laser scanner, and output the result as a LaserScan.

This would work best if you align your sensors well, ie, exactly 180 degrees apart from each other. Also, try to get the optical centers of the lasers as close as possible. The laser scan structure assumes the angular gap between two scan beams is constant, so hacking two laser scans into one might introduce some distortions in the data. Nevertheless, it will probably be minimal, if you are careful with the settings of your scanners.

Now, for a more correct solution: slam-gmapping (as well as other laser tools, such as canonical_scan_matcher) don't algorithmically require that the input data is in polar coordinates. In fact, they take the (r, theta) readings from the laser, and covert them to (x, y) coordinates internally. What would be best is to rewrite the wrappers to accept (x, y) coordinates directly. Then, you would be able to combine any number of laser scans, regardless of their physical configuration. All you would have to do is convert the LaserScans to PointClouds, and then merge the PointClouds together. You would also be able to use non-laser sources of data (like the Kinect) without having to go through a clunky PointCloud-To-LaserScan conversion.

Originally posted by Ivan Dryanovski with karma: 4954 on 2011-03-05

This answer was ACCEPTED on the original site

Post score: 5

Comment by Ivan Dryanovski on 2011-03-05:
Looks like we have two discussions going - on the mailing list and here. We can continue with the details of modifying slam_gmapping on the mailing list.

Comment by aarons on 2011-03-05:
Unfortunately my scanners are at opposite sides of the robot, about 1m apart. I already hacked together a node that merges the LaserScans into one PointCloud, and was planning to look into modifying slam_gmapping to accept a PointCloud. It looks like I'm on the right path then. Thanks.

Comment by JunTuck on 2016-05-24:
Hi there, would you mind sharing which part of slam_gmapping you hacked? I'm having trouble finding the part where it actually converts LaserScans into x-y coordinates. Thanks in advance!

Hi,

I want to do the same thing that you propose, in fact I have 3 laser sensor and I want to combine their data, so I would like to change "slam_gmapping" to accepet "point_cloud", I wanted to know before embarking on, did you managed to get some results ?

I work on the control of a wheelchair at the Polytechnic of Montreal, and I have already managed to build a map from a laser sensor.

Thank you,

Originally posted by Anas with karma: 126 on 2011-08-11

This answer was NOT ACCEPTED on the original site

Post score: 1

Hello all, I also have the same problem. Any luck so far? I found the mailing list thread, but it seems inactive. As long as I couldn't found any solution, I'll try on my own and keep you posted. Comments are welcome.

Originally posted by Manuel with karma: 36 on 2012-03-05

This answer was NOT ACCEPTED on the original site

Post score: 1

Comment by Manuel on 2012-03-05:
Last version of slam_gmapping can manage laser scans from different sensors. You just have to publish both laserscans into the same topic. Gmapping handles transformations on its own.

I have used a modified version of stage simulator for ros (from Gonçalo Cabrita) and gmapping to test it. Gmapping maps are built using both simulated lasers, so I guess it is ok.

Comment by chao on 2013-12-11:
Hi Manuel, I have tried to use both scan from kinect (depthimage_to_laserscan) and hokuyo. But the scan points show on rviz are flickering and switching between both of them. Is it normal?

Comment by Icehawk101 on 2014-01-06:
I did this for a class project. Gmapping won't in fact accept the data from both. It will latch onto the transform used in the first scan it receives, and then will only accept data from the same transform.

What is the latest regarding this? Is there really no established way to use more than one laser scanner together with gmapping? There definitely seems to be a demand for this functionality (several people asking independently on ROS answers, including myself).

"@Brian Gerkey": Considering move_base (which I use in conjunction with gmapping) can handle multiple laser scanners for building its costmaps, it would great if gmapping also could be configured to use more than one laser scanner.

Originally posted by Huibuh with karma: 399 on 2014-03-17

This answer was NOT ACCEPTED on the original site

Post score: 3