ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hello, I amb like 5 years late, but maybe somebody search that and maybe wants a response.

I reached this place searching exactly the same, and even not finding that solution i realized two ways to solve it.

First of all, I am going to define that the reason why a point is duplicated in two pointclouds which you want to concatenate, probably (and at least is the only possibility I realise) it is because they come from the same pointcloud, whic chave been filtered in different ways (in my case, for example, i did a difference of normals filtering and a difference of grayscale filtering).

First approach: Add two or more conditions into the removal: During the filtering, there is the options of pcl:ConditionAnd and pcl::ConditionOr which can concatenate more than one conditions (with addComparison function or addCondition). This way you should be able to directly generate the filtered/concatenated pointcloud.

A main drawback? lets imagine my case in which each filtering is done using a dirrefent kind of pointcloud (pointXYZI with intensity and pcl::PointNormal with curvate) how you merge both pointclouds into one condition? here appears my second approach

Second approach

Just do as you desired originally (so, we create two independent filtered clouds). Remember in this case to set the setKeepOrganized insideconditionalremoval to false, to store the original index (the removed ones will become NaN).

Once you did that, the easies tolution is to convert both pointclouds into the same kind, something like:

pcl::copyPointCloud<pcl::pointxyzi, pcl::pointxyz="">( cloud_with_i, cloud_without_i);

and then apply the following code (dith cloud1 and cloud2 the clouds to concatenate):

pcl::PointCloud<pcl::pointxyz> cloud_concatenated;

cloud_concatenated = cloud1; bool condition1=false; bool condition2=false; for (int i = 0; i < cloud_concatenated.size(); i++) { condition1 = (cloud_concatenated.points[i].x == NaN) && (cloud_concatenated.points[i].y == NaN) (cloud_concatenated.points[i].y == NaN); condition2 = (cloud2.points[i].x != NaN) && (cloud2.points[i].y != NaN) (cloud2.points[i].y != NaN); if (condition1 && condition2) { cloud_concatenated.points[i].x = cloud2.points[i].x; cloud_concatenated.points[i].y = cloud2.points[i].y; cloud_concatenated.points[i].z = cloud2.points[i].z; }

}

Finally if you want to remove the Nan extra valures, just apply pcl::removeNaNFromPointCloud.

I could not test the code. so if there is any issue, please help to imporve the response :)

Hello, I amb like 5 years late, but maybe somebody search that and maybe wants a response.

I reached this place searching exactly the same, and even not finding that solution i realized two ways to solve it.

First of all, I am going to define that the reason why a point is duplicated in two pointclouds which you want to concatenate, probably (and at least is the only possibility I realise) it is because they come from the same pointcloud, whic chave been filtered in different ways (in my case, for example, i did a difference of normals filtering and a difference of grayscale filtering).

First approach: Add two or more conditions into the removal: During the filtering, there is the options of pcl:ConditionAnd and pcl::ConditionOr which can concatenate more than one conditions (with addComparison function or addCondition). This way you should be able to directly generate the filtered/concatenated pointcloud.

A main drawback? lets imagine my case in which each filtering is done using a dirrefent kind of pointcloud (pointXYZI with intensity and pcl::PointNormal with curvate) how you merge both pointclouds into one condition? here appears my second approach

Second approach

Just do as you desired originally (so, we create two independent filtered clouds). Remember in this case to set the setKeepOrganized insideconditionalremoval to false, to store the original index (the removed ones will become NaN).

Once you did that, the easies tolution is to convert both pointclouds into the same kind, something like:

pcl::copyPointCloud<pcl::pointxyzi, pcl::pointxyz="">( cloud_with_i, cloud_without_i);

and then apply the following code (dith cloud1 and cloud2 the clouds to concatenate):

pcl::PointCloud<pcl::pointxyz>

pcl::PointCloud<pcl::pointxyz> cloud_concatenated;

cloud_concatenated = cloud1; bool bool condition1=false; bool bool condition2=false; for (int i = 0; i < < cloud_concatenated.size(); i++) { { condition1 = = (cloud_concatenated.points[i].x == == NaN) && && (cloud_concatenated.points[i].y == == NaN) (cloud_concatenated.points[i].y == NaN); condition2 = (cloud2.points[i].x != NaN) && && (cloud2.points[i].y != NaN) NaN) (cloud2.points[i].y != NaN); if if (condition1 && condition2) { { cloud_concatenated.points[i].x = cloud2.points[i].x; = cloud2.points[i].x; cloud_concatenated.points[i].y = cloud2.points[i].y; = cloud2.points[i].y; cloud_concatenated.points[i].z = = cloud2.points[i].z; }

}

Finally if you want to remove the Nan extra valures, just apply pcl::removeNaNFromPointCloud.

I could not test the code. so if there is any issue, please help to imporve the response :)

click to hide/show revision 3
No.3 Revision

Hello, I amb like 5 years late, but maybe somebody search that and maybe wants a response.

I reached this place searching exactly the same, and even not finding that solution i realized two ways to solve it.

First of all, I am going to define that the reason why a point is duplicated in two pointclouds which you want to concatenate, probably (and at least is the only possibility I realise) it is because they come from the same pointcloud, whic chave been filtered in different ways (in my case, for example, i did a difference of normals filtering and a difference of grayscale filtering).

First approach: Add two or more conditions into the removal: During the filtering, there is the options of pcl:ConditionAnd and pcl::ConditionOr which can concatenate more than one conditions (with addComparison function or addCondition). This way you should be able to directly generate the filtered/concatenated pointcloud.

A main drawback? lets imagine my case in which each filtering is done using a dirrefent kind of pointcloud (pointXYZI with intensity and pcl::PointNormal with curvate) how you merge both pointclouds into one condition? here appears my second approach

Second approach

Just do as you desired originally (so, we create two independent filtered clouds). Remember in this case to set the setKeepOrganized insideconditionalremoval to false, to store the original index (the removed ones will become NaN).

Once you did that, the easies tolution is to convert both pointclouds into the same kind, something like:

pcl::copyPointCloud<pcl::pointxyzi, pcl::pointxyz="">(

pcl::copyPointCloud<pcl::PointXYZI, pcl::PointXYZ>( cloud_with_i, cloud_without_i);

cloud_without_i);

and then apply the following code (dith cloud1 and cloud2 the clouds to concatenate):

pcl::PointCloud<pcl::pointxyz> cloud_concatenated;

pcl::PointCloud<pcl::PointXYZ> cloud_concatenated;

cloud_concatenated = cloud1; bool condition1=false; bool condition2=false; condition2=false;
for (int i = 0; i < cloud_concatenated.size(); i++) { {
  condition1 = (cloud_concatenated.points[i].x == NaN) && (cloud_concatenated.points[i].y == NaN) (cloud_concatenated.points[i].y
(cloud_concatenated.points[i].y == NaN); NaN);
  condition2 = (cloud2.points[i].x != NaN) && (cloud2.points[i].y != NaN) (cloud2.points[i].y != NaN); NaN);
  if (condition1 && condition2) { {
    cloud_concatenated.points[i].x  = cloud2.points[i].x; cloud2.points[i].x;
    cloud_concatenated.points[i].y  = cloud2.points[i].y; cloud2.points[i].y;
    cloud_concatenated.points[i].z  = cloud2.points[i].z;  }

}

cloud2.points[i].z; } }

Finally if you want to remove the Nan extra valures, just apply pcl::removeNaNFromPointCloud.

I could not test the code. so if there is any issue, please help to imporve the response :)

Hello, I amb like 5 years late, but maybe somebody search that and maybe wants a response.

I reached this place searching exactly the same, and even not finding that solution i realized two ways to solve it.

First of all, I am going to define that the reason why a point is duplicated in two pointclouds which you want to concatenate, probably (and at least is the only possibility I realise) it is because they come from the same pointcloud, whic chave been filtered in different ways (in my case, for example, i did a difference of normals filtering and a difference of grayscale filtering).

First approach: Add two or more conditions into the removal: During the filtering, there is the options of pcl:ConditionAnd and pcl::ConditionOr which can concatenate more than one conditions (with addComparison function or addCondition). This way you should be able to directly generate the filtered/concatenated pointcloud.

A main drawback? lets imagine my case in which each filtering is done using a dirrefent kind of pointcloud (pointXYZI with intensity and pcl::PointNormal with curvate) how you merge both pointclouds into one condition? here appears my second approach

Second approach

Just do as you desired originally (so, we create two independent filtered clouds). Remember in this case to set the setKeepOrganized insideconditionalremoval to false, to store the original index (the removed ones will become NaN).

Once you did that, the easies tolution is to convert both pointclouds into the same kind, something like:

pcl::copyPointCloud<pcl::PointXYZI, pcl::PointXYZ>( cloud_with_i, cloud_without_i);

and then apply the following code (dith cloud1 and cloud2 the clouds to concatenate):

pcl::PointCloud<pcl::PointXYZ> cloud_concatenated;

cloud_concatenated = cloud1; bool condition1=false; bool condition2=false;
for (int i = 0; i < cloud_concatenated.size(); i++) {
  condition1 = (cloud_concatenated.points[i].x == NaN) && (cloud_concatenated.points[i].y == NaN) (cloud_concatenated.points[i].y == NaN);
  condition2 = (cloud2.points[i].x != NaN) && (cloud2.points[i].y != NaN) (cloud2.points[i].y != NaN);
  if (condition1 && condition2) {
    cloud_concatenated.points[i].x  = cloud2.points[i].x;
    cloud_concatenated.points[i].y  = cloud2.points[i].y;
    cloud_concatenated.points[i].z  = cloud2.points[i].z;
  }
}

Finally if you want to remove the Nan extra valures, just apply pcl::removeNaNFromPointCloud.

I could not test the code. so if there is any issue, please help to imporve the response :)

Hello, I amb like 5 years late, but maybe somebody search that and maybe wants a response.

I reached this place searching exactly the same, and even not finding that solution i realized two ways to solve it.

First of all, I am going to define that the reason why a point is duplicated in two pointclouds which you want to concatenate, probably (and at least is the only possibility I realise) it is because they come from the same pointcloud, whic chave been filtered in different ways (in my case, for example, i did a difference of normals filtering and a difference of grayscale filtering).

First approach: Add two or more conditions into the removal: During the filtering, there is the options of pcl:ConditionAnd and pcl::ConditionOr which can concatenate more than one conditions (with addComparison function or addCondition). This way you should be able to directly generate the filtered/concatenated pointcloud.

A main drawback? lets imagine my case in which each filtering is done using a dirrefent kind of pointcloud (pointXYZI with intensity and pcl::PointNormal with curvate) how you merge both pointclouds into one condition? here appears my second approach

Second approach

Just do as you desired originally (so, we create two independent filtered clouds). Remember in this case to set the setKeepOrganized insideconditionalremoval to false, to store the original index (the removed ones will become NaN).

Once you did that, the easies tolution is to convert both pointclouds into the same kind, something like:

pcl::copyPointCloud<pcl::PointXYZI, pcl::PointXYZ>( cloud_with_i, cloud_without_i);

and then apply the following code (dith cloud1 and cloud2 the clouds to concatenate):

pcl::PointCloud<pcl::PointXYZ> cloud_concatenated;

cloud_concatenated = cloud1; bool condition1=false; bool condition2=false;
for (int i = 0; i < cloud_concatenated.size(); i++) {
  condition1 = (cloud_concatenated.points[i].x == NaN) && (cloud_concatenated.points[i].y == NaN) (cloud_concatenated.points[i].y (cloud_concatenated.points[i].z == NaN);
  condition2 = (cloud2.points[i].x != NaN) && (cloud2.points[i].y != NaN) (cloud2.points[i].y (cloud2.points[i].z != NaN);
  if (condition1 && condition2) {
    cloud_concatenated.points[i].x  = cloud2.points[i].x;
    cloud_concatenated.points[i].y  = cloud2.points[i].y;
    cloud_concatenated.points[i].z  = cloud2.points[i].z;
  }
}

Finally if you want to remove the Nan extra valures, just apply pcl::removeNaNFromPointCloud.

I could not test the code. so if there is any issue, please help to imporve the response :)

Hello, I amb like 5 years late, but maybe somebody search that and maybe wants a response.

I reached this place searching exactly the same, and even not finding that solution i realized two ways to solve it.

First of all, I am going to define that the reason why a point is duplicated in two pointclouds which you want to concatenate, probably (and at least is the only possibility I realise) it is because they come from the same pointcloud, whic chave been filtered in different ways (in my case, for example, i did a difference of normals filtering and a difference of grayscale filtering).

First approach: Add two or more conditions into the removal: During the filtering, there is the options of pcl:ConditionAnd and pcl::ConditionOr which can concatenate more than one conditions (with addComparison function or addCondition). This way you should be able to directly generate the filtered/concatenated pointcloud.

A main drawback? lets imagine my case in which each filtering is done using a dirrefent kind of pointcloud (pointXYZI with intensity and pcl::PointNormal with curvate) how you merge both pointclouds into one condition? here appears my second approach

Second approach

Just do as you desired originally (so, we create two independent filtered clouds). Remember in this case to set the setKeepOrganized insideconditionalremoval to false, to store the original index (the removed ones will become NaN).

Once you did that, the easies tolution is to convert both pointclouds into the same kind, something like:

pcl::copyPointCloud<pcl::PointXYZI, pcl::PointXYZ>( cloud_with_i, cloud_without_i);

and then apply the following code (dith cloud1 and cloud2 the clouds to concatenate):

pcl::PointCloud<pcl::PointXYZ> cloud_concatenated;

cloud_concatenated = cloud1; bool condition1=false; bool condition2=false;
for (int i = 0; i < cloud_concatenated.size(); i++) {
  condition1 = (cloud_concatenated.points[i].x == NaN) (isnan(cloud_concatenated.points[i].x)) && (cloud_concatenated.points[i].y == NaN) (cloud_concatenated.points[i].z == NaN);
(isnan(cloud_concatenated.points[i].y)) (isnan(cloud_concatenated.points[i].z));
  condition2 = (cloud2.points[i].x != NaN) (!isnan(cloud2.points[i].x)) && (cloud2.points[i].y != NaN) (cloud2.points[i].z != NaN);
(!isnan(cloud2.points[i].y)) (!isnan(cloud2.points[i].z));
  if (condition1 && condition2) {
    cloud_concatenated.points[i].x  = cloud2.points[i].x;
    cloud_concatenated.points[i].y  = cloud2.points[i].y;
    cloud_concatenated.points[i].z  = cloud2.points[i].z;
  }
}

Finally if you want to remove the Nan extra valures, just apply pcl::removeNaNFromPointCloud.

I could not test the code. so if there is any issue, please help to imporve the response :)

Hello, I amb like 5 years late, but maybe somebody search that and maybe wants a response.

I reached this place searching exactly the same, and even not finding that solution i realized two ways to solve it.

First of all, I am going to define that the reason why a point is duplicated in two pointclouds which you want to concatenate, probably (and at least is the only possibility I realise) it is because they come from the same pointcloud, whic chave been filtered in different ways (in my case, for example, i did a difference of normals filtering and a difference of grayscale filtering).

First approach: Add two or more conditions into the removal: During the filtering, there is the options of pcl:ConditionAnd and pcl::ConditionOr which can concatenate more than one conditions (with addComparison function or addCondition). This way you should be able to directly generate the filtered/concatenated pointcloud.

A main drawback? lets imagine my case in which each filtering is done using a dirrefent kind of pointcloud (pointXYZI with intensity and pcl::PointNormal with curvate) how you merge both pointclouds into one condition? here appears my second approach

Second approach

Just do as you desired originally (so, we create two independent filtered clouds). Remember in this case to set the setKeepOrganized insideconditionalremoval to false, to store the original index (the removed ones will become NaN).

Once you did that, the easies tolution is to convert both pointclouds into the same kind, something like:

pcl::copyPointCloud<pcl::PointXYZI, pcl::PointXYZ>( cloud_with_i, cloud_without_i);

and then apply the following code (dith cloud1 and cloud2 the clouds to concatenate):

pcl::PointCloud<pcl::PointXYZ> cloud_concatenated;

cloud_concatenated = cloud1; bool condition1=false; bool condition2=false;
for (int i = 0; i < cloud_concatenated.size(); cloud_concatenated.points.size(); i++) {
  condition1 = (isnan(cloud_concatenated.points[i].x)) && (isnan(cloud_concatenated.points[i].y)) (isnan(cloud_concatenated.points[i].z));
  condition2 = (!isnan(cloud2.points[i].x)) && (!isnan(cloud2.points[i].y)) (!isnan(cloud2.points[i].z));
  if (condition1 && condition2) {
    cloud_concatenated.points[i].x  = cloud2.points[i].x;
    cloud_concatenated.points[i].y  = cloud2.points[i].y;
    cloud_concatenated.points[i].z  = cloud2.points[i].z;
  }
}

Finally if you want to remove the Nan extra valures, just apply pcl::removeNaNFromPointCloud.

I could not test the code. so if there is any issue, please help to imporve the response :)