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

pcl to tf - example for pcl::transformPointCloud

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

mmyself gravatar image

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

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 (http://wiki.ros.org/pcl_ros#CA-1e7f8563c53a97f77516b3fe5ea24f4b33d237de_3)

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);
  tf_pub.publish(pcl_out);

  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();

  ros::spin();
  //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

Comments

My question so stupid?

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

Please be patient, support for this community is a voluntary effort. wiki.ros.org/Support

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

3 Answers

Sort by ยป oldest newest most voted
0

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

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

Comments

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? http://lars.mec.ua.pt/lartk/doc/plane_model_road_segmentation/html/transform__cloud__nodelet_8cpp_source.html many thx for your patient, tf is a hard concept for me ;)

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

Have you gone through all the tf tutorials? http://wiki.ros.org/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 -0600 )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 -0600 )edit
1

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

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. https://github.com/ethz-asl/ethzasl_ptam/blob/master/ptam/src/PTAMVisualizer.cpp

  3. my fault was: i don't know that i can gave many topics the same frame.id 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 frame.id /world and everything works great. i can see the cloud in rivz :)

edit flag offensive delete link more
0

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

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

3 followers

Stats

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

Seen: 14,878 times

Last updated: Mar 21 '14