I have a header file preprocess.h
in the include folder that simply does noise removal from a point cloud. The point type of point cloud does not exist in the pcl library so I have to create a custom point type RadarPoint
for pcl::PointCloud<PointT>
. Also, it's a good practice to create a namespace for functions inside the header file. The following is my code.
#ifndef PREPROCESS_H
#define PREPROCESS_H
#define PCL_NO_PRECOMPILE
#include <ros/ros.h>
#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/pcl_macros.h>
#include <pcl/filters/statistical_outlier_removal.h>
namespace filtration {
struct RadarPoint {
PCL_ADD_POINT4D; // preferred way of adding a XYZ padding
uint8_t beam_side;
EIGEN_MAKE_ALIGNED_OPERATOR_NEW // make sure our new allocators are aligned
} EIGEN_ALIGN16; // enforce SSE padding for correct memory alignment
POINT_CLOUD_REGISTER_POINT_STRUCT (RadarPoint, // here we add XYZ and beam_side
(float, x, x)
(float, y, y)
(float, z, z)
(uint8_t, beam_side, beam_side)
)
//remove outliers from point cloud
pcl::PointCloud<RadarPoint>::Ptr filter(const pcl::PointCloud<RadarPoint>::Ptr& cloud_input);
}
#endif
However, there are some bugs. For the function, I got the error "namespace filtration::pcl" has no member PointCloud
. For the custom PointT
, I got the two errors. The first error is namespace "filtration::pcl" has no member "Vector3fMap"
for the code PCL_ADD_POINT4D;
. The second error is improperly terminated macro invocation
for the code POINT_CLOUD_REGISTER_POINT_STRUCT
. Any help on why and how to solve them?
CodePudding user response:
POINT_CLOUD_REGISTER_POINT_STRUCT
must be used in the global namespace: https://github.com/PointCloudLibrary/pcl/blob/master/common/include/pcl/register_point_struct.h#L63
See also how the macro is used in PCL: https://github.com/PointCloudLibrary/pcl/blob/master/common/include/pcl/impl/point_types.hpp#L1781