这是我在程序中遇到的 C++ 构造函数问题。
问题出现在这里,程序中没有检测到cyclical_的构造函数。这里
pcl::gpu::kinfuLS::KinfuTracker::KinfuTracker
( const Eigen::Vector3f &volume_size, const float shiftingDistance,
int rows, int cols) :
//
// error lies here, no matching function for cyclical_()
//
cyclical_( DISTANCE_THRESHOLD, VOLUME_SIZE, VOLUME_X ),
rows_(rows), cols_(cols), global_time_(0), max_icp_distance_(0),
integration_metric_threshold_(0.f),
perform_last_scan_ (false), finished_(false), lost_ (false),
disable_icp_ (false), perform_segmentation_(false)
{
....
}
Cyclical_ 类的定义和引用都很好。它被定义为以下之一。完整的原始完整在这里。https://github.com/lvzhaoyang/pcl/blob/master/gpu/kinfu_large_scale/include/pcl/gpu/kinfu_large_scale/kinfu.h 我在我的程序中添加了一些参数,但是我没有改变任何与CyclicalBuffer相关的东西.
CyclicalBuffer cyclical_;
CyclicalBuffer object_cyclical_; // another member of type CyclicalBuffer, but the error shows the former one, not this one. Someone say it might affect.
enum { VOLUME_X = 512, VOLUME_Y = 512, VOLUME_Z = 512 };
const float VOLUME_SIZE = 3.0f;
const float DISTANCE_THRESHOLD = 1.5f;
CyclicalBuffer 类定义如下。原文在这里:https ://github.com/lvzhaoyang/pcl/blob/master/gpu/kinfu_large_scale/include/pcl/gpu/kinfu_large_scale/cyclical_buffer.h这部分我什么都没改。
namespace pcl
{
namespace gpu
{
namespace kinfuLS
{
class PCL_EXPORTS CyclicalBuffer
{
public:
CyclicalBuffer (const double distance_threshold, const double cube_size = 3.f, const int nb_voxels_per_axis = 512)
{
distance_threshold_ = distance_threshold;
buffer_.volume_size.x = cube_size;
buffer_.volume_size.y = cube_size;
buffer_.volume_size.z = cube_size;
buffer_.voxels_size.x = nb_voxels_per_axis;
buffer_.voxels_size.y = nb_voxels_per_axis;
buffer_.voxels_size.z = nb_voxels_per_axis;
}
CyclicalBuffer (const double distance_threshold, const double volume_size_x, const double volume_size_y, const double volume_size_z, const int nb_voxels_x, const int nb_voxels_y, const int nb_voxels_z)
{
distance_threshold_ = distance_threshold;
buffer_.volume_size.x = volume_size_x;
buffer_.volume_size.y = volume_size_y;
buffer_.volume_size.z = volume_size_z;
buffer_.voxels_size.x = nb_voxels_x;
buffer_.voxels_size.y = nb_voxels_y;
buffer_.voxels_size.z = nb_voxels_z;
}
...
}
}
};
但是当我编译问题时,它给出了这样的错误:
/home/lv/pcl-trunk/gpu/kinfu_large_scale/src/kinfu.cpp: In constructor ‘pcl::gpu::kinfuLS::KinfuTracker::KinfuTracker(const Vector3f&, float, int, int)’:
/home/lv/pcl-trunk/gpu/kinfu_large_scale/src/kinfu.cpp:85:53: error: no matching function for call to ‘pcl::gpu::kinfuLS::CyclicalBuffer::CyclicalBuffer()’
/home/lv/pcl-trunk/gpu/kinfu_large_scale/src/kinfu.cpp:85:53: note: candidates are:
/home/lv/pcl-trunk/gpu/kinfu_large_scale/include/pcl/gpu/kinfu_large_scale/cyclical_buffer.h:96:11: note: pcl::gpu::kinfuLS::CyclicalBuffer::CyclicalBuffer(double, double, double, double, int, int, int)
/home/lv/pcl-trunk/gpu/kinfu_large_scale/include/pcl/gpu/kinfu_large_scale/cyclical_buffer.h:96:11: note: candidate expects 7 arguments, 0 provided
/home/lv/pcl-trunk/gpu/kinfu_large_scale/include/pcl/gpu/kinfu_large_scale/cyclical_buffer.h:75:11: note: pcl::gpu::kinfuLS::CyclicalBuffer::CyclicalBuffer(double, double, int)
/home/lv/pcl-trunk/gpu/kinfu_large_scale/include/pcl/gpu/kinfu_large_scale/cyclical_buffer.h:75:11: note: candidate expects 3 arguments, 0 provided
/home/lv/pcl-trunk/gpu/kinfu_large_scale/include/pcl/gpu/kinfu_large_scale/cyclical_buffer.h:65:25: note: pcl::gpu::kinfuLS::CyclicalBuffer::CyclicalBuffer(const pcl::gpu::kinfuLS::CyclicalBuffer&)
/home/lv/pcl-trunk/gpu/kinfu_large_scale/include/pcl/gpu/kinfu_large_scale/cyclical_buffer.h:65:25: note: candidate expects 1 argument, 0 provided
我不太明白候选人期望 3 个参数,0 提供的错误。我想我已经提供了正确数量的论据,并且所有内容都被明确提及。
感谢您讨论我的问题。我想我找到了一些线索,但我不知道为什么。问题可能出在 CyclicalBuffer 类型的第二个成员上。
CyclicalBuffer cyclical_;
CyclicalBuffer object_cyclical_; // when I comment everything related to this. The error disappears.
这似乎很奇怪。我不知道第二个成员如何对第一个成员给出错误。如果是object_cyclical_构造不正确的问题,为什么会在cyclical_上报错?为了确保,错误报告第 85 行是 cyclical_( DISTANCE_THRESHOLD, VOLUME_SIZE, VOLUME_X ) 的行
谁能帮我指出它存在的潜在问题?