copy cloud with header in filtre
This commit is contained in:
parent
c36ff5a5aa
commit
91c4cf5e77
1 changed files with 17 additions and 4 deletions
|
@ -3,7 +3,8 @@
|
||||||
#include <pcl/point_types.h>
|
#include <pcl/point_types.h>
|
||||||
#include <pcl/filters/passthrough.h>
|
#include <pcl/filters/passthrough.h>
|
||||||
|
|
||||||
typedef pcl::PointCloud<pcl::PointXYZRGB> PointCloud;
|
typedef pcl::PointXYZRGB Point;
|
||||||
|
typedef pcl::PointCloud<Point> PointCloud;
|
||||||
|
|
||||||
class Callback {
|
class Callback {
|
||||||
public:
|
public:
|
||||||
|
@ -11,10 +12,11 @@ class Callback {
|
||||||
operator()(const PointCloud::ConstPtr& msg)
|
operator()(const PointCloud::ConstPtr& msg)
|
||||||
{
|
{
|
||||||
PointCloud::Ptr pcl(new PointCloud());
|
PointCloud::Ptr pcl(new PointCloud());
|
||||||
for (int i = 0; i < msg->points.size(); ++i)
|
copy_info(msg, pcl);
|
||||||
|
BOOST_FOREACH (const Point& pt, msg->points)
|
||||||
{
|
{
|
||||||
if (msg->points[i].z < zmax)
|
if (pt.z < zmax)
|
||||||
pcl->points.push_back(msg->points[i]);
|
pcl->push_back(pt);
|
||||||
}
|
}
|
||||||
publisher.publish(pcl);
|
publisher.publish(pcl);
|
||||||
}
|
}
|
||||||
|
@ -25,6 +27,17 @@ class Callback {
|
||||||
private:
|
private:
|
||||||
ros::Publisher publisher;
|
ros::Publisher publisher;
|
||||||
float zmax;
|
float zmax;
|
||||||
|
|
||||||
|
inline
|
||||||
|
void
|
||||||
|
copy_info(const PointCloud::ConstPtr& a,
|
||||||
|
PointCloud::Ptr b)
|
||||||
|
{
|
||||||
|
b->header = a->header;
|
||||||
|
b->sensor_origin_ = a->sensor_origin_;
|
||||||
|
b->sensor_orientation_ = a->sensor_orientation_;
|
||||||
|
b->is_dense = a->is_dense;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Reference in a new issue