#define PCL_NO_PRECOMPILE
#include <pcl/pcl_macros.h>
#include <pcl/point_types.h>
#include <pcl/point_cloud.h>
#include <Eigen/Geometry>
#include <Eigen/Dense>
#include <Eigen/Core>
namespace pcl{
struct PointXYZIR
{
PCL_ADD_POINT4D; // Macro quad-word XYZ
float intensity; // Laser intensity
uint16_t ring; // Laser ring number
EIGEN_MAKE_ALIGNED_OPERATOR_NEW // Ensure proper alignment
} EIGEN_ALIGN16;
}
POINT_CLOUD_REGISTER_POINT_STRUCT(PointXYZIR,
(float, x, x)
(float, y, y)
(float, z, z)
(float, intensity, intensity)
(uint16_t, ring, ring)
)
typedef pcl::PointCloud<pcl::PointXYZIR>::Ptr pcXYZIRPtr;
typedef pcl::PointCloud<pcl::PointXYZIR> pcXYZIR;
And then this Code:
pcXYZIRPtr test1(new pcXYZIR);
pcXYZIRPtr test2(new pcXYZIR);
pcl::PointXYZIR test_p(1.0f,1.0f,1.0f,1.0f,1);
test1->push_back(test_p);
test2->push_back(test_p);
test1 += test2;
However, this results in these errors:
error: no matching function for call to ‘pcl::PointXYZIR::PointXYZIR(float, float, float, float, int)’
error: no match for ‘operator+=’ (operand types are ‘pcXYZIRPtr’ {aka ‘boost::shared_ptr<pcl::PointCloud<pcl::PointXYZIR> >’} and ‘pcXYZIRPtr’ {aka ‘boost::shared_ptr<pcl::PointCloud<pcl::PointXYZIR> >’})
92 | test1 += test2;
This means that i can't use my own custom point type like any normal point type, e.g. pcl::PointXYZI
.
What do i need to change in order for this to work? I tried without namespace pcl
and with, but it does not work in both ways.
So i eventually fixed the first error message with this new code (adapted the name of the new integer variable as well):
#define PCL_NO_PRECOMPILE
#include <pcl/pcl_macros.h>
#include <pcl/point_types.h>
namespace pcl {
struct PointXYZIL
{
PCL_ADD_POINT4D; // preferred way of adding a XYZ+padding
float intensity;
int label;
PointXYZIL(float x, float y, float z, float intensity, int label) : x(x), y(y), z(z), intensity(intensity), label(label) {}
PointXYZIL() : x(0.0), y(0.0), z(0.0), intensity(0.0), label(0) {}
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 (pcl::PointXYZIL,
(float, x, x)
(float, y, y)
(float, z, z)
(float, intensity, intensity)
(int, label, label)
)
For the second error message i adopted the answer by @sehe.