Ask Your Question
0

transformPointCloud unconnected to tf_broadcaster

asked 2016-06-06 08:39:39 -0500

marilia15 gravatar image

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.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-06-06 12:16:21 -0500

joq gravatar image

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.)

edit flag offensive delete link more

Comments

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]

marilia15 gravatar imagemarilia15 ( 2016-06-08 08:00:05 -0500 )edit

Sounds like something is wrong with your `tf tree or your clock.

joq gravatar imagejoq ( 2016-06-08 15:31:44 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-06-06 08:39:39 -0500

Seen: 165 times

Last updated: Jun 06 '16