ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | Q&A answers.ros.org
Ask Your Question
0

Filtering sensor_msgs::PointCloud2 agnostic of point type

asked 2019-02-24 21:05:51 -0600

abhinavkulkarni gravatar image

Hi,

I am writing a basic filtering pipeline for 3D data (can be XYZRGB or RGBD or other types). My steps are as follows:

  1. Firstly, convert sensor_msgs::PointCloud2 to pcl::PointCloud<T>. I want to work with pcl::PointCloud<T> instead of pcl::PointCloud2 because the former is recommended (as mentioned here) and some of the filters play nice with it (rather than pcl::PointCloud2).
  2. Once I have converted sensor_msgs::PointCloud2 to pcl::PointCloud<T>, then I have some generic filtering code that filters regardless of the template type T (wether it is pcl::PointXYZRGB or pcl::PointXYZRGBA or pcl::PointXYZI).

So, how do I determine (at runtime) template type T?

Thanks.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-02-25 05:14:57 -0600

Short answer. You don't, the compiler needs to resolve templates at compile time, they do not give you run-time versatility. Using the templated method you will not be able to make a completely PointType agnostic implementation. Also custom point types can be defined by developers so you cannot always determine the type.

You will need separate code for each possible point type. However this can be done using a case statement and instantiating the correct type of filter object, so isn't as bad as it sounds.

If you kept within the PointCloud2 type, this defines the meta-data describing the point type itself. So if you identifed the X, Y and Z types and locations and the size of the point type then you could build a completely PointType agnostic filter.

Hope this helps.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2019-02-24 21:05:51 -0600

Seen: 350 times

Last updated: Feb 25 '19