ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to convert LaserScanner msgs to 2D cartesian cooridnates?

asked 2015-07-02 07:44:32 -0600

ANY gravatar image

I'm trying to convert LaserScanner msgs to 2D vector(cartesian coordinates,(X,Y) pair) in C++ without using any library.Main problem is that I'm using a formula X=rcos(phi) and Y=rsin(phi),and if ranges[i] is r,how can I find phi?

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
3

answered 2015-07-02 10:10:03 -0600

dornhege gravatar image

The information is in the LaserScan message. You can angle_min for the start angle, and each range is angle_increment * i + angle_min for the phi.

edit flag offensive delete link more
0

answered 2015-07-02 08:43:42 -0600

For the Hokuyo URG-04LX-UG01 (as an example), the angular resolution is 0.36° which is what you would get if you do 240/ranges.size().

Therefore, assuming the X axes (phi=0) is following ROS convention, you have to set -120° to ranges[0] and then increase it by 0.36°. In summary: phi = (i * 0.36)-120. And then, convert to radians.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-07-02 07:44:32 -0600

Seen: 920 times

Last updated: Jul 02 '15