我是 MRPT 的新手,我想用它来使用 velodyne 点云构建占用网格地图。
KITTI 数据集提供 (x,y,z,r) 格式的 velodyne 点云,其中 r 是反射率。我正在尝试用此类数据填充 mrpt::obs::CObservationVelodyneScan,但使用 insertObservation 方法似乎无济于事。你能指出我使用这种观察类型的正确方向吗?
我的代码基本上是这样的:
COccupancyGridMap2D map;
// allocate 4 MB buffer (only ~130*4*4 KB are needed)
int32_t num = 1000000;
float *data = (float*)malloc(num*sizeof(float));
// pointers
float *px = data+0;
float *py = data+1;
float *pz = data+2;
float *pr = data+3;
// load point cloud
FILE *stream;
stream = fopen (args.velodyne_filename.c_str(),"rb");
num = fread(data,sizeof(float),num,stream)/4;
obs::CObservationVelodyneScan v;
v.point_cloud.x.resize(num);
v.point_cloud.y.resize(num);
v.point_cloud.z.resize(num);
v.point_cloud.intensity.resize(num);
for (int32_t i=0; i<num; i++)
{
v.point_cloud.x[i] = *px;
v.point_cloud.y[i] = *py;
v.point_cloud.z[i] = *pz;
v.point_cloud.intensity[i] = *pr;
px+=4; py+=4; pz+=4; pr+=4;
}
fclose(stream);
map.likelihoodOptions.likelihoodMethod = OccupancyGridMap2D::lmRayTracing;
map.insertObservation(&v);
谢谢,
弗朗切斯科