Ask Your Question
2

How to convert a PointCloud via tf2

asked 2014-09-29 15:30:32 -0500

v4hn gravatar image

Hey there,

I tried to write some pretty simple code with tf2 and I'm stuck already.

How does one transform a pcl::PointCloud<...> when using tf2 (and, less importantly, how about transforming a sensor_msgs/PointCloud2)? With tf there is the pcl_ros package which can transform pcl-PointClouds with tf::Transform. There's also pcl's own transformation interface pcl::transformPointCloud which takes Transforms as Eigen matrices.

However, tf2_ros::Buffer::lookupTransform, which seems to be the right interface to use, only returns geometry_msgs::TransformStamped and I can't find a one-liner to convert these (or, well, more likely the wrapped geometry_msgs::Transform to Eigen::Matrix4f or similar.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2014-09-29 23:43:50 -0500

tfoote gravatar image

updated 2014-09-29 23:45:56 -0500

@vincent Rabaud recently opened a pull request to add support for exactly that. The pull-request is here. https://github.com/ros/geometry_exper... It will probably be merged and deployed after a review.

edit flag offensive delete link more

Comments

Thanks, that answers one question.

What do we do about pcl::PointClouds? To use pcl::transformPointCloud we'd need a function to convert geometry_msgs::Transform to Eigen::Matrix4f. Could tf2::convert do that?

Otoh, pcl_ros is quite useful already, so how about extending its transforms.h?

v4hn gravatar image v4hn  ( 2014-09-30 06:54:54 -0500 )edit

Should the latter be done by adding pcl_ros::transformPointCloud functions for geometry_msgs::TransformStamped (which makes sense in the context of pcl_ros) or by adding tf2::doTransform functions there (which makes sense in the context of tf2)?

v4hn gravatar image v4hn  ( 2014-09-30 06:57:05 -0500 )edit
1

If you want to use the pcl transform function, just use eigen_conversions to convert the transform into the needed eigen matrix.

tfoote gravatar image tfoote  ( 2014-09-30 15:52:59 -0500 )edit

Thanks, I didn't know about that package!

v4hn gravatar image v4hn  ( 2014-10-01 07:19:10 -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: 2014-09-29 15:30:32 -0500

Seen: 2,023 times

Last updated: Sep 29 '14