Scan lines are not gathered in generating a point cloud
I've have built a point cloud, nevertheless, it is not fully working in the sense that when I watch in rviz, it shows only scan lines. Of course I can I a kind of cloud if i set the decay value in rviz as high as possible, but, it is just a fake one if I do that. I have followed this tutorial, anyway, to build the point cloud.
What I can see is that since the code snippet(see below) for building the point cloud resides in a function, that always being called, including to provide a new scan. It seems that, it enter the function, the cloud object is deleted and replaced with a new one, instead of accumulated over time. Then, I start to put the cloud variable as a class member variable, even though, in the tutorial, it is declared as a local variable. The problem after making it a class member variable is that, in rviz the message is not received(a kind of complaint).
I've tried to comment the transformLaserScanToPointCloud call, and no scan lines at all appears. This could mean, it somehow enters the try block.
Anyone know how to improve this? or Am i using the wrong function transformLaserScanToPointCloud call to implement building a point cloud.
Thanks in advance.
The code snippet(resides in a callback function):
sensor_msgs::PointCloud cloud;
static tf::TransformBroadcaster tfb;
tf::Transform xform;
xform.setOrigin(tf::Vector3(pose3D_LDD.pose.position.x, pose3D_LDD.pose.position.y, pose3D_LDD.pose.position.z));
xform.setRotation(tf::Quaternion(pose3D_LDD.pose.orientation.x, pose3D_LDD.pose.orientation.y, pose3D_LDD.pose.orientation.z, pose3D_LDD.pose.orientation.w));
tfb.sendTransform(tf::StampedTransform(xform, ros::Time(pose3D_LDD.header.stamp), "base_link", "laser"));
tfListener_.waitForTransform("base_link", "laser", previous_scan_.header.stamp, ros::Duration(2.0));
try
{
projector_.transformLaserScanToPointCloud("base_link", previous_scan_, cloud, tfListener_);
}
catch (tf::TransformException ex)
{
ROS_WARN("Problem: %s", ex.what());
}