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

Transforming Point Cloud

asked 2015-03-17 15:54:14 -0500

RosFan19 gravatar image


I'm trying to transform a Point Cloud from one frame to another. I'm using the method:

transformPointCloud (const std::string &target_frame, const tf::Transform &net_transform, const sensor_msgs::PointCloud2 &in, sensor_msgs::PointCloud2 &out)

I have built a transform tree and it works great. I can see well transformed image in rviz using base_link as map. I need to do some calculations on the PointCloud2 data so i need the points transformed to camera_depth frame. However when I use this method I'm not getting the result needed when I visualize the camera_depth, the image is tilted and not straight as in base_link.

listener.lookupTransform(*camera_depth, *base_link, ros::Time(0), transform);

pcl_ros::transformPointCloud(*camera_depth, transform, *msg, *msgOut);
edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2015-03-27 12:21:29 -0500

RosFan19 gravatar image

The problem was that I needed to invert the transform.

pcl_ros::transformPointCloud(*camera_depth, transform.invert(), *msg, *msgOut);

Solved the problem.

edit flag offensive delete link more



That would be because the API for lookupFrame is:

lookupTransform (const std::string &target_frame, const std::string &source_frame ..)

So it would be more sensible to have *camera_depth as your source frame, and *base_link as your target frame. Didn't catch that.

paulbovbel gravatar image paulbovbel  ( 2015-04-26 19:37:21 -0500 )edit

answered 2015-03-22 12:43:05 -0500

paulbovbel gravatar image

updated 2015-03-22 12:43:44 -0500

You've got the right API, although would be easier.

How is your transform tree setup? Make sure you understand the differences in convention between regular frames and optical-related frames ( ).

If I understand correctly, you have PointCloud data in base_link, which you want to compare to an Image in the camera_depth frame. Since a camera frame will typically be oriented z-forward, x-up, y-left, if you set 'camera_depth' to your fixed-frame in rviz and view the PointCloud, it will indeed be tilted.

edit flag offensive delete link more


I have the problem that i make base link is static publisher transform , camera link is child frame of base link. I made the point cloud to be in right perspective when fixed frame is base link. However , point cloud is still in camera depth optical frame. How can i make it to be in base link frame

dmngu9 gravatar image dmngu9  ( 2015-04-26 01:00:50 -0500 )edit

also, it always give me pcl_ros has not been declared

dmngu9 gravatar image dmngu9  ( 2015-04-26 01:43:38 -0500 )edit

Please read the tf tutorials to understand how to transform data. You would have to write a node to subscribe to the data, transform it, and republish on a new topic.

Also in the future, please ask a new question instead of resurrecting an old one.

paulbovbel gravatar image paulbovbel  ( 2015-04-26 19:35:39 -0500 )edit

Hi, I am sorry to bring this up again. I am using Indigo and have same problem with dmngu9: ‘pcl_ros’ has not been declared. Do you have any clue how to fix?

hmchung gravatar image hmchung  ( 2016-12-02 22:15:03 -0500 )edit

Question Tools



Asked: 2015-03-17 15:54:14 -0500

Seen: 6,001 times

Last updated: Mar 27 '15