PointCloud2 for laser_geometry
I am using a code snippet from laser_geometry tutorial. I've tried to use this code using PointCloud type (instead of PointCloud2), but it doesn't work.
laser_geometry::LaserProjection projector_;
tf::TransformListener listener_;
void scanCallback (const sensor_msgs::LaserScan::ConstPtr& scan_in)
{
sensor_msgs::PointCloud cloud;
projector_.transformLaserScanToPointCloud("base_link",*scan_in,cloud,listener_);
// Do something with cloud.
}
How does the signature of the line,
projector_.transformLaserScanToPointCloud("base_link",*scan_in,cloud,listener_);
look like if I would use it with PointCloud2 data type?
Another question, what is the benefit of using PointCloud2 as opposed to PointCloud?