Xavier(8):Xavier使用速腾聚创激光雷达运行a-loam算法部分报错与解决方案

文章目录

  • 1 速腾聚创激光雷达驱动
    • 报错:Project 'cv_bridge' specifies '/usr/include/opencv' as an include dir
    • Project 'grid_map_cv' specifies '/usr/include/opencv' as an include dir
  • 2 a-loam算法
    • 报错: fatal error: opencv/cv.h: 没有那个文件或目录
    • 报错:error: ‘CV_LOAD_IMAGE_GRAYSCALE’ was not declared in this scope
    • 报错:[FATAL] [1668787250.688458461]: BREAKPOINT HIT

Xavier(8):Xavier使用速腾聚创激光雷达运行a-loam算法部分报错与解决方案_第1张图片
左边是a-loam效果,右边是激光雷达点云。
本机使用Nvidia xavier镜像,为ubuntu18.04、ros-melodic、opencv4
a-loam经过简单的源码修改可以适用于opencv4.x

1 速腾聚创激光雷达驱动

报错:Project ‘cv_bridge’ specifies ‘/usr/include/opencv’ as an include dir

CMake Error at /opt/ros/melodic/share/cv_bridge/cmake/cv_bridgeConfig.cmake:113 (message):
  Project 'cv_bridge' specifies '/usr/include/opencv' as an include dir,
  which is not found.  It does neither exist as an absolute directory nor in
  '${{prefix}}//usr/include/opencv'. 

参考:https://blog.csdn.net/qq_53627591/article/details/126116822
原因是:NVIDIA xaiver的镜像image自带的是opencv4版本,下面把opencv命名成了opencv4
sudo gedit /opt/ros/melodic/share/cv_bridge/cmake/cv_bridgeConfig.cmake
修改前

if(NOT "include;/usr/include;/usr/include/opencv " STREQUAL " ")
  set(cv_bridge_INCLUDE_DIRS "")
  set(_include_dirs "include;/usr/include;/usr/include/opencv")

修改后

if(NOT "include;/usr/include;/usr/include/opencv4 " STREQUAL " ")
  set(cv_bridge_INCLUDE_DIRS "")
  set(_include_dirs "include;/usr/include;/usr/include/opencv4")

下面这个报错在其他程序里面出现,在编译速腾聚创激光雷达驱动没有出现,此处作为参考

Project ‘grid_map_cv’ specifies ‘/usr/include/opencv’ as an include dir

CMake Error at /opt/ros/melodic/share/grid_map_cv/cmake/grid_map_cvConfig.cmake:113 (message):
  Project 'grid_map_cv' specifies '/usr/include/opencv' as an include dir,
  which is not found.  It does neither exist as an absolute directory nor in
  '${{prefix}}//usr/include/opencv'.  Check the issue tracker
  'http://github.com/anybotics/grid_map/issues' and consider creating a
  ticket if the problem has not been reported yet.

修改上面报错的第一行中的文件的94行和96行,将opencv替换为opencv4:
修改前

if(NOT "include;/usr/include;/usr/include/opencv " STREQUAL " ")
  set(grid_map_cv_INCLUDE_DIRS "")
  set(_include_dirs "include;/usr/include;/usr/include/opencv")

修改后

if(NOT "include;/usr/include;/usr/include/opencv4 " STREQUAL " ")
  set(grid_map_cv_INCLUDE_DIRS "")
  set(_include_dirs "include;/usr/include;/usr/include/opencv4")

2 a-loam算法

报错: fatal error: opencv/cv.h: 没有那个文件或目录

xx/src/A-LOAM/src/draw_boxes.cpp:7:10: fatal error: opencv/cv.h: 没有那个文件或目录
 #include 

修改 #include #include

报错:error: ‘CV_LOAD_IMAGE_GRAYSCALE’ was not declared in this scope

error: ‘CV_LOAD_IMAGE_GRAYSCALE’ was not declared in this scope
         cv::Mat left_image = cv::imread(left_image_path.str(), CV_LOAD_IMAGE_GRAYSCALE);

参考:https://blog.csdn.net/weixin_41560777/article/details/124138138
找到对应的kittiHelper.cpp文件,将91行与93行的CV_LOAD_IMAGE_GRAYSCALE改为cv::IMREAD_GRAYSCALE

报错:[FATAL] [1668787250.688458461]: BREAKPOINT HIT

先启动速腾雷达驱动roslaunch rslidar_sdk start.launch ,后启动a-loamroslaunch aloam_velodyne aloam_velodyne_VLP_16_c2.launch

[FATAL] [1668787250.688458461]: BREAKPOINT HIT
	file = /home/aaeon/hxz/c2_aloam/src/A-LOAM/src/laserOdometry.cpp
	line=240

[alaserOdometry-2] process has died [pid 8867, exit code -6, cmd /home/aaeon/hxz/c2_aloam/devel/lib/aloam_velodyne/alaserOdometry __name:=alaserOdometry __log:=/home/aaeon/.ros/log/2653080a-675a-11ed-a57f-48b02d185503/alaserOdometry-2.log].
log file: /home/aaeon/.ros/log/2653080a-675a-11ed-a57f-48b02d185503/alaserOdometry-2*.log

Xavier(8):Xavier使用速腾聚创激光雷达运行a-loam算法部分报错与解决方案_第2张图片

根据报错查看/home/aaeon/hxz/c2_aloam/src/A-LOAM/src/laserOdometry.cpp240行左右内容,怀疑是时间戳问题

            if (timeCornerPointsSharp != timeLaserCloudFullRes ||
                timeCornerPointsLessSharp != timeLaserCloudFullRes ||
                timeSurfPointsFlat != timeLaserCloudFullRes ||
                timeSurfPointsLessFlat != timeLaserCloudFullRes)
            {
                printf("unsync messeage!");
                ROS_BREAK();
            }

先启动启动a-loamroslaunch aloam_velodyne aloam_velodyne_VLP_16_my.launch,后启动速腾雷达驱动roslaunch rslidar_sdk start.launch 则不会报错,且会正常运行

Xavier(8):Xavier使用速腾聚创激光雷达运行a-loam算法部分报错与解决方案_第3张图片

你可能感兴趣的:(slam,算法,c++,slam,a-loam,激光雷达)