laser_geometry waitfor transformation not working

asked 2015-01-05 08:13:44 -0600

RSA_kustar gravatar image

I used the following example from one of the wiki tutorials:

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))){
     std::cout << "HERE" << std::endl; 
  return;
} 

  sensor_msgs::PointCloud cloud;
  projector_.transformLaserScanToPointCloud("/base_link",*scan_in,
      cloud,listener_);

   array.clear();
   // Do something with cloud. the following is what I am doing 
for(int i=0; i< cloud.points.size(); ++i)
{
    Eigen::Vector3d obstacle(cloud.points[i].x,cloud.points[i].y,0.0);
    array.push_back(obstacle);
} // end of the for loop


 }

I have my class where I added the following two lines in the constructor

laser_geometry::LaserProjection projector_;
tf::TransformListener listener_;

I am doing a laserCall back function for laser data and then I want to use the above code to transfare the data from the laser frame to the baselink frame and for each point I have the x, y point related to the base link frame.

What i get is the output HERE and it never do the transformation ??

Also, if I am using this code is it needed to do a static transformation between the base frame and the laser frame ?? I dont have a dynamic callibration ??

edit retag flag offensive close merge delete