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

problem with custom point cloud type

asked 2013-09-16 18:56:17 -0500

brice rebsamen gravatar image

Hello

I want to create my own point type for my point cloud. Something similar to velodyne_pointcloud. So I created my point type, copying what joq did and adding my own fields to it. Then I used the POINT_CLOUD_REGISTER_POINT_STRUCT to declare (?) it.

I want to publish it and receive it as a pcl::PointCloud so I included the pcl_ros/point_cloud.h header file.

But I get compilation errors: no member name __getMD5Sum, __getDataType, serialize, etc.

According to the documentation, it should be possible to work directly with pcl::PointCloud<t>.

I read the code in velodyne_pointcloud over and over, and I also a created a small test package to test custom point cloud types and it worked. But I can't fix my "real" code. Please help, it's driving me crazy.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2013-09-17 08:25:55 -0500

brice rebsamen gravatar image

updated 2015-06-24 11:57:50 -0500

I found the solution: I was declaring my point cloud as

namespace velodyne {
struct PointType : pcl::PointXYZRGB { ... };
struct PointCloud : pcl::PointCloud<PointType> { ... };
}

but if I use a typedef instead then my compilation error disappears:

namespace velodyne {
struct PointType : pcl::PointXYZRGB { ... };
typedef PointCloud<PointType> PointCloud;
}

EDIT: Actually, I am now declaring my point type following PCL's model: it does not inherit from pcl::PointXYZRGB but rather copies the body of pcl::PointXYZRGB. In the end it looks as follows:

namespace velodyne
{
struct EIGEN_ALIGN16 _PointType
{
  PCL_ADD_POINT4D;
  PCL_ADD_RGB;
  ...
  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
};

struct EIGEN_ALIGN16 PointType : public _PointType
{
  inline PointType () {  ... }
}

} // namespace velodyne

POINT_CLOUD_REGISTER_POINT_STRUCT (velodyne::_PointType,
    (float, x, x)
    (float, y, y)
    (float, z, z)
    (uint32_t, rgb, rgb)
    ...
)
POINT_CLOUD_REGISTER_POINT_WRAPPER(velodyne::PointType, velodyne::_PointType)

namespace velodyne {    
typedef pcl::PointCloud<PointType> PointCloud;
typedef boost::shared_ptr<PointCloud> PointCloudPtr;
typedef boost::shared_ptr<PointCloud const> PointCloudConstPtr;
} // namespace velodyne
edit flag offensive delete link more
0

answered 2013-09-17 01:47:55 -0500

Philip gravatar image

updated 2013-09-17 01:56:36 -0500

Just out of my head, it's been a couple of months: I stumbled upon something similar and it wasn't because of the custom type, but of how I used the publisher. Check if you

  • pass the correct object
  • template the publisher correctly
  • and similar stuff...

Hope this helps!


EDIT: Just looked it up. Here's the relevant parts of my code copied together:

ros::Publisher myPublisher;
sensor_msgs::PointCloud2::Ptr cloudPtr;
<fill the cloud>
myPublisher = n.advertise<sensor_msgs::PointCloud2>("topic/name", 10);
myPublisher.publish(cloudPtr);

However, I directly fill the sensor_msgs::PointCloud2 datatype of ROS instead of using the PCL one.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2013-09-16 18:56:17 -0500

Seen: 1,875 times

Last updated: Jun 24 '15