Offset between input (sensor_msgs::PointCloud2) and its conversion to (pcl::PointCloud<pcl::PointXYZ>) [RViz]
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";
pub_test.publish(*cloud);
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";
pub_test.publish(testcloud);
}
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!