ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

pcl to tf - example for pcl::transformPointCloud

asked 2013-10-13 00:21:10 -0500

mmyself gravatar image

updated 2014-01-28 17:18:13 -0500

ngrennan gravatar image

I am looking for a working example for translating a pointcloud to tf. Here is my example based on the examples here. pcl_ros tutorials (

typedef pcl::PointCloud<pcl::PointXYZ> PointCloud;

ros::Publisher tf_pub;
tf::TransformListener *tf_listener; 

void callback(const PointCloud::ConstPtr& pcl_in)

  PointCloud pcl_out;

  tf_listener->waitForTransform("/world", (*pcl_in).header.frame_id, (*pcl_in).header.stamp, ros::Duration(5.0));
  pcl_ros::transformPointCloud("/world", *pcl_in, pcl_out, *tf_listener);

  printf ("Cloud: width = %d, height = %d\n", pcl_in->width, pcl_in->height);
  BOOST_FOREACH (const pcl::PointXYZ& pt, pcl_in->points)
    printf ("\t(%f, %f, %f)\n", pt.x, pt.y, pt.z);

int main(int argc, char** argv)
  ros::init(argc, argv, "sub_pcl");
  ros::NodeHandle nh;
  ros::Subscriber sub = nh.subscribe<PointCloud>("points2", 1, callback);
  tf_pub = nh.advertise<PointCloud> ("tf_points2", 1);

  tf_listener    = new tf::TransformListener();

  //delete tf_listener; 
  //return 0; 

this resumes in the following error.

[ERROR] [1381659561.691872448]: Frame id /pcl does not exist! Frames (3): Frame /world_marker exists with parent /world.
Frame /world exists with parent NO_PARENT.

the frame_id /pcl exists. rxgraph show that is all connected and well.

anybody there who can tell me what i'm doing wrong or maybe has a working example for me?

update: after looking around and trying a lot, i didn't find a working example anyway. the above code is not what i'am searching for. i was on the wrong lane, by googling to the theme pcl to tf.

i was looking for an example for maybe an /world frame and the /pcl frame from pcl_ros tutorial above. must i transform any point of the pointcloud or ...??? don't no what to do.

at the end, i only want a /world -> /camera -> /pcl tf chain for the ardrone. but stick in the pcl to tf thing and didn't come further :(

anybody out there who can help me at this point.

edit retag flag offensive close merge delete


My question so stupid?

mmyself gravatar image mmyself  ( 2013-10-14 00:25:38 -0500 )edit

Please be patient, support for this community is a voluntary effort.

tfoote gravatar image tfoote  ( 2013-10-14 11:11:23 -0500 )edit

3 Answers

Sort by ยป oldest newest most voted

answered 2013-10-14 11:10:18 -0500

tfoote gravatar image

It appears that your incoming data is in the frame "/pcl" but "/pcl is not published as a tf frame_id. Only "/world" and "/world_marker" exist.

You can see your frame tree with the tf package view_frames. Something needs to publish the transform from "/pcl" to "/world" or you need to update what frame the recieved point cloud is stamped as being originated.

edit flag offensive delete link more


thx a lot tfoote, "but "/pcl is not published as a tf frame_id". this is what i also thought, after a long night yesterday. but this is exactly what i want. so i'm back to my question, how can i bring a pcl to tf. if i was searching on google for pcl to tf i found only examples in the above way. Must i only make a tf broadcaster for the pcl? You know an example file in ros where i can see how this work? maybe this i a good example? many thx for your patient, tf is a hard concept for me ;)

mmyself gravatar image mmyself  ( 2013-10-14 22:43:59 -0500 )edit

Have you gone through all the tf tutorials? That should help you understand the basic concepts. You can either add a broadcaster or change the incoming data.

tfoote gravatar image tfoote  ( 2013-10-15 07:01:09 -0500 )edit

i know the tutorials and have other tf solutions working. my prob is the pcl to tf thing. hope i can post the solution here. try to bring the above link to work. and will post it.

mmyself gravatar image mmyself  ( 2013-10-15 23:45:21 -0500 )edit

answered 2013-10-23 22:18:06 -0500

mmyself gravatar image
  1. tully's answer is absolut correct, to my question.

  2. the answer i need, i found here. here happens the tranformation stuff.

  3. my fault was: i don't know that i can gave many topics the same and that there must only one tf for two different frames to work in rviz, in my case world->camera. So i gave the pcl topic also the /world and everything works great. i can see the cloud in rivz :)

edit flag offensive delete link more

answered 2014-03-21 04:51:24 -0500

keygeorge gravatar image

you must broadcast /pcl frame over ros,in order to let tf establish the connections between /pcl and other frames in the tf frame tree,then you can transform the pointcloud between any two frames

edit flag offensive delete link more

Question Tools



Asked: 2013-10-13 00:21:10 -0500

Seen: 14,713 times

Last updated: Mar 21 '14