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

bug in calculating the filtered pointcloud after sample indexing #132

Open
rmessaou opened this issue Dec 16, 2022 · 1 comment
Open

bug in calculating the filtered pointcloud after sample indexing #132

rmessaou opened this issue Dec 16, 2022 · 1 comment

Comments

@rmessaou
Copy link

rmessaou commented Dec 16, 2022

Hi Atenpas,

I am using gpd in my project and I had difficulties to work with the indexed pointcloud as input. It seems like the region that I am defining is not taken into consideration when the grasps are generated.

After a thorough look into the code, in the function where the filtering of the pointcloud using the indices is done, I noticed this:

gpd/src/gpd/util/cloud.cpp

Lines 206 to 222 in 6327f20

void Cloud::filterWorkspace(const std::vector<double> &workspace) {
// Filter indices into the point cloud.
if (sample_indices_.size() > 0) {
std::vector<int> indices_to_keep;
for (int i = 0; i < sample_indices_.size(); i++) {
const pcl::PointXYZRGBA &p = cloud_processed_->points[sample_indices_[i]];
if (p.x > workspace[0] && p.x < workspace[1] && p.y > workspace[2] &&
p.y < workspace[3] && p.z > workspace[4] && p.z < workspace[5]) {
indices_to_keep.push_back(i);
}
}
sample_indices_ = indices_to_keep;
std::cout << sample_indices_.size()
<< " sample indices left after workspace filtering \n";
}

and specifically this line

indices_to_keep.push_back(i);

So it seems like the indices that are being kept are not "the sample indices" but actually their indices in the for loop list (so technically you are saving the index i instead of sample_indices_[i]).

Therefore shouldn't this line be instead like this

 indices_to_keep.push_back(sample_indices_[i]);

Can you confirm this ?
Thank you and best regards
Rayene

@anmakon
Copy link

anmakon commented Jul 19, 2023

Hi @rmessaou,
I'm a bit late to the game here, but your fix just saved my day and I can confirm it's working!
I think this bug could have been introduced somewhere along with the restructuring of the code in commit #83035e5, since I had earlier versions (with a weird version of ROS kinetic) working before without this issue.

Thank you!

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