|
@@ -24,19 +24,25 @@ static void points_callback(const sensor_msgs::PointCloud2::ConstPtr &input)
|
|
|
|
|
|
pcl::fromROSMsg(*input, point_cloud);
|
|
|
|
|
|
- int pointsize = point_cloud.width;
|
|
|
+ int pointsize = point_cloud.points.size();
|
|
|
int i;
|
|
|
int nskip = 0;
|
|
|
|
|
|
pcl::PointCloud<pcl::PointXYZI>::Ptr point_cloud_filter(
|
|
|
new pcl::PointCloud<pcl::PointXYZI>());
|
|
|
point_cloud_filter->header = point_cloud.header;
|
|
|
+
|
|
|
+ point_cloud_filter->width = 0;
|
|
|
+ point_cloud_filter->height = 1;
|
|
|
+
|
|
|
+ std::cout<<" point width "<<point_cloud.width<<" size: "<<point_cloud.points.size()<<std::endl;
|
|
|
for(i=0;i<pointsize;i++)
|
|
|
{
|
|
|
double x,y,z;
|
|
|
- x = point_cloud.at(i).x;
|
|
|
- y = point_cloud.at(i).y;
|
|
|
- z = point_cloud.at(i).z;
|
|
|
+ x = point_cloud.points.at(i).x;
|
|
|
+ y =point_cloud.points.at(i).y;
|
|
|
+ z =point_cloud.points.at(i).z;
|
|
|
+
|
|
|
if(std::isnan(x) ||(std::isnan(y))||std::isnan(z))
|
|
|
{
|
|
|
nskip++;
|
|
@@ -47,12 +53,18 @@ static void points_callback(const sensor_msgs::PointCloud2::ConstPtr &input)
|
|
|
nskip++;
|
|
|
continue;
|
|
|
}
|
|
|
- point_cloud_filter->points.push_back(point_cloud.at(i));
|
|
|
+
|
|
|
+ pcl::PointXYZI point;
|
|
|
+ point.x = x;
|
|
|
+ point.y = y;
|
|
|
+ point.z = z;
|
|
|
+ point.intensity = point_cloud.points.at(i).intensity;
|
|
|
+ point_cloud_filter->points.push_back(point);
|
|
|
++point_cloud_filter->width;
|
|
|
}
|
|
|
|
|
|
std::cout<<" skip nan point count: "<<nskip<<" out point count: "<<point_cloud_filter->width<<std::endl;
|
|
|
- point_cloud_pub.publish(point_cloud);
|
|
|
+ point_cloud_pub.publish(point_cloud_filter);
|
|
|
}
|
|
|
|
|
|
|