Invalid argument passed to canTransform argument source_frame in tf2 frame_ids cannot be empty错误.

PCL库中copyPointCloud两种原型

第一种:有点云索引值

 template <typename PointT> void
 pcl::copyPointCloud (const pcl::PointCloud<PointT> &cloud_in, 
                      const pcl::PointIndices &indices,
                      pcl::PointCloud<PointT> &cloud_out)
 {
   // Do we want to copy everything?
   if (indices.indices.size () == cloud_in.points.size ())
   {
     cloud_out = cloud_in;
     return;
   }
 
   // Allocate enough space and copy the basics
   cloud_out.points.resize (indices.indices.size ());
   cloud_out.header   = cloud_in.header;
   cloud_out.width    = indices.indices.size ();
   cloud_out.height   = 1;
   cloud_out.is_dense = cloud_in.is_dense;
   cloud_out.sensor_orientation_ = cloud_in.sensor_orientation_;
   cloud_out.sensor_origin_ = cloud_in.sensor_origin_;
 
   // Iterate over each point
   for (std::size_t i = 0; i < indices.indices.size (); ++i)
     cloud_out.points[i] = cloud_in.points[indices.indices[i]];
 }

第二种:无点云索引值

 template <typename PointInT, typename PointOutT> void
pcl::copyPointCloud (const pcl::PointCloud<PointInT> &cloud_in,
                     pcl::PointCloud<PointOutT> &cloud_out)
{
  // Allocate enough space and copy the basics
  cloud_out.header   = cloud_in.header;
  cloud_out.width    = cloud_in.width;
  cloud_out.height   = cloud_in.height;
  cloud_out.is_dense = cloud_in.is_dense;
  cloud_out.sensor_orientation_ = cloud_in.sensor_orientation_;
  cloud_out.sensor_origin_ = cloud_in.sensor_origin_;
  cloud_out.points.resize (cloud_in.points.size ());

  if (cloud_in.points.empty ())
    return;

  if (isSamePointType<PointInT, PointOutT> ())
    // Copy the whole memory block
    memcpy (&cloud_out.points[0], &cloud_in.points[0], cloud_in.points.size () * sizeof (PointInT));
  else
    // Iterate over each point
    for (std::size_t i = 0; i < cloud_in.points.size (); ++i)
      copyPoint (cloud_in.points[i], cloud_out.points[i]);
}

可以看到上述点云在copy的时候是将原点云的一些属性值也一同赋值了,比如header等,这个时候我们就要注意,如果我们不使用这个函数,而是使用push_back函数一个一个将点云的索引值push的时候,在索引值push结束的时候,一定要将原点云的属性值赋值给新的点云,如header,is_dence等,否则,新点云虽然可以使用,但是在使用rviz显示的时候,会出现Invalid argument passed to canTransform argument source_frame in tf2 frame_ids cannot be empty的错误.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值