Ask Your Question
0

Detecting hallways using LaserScan data

asked 2016-02-18 17:19:51 -0500

San gravatar image

Hello everyone, I am trying to detect hallways (two solid parallel lines) using laser data (sensor_msgs/LaserScan). Does anyone know of any ready to use ROS packages to get this job done.

If there are no ready to use packages, my other option is to use Hough transforms to detect straight lines and search for two parallel lines. To do this, I have converted sensor_msgs/LaserScan to sensor_msgs/PointCloud2. How do I access individual points so that I can discard the Z axis values and apply Hough transform by voting an accumulator. (I am assuming PointCloud2 is a message type and we can not access individual points) Do I need to convert it into some other form? If so how can I do that?

Any help is much appreciated. Thank you.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-02-18 21:04:18 -0500

San gravatar image

updated 2016-03-01 00:26:36 -0500

Thanks for the quick reply. Yes, what you said seems valid. However, I have a question, How do I apply hough's transform to laser data? for the equation r = x cos theta + y sin theta, I can get r value (range in laser message), theta (theta increments from the laser message). I am still left with two unknowns x and y.

I used hough's transforms on Images before as follows: I iterate over every pixel and for every edge pixel, I calculate theta using gradient, solve for r in r = x cos theta + y sin theta vote for r , theta in a accumulator. The (r, theta) that gets maximum votes are my hough parameters.

So, when I have two unknowns (x, y ) how can solve for the equation.

Edit: I found the answer. The laser messages are already in polar form. so, you have r and theta from it. Using r, theta find x = r * cos theta and y = r * sin theta. round of both x and y. Using opencv create an empty image (white image) - the image size depends on the accuracy/resolution you need, for every calculated x, y manipulate pixel at x,y to black pixel. By doing so, you will get a white image with black dots (walls/obstacles detected by the laser). Now, use the built in Hough transform from OpenCV and find the lines. In order to detect the hallway, select two strong lines whose slopes are equal.

edit flag offensive delete link more

Comments

I implemented Hough transform before and I am not sure OpenCV is required as you only need it for visualization. I think you can make in a easier way the debugging output using python with matplotlib. You will vote in a numpy 2D array then show it

Arowana gravatar image Arowana  ( 2016-03-01 18:37:48 -0500 )edit

I checked and it is true OpenCV has a Hough line detector, however I think it was design for images instead of a laser scan.

Arowana gravatar image Arowana  ( 2016-03-01 18:40:21 -0500 )edit

I would be very curious to see the code of how you implemented this and how efficient it is. It is possible?

doisyg gravatar image doisyg  ( 2016-07-21 17:30:35 -0500 )edit
0

answered 2016-02-18 18:03:09 -0500

If you end up implementing your own linear Hough Transform extraction code, I'd avoid the point cloud message entirely. Because the Hough Transform you'd want to implement is inherently polar in nature it can be calculated faster if you keep the polar coordinates you get from the laser scan instead of converting them to Cartesian coordinates.

edit flag offensive delete link more

Comments

I was restricted to 300 characters. So I wrote as an answer please reply to that. Thanks.

San gravatar image San  ( 2016-02-18 21:06:16 -0500 )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

1 follower

Stats

Asked: 2016-02-18 17:19:51 -0500

Seen: 1,214 times

Last updated: Mar 01 '16