Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Range check for output index of nearestKSearch() #37

Open
miroslavradojevic opened this issue Jul 16, 2020 · 1 comment
Open

Range check for output index of nearestKSearch() #37

miroslavradojevic opened this issue Jul 16, 2020 · 1 comment

Comments

@miroslavradojevic
Copy link

I have tried running A-LOAM on Velodyne lidar .bag file recordings and encountered a bug when processing point-clouds.
In laserOdometry.cpp, at line 390:
kdtreeCornerLast->nearestKSearch(pointSel, 1, pointSearchInd, pointSearchSqDis);
pointSearchInd is later used to refer to values from laserCloudCornerLast->points[] list

...
closestPointInd = pointSearchInd[0];
...
int closestPointScanID = int(laserCloudCornerLast->points[closestPointInd].intensity);
...

It happens that the index obtained from nearestKSearch() is a number that exceeds the length of the laserCloudCornerLast->points list and causes this node to stop.

What I added was index check after line 395:

if (closestPointInd >= 0 && closestPointInd < (int)laserCloudCornerLast->points.size()){  
... lines 397 to 481...
}

and the remainder of the code for that block (line 394-482) should go inside if-block to make sure list is not invoked with invalid index.

@jypjypjypjyp
Copy link

Hello! I get very few points after adding the index check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants