5、RGB-D— 视觉里程计 Visual Odometry

来源:互联网 发布:高仿京东商城源码 编辑:程序博客网 时间:2024/06/06 14:12

(在做高博的“一起做RGB-D_SLAM”的一些问题,作为自己笔记总结,以督促自己完成并理解)
与上一讲的课程,修改了4个地方:
1. src/slamBase.cpp
首先工具函数:将cv的旋转矢量与位移矢量转换为变换矩阵,类型为Eigen::Isometry3d;
另一个函数:将新的帧合并到旧的点云里:

 // joinPointCloud  // 输入:原始点云,新来的帧以及它的位姿 // 输出:将新来帧加到原始帧后的图像
  1. parameters.txt
# part 5 # 数据相关# 起始与终止索引start_index=1end_index=700# 数据所在目录##注意路径rgb_dir=../data/rgb_png/rgb_extension=.pngdepth_dir=../data/depth_png/depth_extension=.png# 点云分辨率voxel_grid=0.02# 是否实时可视化visualize_pointcloud=yes# 最小匹配数量min_good_match=10# 最小内点min_inliers=5# 最大运动误差max_norm=0.3

3. src/visualOdometry.cpp  实现一个VO
4. src/CMakeLists.txt 改了一行(什么意思呢?)
Q1、不然会出现这个,pcl 链接错误

[ 14%] Built target slambaseLinking CXX executable /home/××/learn/my_code/rgbd_slam/bin/detectFeatures/home/××/learn/my_code/rgbd_slam/lib/libslambase.a(slambase.cpp.o):(.rodata._ZTVN3pcl9VoxelGridINS_12PointXYZRGBAEEE[_ZTVN3pcl9VoxelGridINS_12PointXYZRGBAEEE]+0x48): undefined reference to `pcl::VoxelGrid<pcl::PointXYZRGBA>::applyFilter(pcl::PointCloud<pcl::PointXYZRGBA>&)'collect2: error: ld returned 1 exit statusmake[2]: *** [/home/××/learn/my_code/rgbd_slam/bin/detectFeatures] Error 1make[1]: *** [src/CMakeFiles/detectFeatures.dir/all] Error 2make: *** [all] Error 210:56:48: The process "/usr/bin/cmake" exited with code 2.Error while building/deploying project slam (kit: Desktop)The kit Desktop has configuration issues which might be the root cause for this problem.When executing step "Make"10:56:48: Elapsed time: 00:01.
FIND_PACKAGE( PCL REQUIRED COMPONENTS common io visualization )

改成了

FIND_PACKAGE( PCL REQUIRED COMPONENTS common io visualization filters )

Q2、
运行

bin/visualOdometry

显示:

Reading files 6find total 500 matches.good matches: 126solving pnpnorm = 0.0107077T=    0.999997   0.00130699    0.0020222   0.00362735 -0.00130765     0.999999  0.000322329   0.00742123 -0.00202178 -0.000324972     0.999998 -0.000545456           0            0            0            1Reading files 7find total 500 matches.good matches: 0solving pnpOpenCV Error: Assertion failed (opoints.isContinuous()) in solvePnPRansac, file /build/buildd/opencv-2.4.8+dfsg1/modules/calib3d/src/solvepnp.cpp, line 283terminate called after throwing an instance of 'cv::Exception'  what():  /build/buildd/opencv-2.4.8+dfsg1/modules/calib3d/src/solvepnp.cpp:283: error: (-215) opoints.isContinuous() in function solvePnPRansacAborted (core dumped)

几秒就消失了
有人回答说是配置文件路径问题?

# 数据所在目录rgb_dir= data/rgb_png/rgb_extension=.pngdepth_dir= data/depth_png/depth_extension=.png

改了也不行
后面发现错误里good matches: 0
所以考虑问题应该是在slambase.cpp里的estimateMotion 计算两个帧之间的运动那一块有问题

 105  if (goodMatches.size() <= 5)    {        result.inliers = -1;        return result;
  133 if (pts_obj.size() ==0 || pts_img.size()==0)    {        result.inliers = -1;        return result;    }
    //RESULT_OF_PNP result;  //要注释掉
添加:// cvMat2Eigen

最后效果:
这里写图片描述