-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Usage of updatePointCloud leads to length_error in vector::reserve #4001
Comments
This is not a MCVE. Seems unrelated to PCL based on information provided Also the erase call looks suspiciously bad. Try |
Are there some more informations needed? I pointed out that this issue is related to
The erase call was used due to an administrator post from here. Also it's not possible to call |
I didn't notice you were using the cloud. The usage appears correct, except at Regarding MCVE, you example isn't minimum or easily verifiable. The issue also doesn't show that the problem is in the library or some code you wrote (in which case SO is the best place) |
Alright, I did some more testing and stripped down the issue. Hope it's more clear now. |
Possible issue: user-code: The delete then tries to delete 2 or 3 poins, trying to delete position Closing in favor of the SO question since issue seems unrelated to PCL library code. |
The delete only deletes one point per function call and it is always the last point. This does work if the cloud only contains two points at the beginning. All ppints can be deleted. I've pointed that out- Also, I wrote that this problem occurs as well if an |
The last is the key point. Without that, based on first 2 points, I can't be sure that the issue isn't in user-code. |
Okay, I understand. Will remember it the next time. :-) Should I create an MCVE nonetheless? I can provide a minimal example of code to give some more details, but the issue is already there so I'm not sure whether that's really necessary. |
If you don't mind that would be great. It would save me some time setting up things ourselves and we could jump straight into debugging the issue 😬 |
Alright, I've put a very small project together to reproduce this issue. Here you go: |
Description
When using the viewer function
updatePointCloud
alength_error
invector::reserve
is thrown out.Context
I want to delete points out of a point cloud. To do that, I created a KeyEvent function that deletes the points using the BackSpace key.
The code to delete the newest point (which means the last index inside the point cloud) and update the cloud goes as follows:
if(event.getKeySym () == "BackSpace" && event.keyDown()) {
if(!cloud.empty) {
// delete the "newest" point in the point cloud.
cloud->erase(cloud->end() - 1);
// Use any color you like to visualize the cloud
pcl::visualization::PointCloudColorHandlerCustom<pcl::PointXYZRGB> red(cloud, 235, 19, 19);
m_viewer->updatePointCloud(cloud, red, "cloud");
}
}
Expected behavior
The user should be able to delete all points of the cloud until no points remain.
Current Behavior
If the point cloud contains more than three points and points are deleted until only two points remain, the following issue will be displayed if the user wants to delete a point again:
terminate called after throwing an instance of 'std::length_error' what(): vector::reserve
This error is only thrown if the function
updatePointCloud
is used. But if the function is used this error will be thrown while running the functionviewer->spinOnce(100);
To Reproduce
KeyEvent
function using an arbitrary key to delete points using the function as mentioned above.-> Now this error occures.
-> At first, I thought this issue might be caused due to the
cloud->erase(cloud->end() - 1);
because I thought it might be some bad code. But this is definitely not the issue. I tried to delete points using an ExtractIndices-function (as mentioned here and the error occured nonetheless.
-> If the point cloud contains only two points, everything works fine, so no error is displayed. It only happens if the cloud contains three or more points.
-> I already created a stackoverflow entry for this issue (see here) but there is now answer until now.
-> I have a picture of the full stacktrace after the error was thrown. I'll put it here:
![stacktrace](https://user-images.githubusercontent.com/15110943/80752550-f34d3780-8b2b-11ea-8429-6b8015793f34.png)
Tested environment
Let me know if you need some more information. Cheers!
The text was updated successfully, but these errors were encountered: