Skip to content

bug in calculating the filtered pointcloud after sample indexing #132

Open
@rmessaou

Description

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions