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

Offset between input (sensor_msgs::PointCloud2) and its conversion to (pcl::PointCloud<pcl::PointXYZ>) [RViz]

asked 2019-06-19 09:26:38 -0600

sm0ke gravatar image

I have a input cloud called cloud of type sensor_msgs::PointCloud2ConstPtr& and want to convert it to cloud_conv of type enter code here :

void callback(const sensor_msgs::PointCloud2ConstPtr& cloud)
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_conv (new pcl::PointCloud<pcl::PointXYZ>);
pcl::fromROSMsg(*cloud, *cloud_conv);

Publishing *cloud into Rviz directly without conversion plots the correct result as a sanity check:

sensor_msgs::PointCloud2 testcloud;
testcloud.header.frame_id = "base_link";

However plotting the converted cloud (and reconverted back) shows the correct cloud in RViz but with some offset in all x,y, and z directions:

sensor_msgs::PointCloud2 testcloud;
pcl::toROSMsg(*cloud_conv, testcloud);
testcloud.header.frame_id = "base_link";

So my question is, how to I make sure testcloud has no offset in x,y,z in regards to the input (reference) cloud *cloud? Is there some parameter for this that I'm missing? I have tried searching and am lost, thank you!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-06-20 11:08:22 -0600

sm0ke gravatar image

The error was not taking the right reference frame, beginner mistake :)

edit flag offensive delete link more

Question Tools



Asked: 2019-06-19 09:26:38 -0600

Seen: 368 times

Last updated: Jun 20 '19