init rtabmap::LaserScan

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

init rtabmap::LaserScan

scanboy
To init rtabmap::LaserScan with XY data from a 2D LIDAR is just to do it in an unorganised way like this? (a little bit like an unorganised point cloud vs. an organised depth image)

int mySizeOfLidarPoints = 15000; // or what ever it is
cv::Mat laserScan2dCv(1, mySizeOfLidarPoints, CV_32FC2);
for (int i = 0; i < mySizeOfLidarPoints; ++i)
{
        float * ptr = laserScan2dCv.ptr<float>(0, i++);
        // x = 0 y = 1
        float x,y;
        ptr[0] = myLidarPointsSrcX[i]; // float source
        ptr[1] = myLidarPointsSrcY[i]; // float source
}

rtabmap::LaserScan laserScan2d = LaserScan(laserScan2dCv, mySizeOfLidarPoints, maxRadiusOfMyLidar, rtabmap::LaserScan::kXY);

Is there any way of setting it up with angle and distance pairs? I can of course just write a simple function to convert from polar to cartesian and do as above but I thought I ask anyway.

I'm not using ROS, I use the C++ APIs.
Reply | Threaded
Open this post in threaded view
|

Re: init rtabmap::LaserScan

matlabbe
Administrator
Hi,

It is indeed the way to do this. Points would be ordered from right to left (counter-clockwise) like in the ros message:
# in frame frame_id, angles are measured around
# the positive Z axis (counterclockwise, if Z is up)
# with zero angle being forward along the x axis
In general, the points don't need to be ordered for normal use, only specific options require to have them ordered like that.

To know how to convert from polar coordinates, I use laser_geometry package to do so.

EDIT: I don't think you need "i++" (replace with "i"), it should already point to first float of the channel.

cheers,
Mathieu