Error error in operand of ‘->’ which has non-pointer type ‘sensor_msgs::PointCloud’
I wrote a code to convert from laserscan points to sonar scan point from the following link
wiki.ros.org/laser_geometry where they provide the following code
Laser_geometry::LaserProjection projector_;
tf::TransformListener listener_;
void scanCallback (const sensor_msgs::LaserScan::ConstPtr& scan_in)
{
if(!listener_.waitForTransform(
scan_in->header.frame_id,
"/base_link",
scan_in->header.stamp + ros::Duration().fromSec(scan_in->ranges.size()*scan_in->time_increment),
ros::Duration(1.0))){
return;
}
sensor_msgs::PointCloud cloud;
projector_.transformLaserScanToPointCloud("/base_link",*scan_in,
cloud,listener_);
// Do something with cloud.
}
This what I added only
Laser_geometry::LaserProjection projector_;
tf::TransformListener listener_;
void scanCallback (const sensor_msgs::LaserScan::ConstPtr& scan_in)
{
if(!listener_.waitForTransform(
scan_in->header.frame_id,
"/base_link",
scan_in->header.stamp + ros::Duration().fromSec(scan_in->ranges.size()*scan_in->time_increment),
ros::Duration(1.0))){
return;
}
sensor_msgs::PointCloud cloud;
projector_.transformLaserScanToPointCloud("/base_link",*scan_in,
cloud,listener_);
// Do something with cloud.
// this what I added it
for(int i=0; i< cloud->points.size(); ++i)
{
Eigen::Vector3d data(cloud->points[i].x,cloud->points[i].y,0.0);
}
}
I got the following error base operand of ‘->’ has non-pointer type ‘sensor_msgs::PointCloud’
how can I solve it ?