ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
You had found the correct answer: pcl_ros::transformPointCloud()
is the function to call.
The generated documentation link may have changed. Try looking for it starting with the main pcl_ros
API page.
You can transform using the tf2_sensor_msgs (both C++ and Python interface, since at least Indigo):
#include <tf2_sensor_msgs.h>
#include <sensor_msgs/PointCloud2.h>
#include <geometry_msgs/TransformStamped.h>
const sensor_msgs::PointCloud2 cloud_in, cloud_out;
const geometry_msgs::TransformStamped transform;
// TODO load everything
tf2::doTransform (cloud_in, cloud_out, transform);
Or in Python:
from tf2_sensor_msgs.tf2_sensor_msgs import do_transform_cloud
cloud_out = do_transform_cloud(cloud_in, transform)
None of the codes was really tested, though I intend to use them tomorrow. If you test them and find a bug, please edit my answer. I really wonder why there aren't more tutorials for this kind of essential conversions.
tf_buffer = tf2_ros.Buffer()
tf_listener = tf2_ros.TransformListener(tf_buffer)
transform = tf_buffer.lookup_transform("camera_link","map", rospy.Time())
pcd2_camera = do_transform_cloud(pcd2, transform)
This help to trasform pointclouds2 from "map" link into camera_link
@blueflame does your code actually work? because i tried to implement it but i get
ImportError: No module named tf2_sensor_msgs.tf2_sensor_msgs
Please advise
I have tested this part of the code and am facing some offset issues, meaning there is an increasing offset issue with it. Let me explain it furthur, so I have the laser scan data in laser frame being plotted in the rviz and I then convert the same point cloud frame to odom frame and then plot the same in rviz. Initially there is an offset only in the z axis at the start position but as the robot moves the point cloud data keeps drifting away from the laser scan plot. Has anyone else faced this issue as well ?
Asked: 2012-02-04 07:07:36 -0600
Seen: 6,224 times
Last updated: Aug 13 '15
rosbag play & tf static_transform_publisher
Corrected Odometry from GMapping / Karto?
How to synchronize tfMessage and Image messages?
gazebo pr2 launch success but with tf errors
Fast triangulation of unordered point clouds - adding new clouds
No transform from [anything] to [/base_link]