ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A
Ask Your Question

RANSAC implementation for laser scans?

asked 2013-07-09 16:33:21 -0600

Astronaut gravatar image

updated 2014-01-28 17:17:11 -0600

ngrennan gravatar image


I would like to use RANSAC for detection straight lines from my laser scans. So my platform has a IMU, encoders and Laser. I would like to find the minimum distance to some obstacle using the laser range sensor. So in order to know if the closest point is in some wall or some high object that can detect the laser i would like to extract the straight lines. If the point is on the longest straight line than means the closest point is on the wall if not that on some other object. So i find several methods but was told that RANSAC “RANdom SAmple Consensus” methods is the robust one.Is similar as the one used in PCL but I would like to implement for laser scans. ANY help?? Any ROS/C++ code implementation of RANSAC??


edit retag flag offensive close merge delete



Not directly answering your question, but RANSAC for finding lines in a 2D laser scan should be relatively simple to code. I think it's one of those algorithms that's worth implementing once just to understand it better, and this is just about its simplest use case =)

lindzey gravatar image lindzey  ( 2013-07-09 17:29:56 -0600 )edit

yes I think so , just wonted to ask here... Do I need to work with point clouds with that transform? I mean do I need to convert a Laser Scan to a Point Cloud, means to get laser scan as a set of 3D Cartesian (x,y,z) points, converting it to a point cloud message??

Astronaut gravatar image Astronaut  ( 2013-07-09 17:54:37 -0600 )edit

I'd at least convert to cartesian coordinates, since I'd rather do that than work out the minimizations in polar ... however, for simplicity's sake, I might just do my own quick 2D conversion from R and theta and work in xy space, rather than xyz.

lindzey gravatar image lindzey  ( 2013-07-09 18:00:43 -0600 )edit

So u mean to use the transformLaserScanToPointCloud to transform laser scan into a point cloud in another (preferably fixed) frame? Or projectLaser to do a straight projection from range-angle to 3D (x,y,z), without using tf?Or only 2D conversion from R and theta? Sorry for the questions

Astronaut gravatar image Astronaut  ( 2013-07-09 18:10:31 -0600 )edit

How I'd do it would depend on the system it was fitting into, and my goals for writing the code in the first place ... if you have a specific question about best-practices for using those tools, I'd recommend creating an entirely new question. Otherwise, just code, and see if you can make it work =)

lindzey gravatar image lindzey  ( 2013-07-09 18:13:38 -0600 )edit

2 Answers

Sort by » oldest newest most voted

answered 2013-07-18 09:43:05 -0600

Georg gravatar image

updated 2013-07-18 09:44:46 -0600

There is code for this readily available in PCL.

The example given there is for planes ans spheres, but ransac for lines is also implemented. Just have a look at the PCL documentation. Besides the bare ransac, segmentation using ransac is also implemented. Just read the documentation.



edit flag offensive delete link more

answered 2013-07-09 18:37:31 -0600

Bill Smart gravatar image

RANSAC is a good approach when you have too much data to search exhaustively for things, but it's a probabilistic method and might not find the thing that you're looking for. If a randomly-selected point from your data set is likely to be part of the thing you're looking for (a wall in this case), the chances that RANSAC will find it are higher, but it's never a sure thing.

For 2d laser data, my recommendation would be to use a Hough transform. This will find the strongest straight line in your data, with probability 1.

edit flag offensive delete link more


I found that a RANSAC-based method could give good results for feature tracking, and not only extraction. You can help the RANSAC algorithm sample appropriate points when you look for features when you know where they are likely to be. You then only need a few iterations, sometimes even just one.

po1 gravatar image po1  ( 2013-07-10 00:16:42 -0600 )edit

I'd also not go for RANSAC, but we use a split-and-merge approach using the structured nature of a laser scan. Lines aren't arbitrary in a scan. They only appear within consecutive points that can be merged into a line as long as it fits the thresholds for a line.

dornhege gravatar image dornhege  ( 2013-07-10 02:45:37 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2013-07-09 16:33:21 -0600

Seen: 4,939 times

Last updated: Jul 18 '13