NKU-MobFly-Robotics / laser_scan_matcher

An incremental laser scan matcher, using PLICP (point-to-line iterative closest point) scan matching algorithm.
125 stars 37 forks source link

How to get the lidar measurement points in the map frame? #2

Closed ywiyogo closed 4 years ago

ywiyogo commented 4 years ago

Hi @nkuwenjian ,

I have another questions. The function scanCallback() is the start entry of the scan processing if a lidar measurements coming. It contains three important steps : getLaser(), processScan(), and updateMap().

There is no documentation in both repositories from scan_tools and open_karto. Thus, I would like to ask how can I get the measurement points at the map frame?

Furthermore, since the function int value = occ_grid->GetValue(Vector2<int>(x, y)); is index-based. If I have a point (x,y) from the map frame in meter, how can I get the value at the occupancy gridmap?

Thanks

nkuwenjian commented 4 years ago

Hi @ywiyogo ,

Firstly, in the "karto_tools.h" file, a class called "LocalizedRangeScan" is implemented to store the data of a laser scan. If you want to get the scan points in the map frame, you can call the function "pScan->GetPointReadings" to access the point readings in global coordinates.

Secondly, when you have a point in world coordinates, you must scale it into grid coordinates before you can access the value at the grid map. The function "WorldToGrid" implemented in the "Grid" class can help you.

ywiyogo commented 4 years ago

Thanks @nkuwenjian , it works now!