0
$\begingroup$

Rosanswers logo

I am using the code tf_broadcaster from the ROS tutorial, but I am using "base_link" and "velodyne" as parent and children in the transformation. I am using "velodyne" because is the frame_id of the pointcloud that my scanner is publishing, please let me know if it is not necessary to have the same name.

And I am using this code for subscribing a pointcloud2 and tf messages and publish a new pointcloud2:

ros::Publisher pub;
tf::Transform transform;
sensor_msgs::PointCloud2 msg2;

void chatterCallback(const sensor_msgs::PointCloud2::ConstPtr& msg) 
{ 
  tf::TransformListener tf_listener;
  pcl_ros::transformPointCloud("velodyne", *msg, msg2, tf_listener);    
  pub.publish(msg2);        
}

int main(int argc, char **argv)
{
  ros::init(argc, argv, "pc2tfpc");
  ros::NodeHandle n ; 
  ros::Subscriber sub = n.subscribe("velodyne_points", 1, chatterCallback); 
  pub=n.advertise<sensor_msgs::PointCloud2>("tfpc",1); 
  ros::spin();
  return 0;
}

I can compile code and execute but the new pointcloud2 has not been transformed with the published tf (I checked it on rviz)

rostopic echo /tf shows the right transformation.

rosrun rqt_graph rqt_graph shows that my code is not subscribed to /tf

If I change the target_frame to "velodyne" ( pcl_ros::transformPointCloud("velodyne", *msg, msg2, tf_listener); ) then I get this error in the execution: "base_link" passed to lookupTransform argument target_frame does not exist.

Anybody has an idea about what is wrong? Thanks in advance.


Originally posted by marilia15 on ROS Answers with karma: 104 on 2016-06-06

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Assuming your tf tree is set up correctly, velodyne_pointcloud provides a transform nodelet that can perform this operation for you.

In your case, set the frame_id parameter to "base_link". (The default is "odom", which is usually what people want.)


Originally posted by joq with karma: 25443 on 2016-06-06

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by marilia15 on 2016-06-08:
I run the velodyne_node to publish raw data, the tf_broadcaster from the tutorial (parent "base_link", children "velodyne") and the transform_node _frame_id:=/base_link and a calibration file. I get error: Lookup would require extrapolation into the past...from frame [velodyne] to [base_link]

Comment by joq on 2016-06-08:
Sounds like something is wrong with your ```tf`` tree or your clock.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.