ORB-SLAM2编译报错:rospack found package "ORB_SLAM2" at "/opt/ros/kinetic/share/ORB_SLAM2", but the....

折腾了一中午,尝试了各种修改路径的方法,仍然是提示报错,但是路径明明是添加进去了…

在.bashrc文件中添加如下路径信息:

source /opt/ros/kinetic/setup.bash
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/bruce/study/slam/orb/point_map/Examples/ROS

刷新环境变量,并验证路径设置信息:

bruce@bruce-desktop:~$ source ~/.bashrc
bruce@bruce-desktop:~$ echo $ROS_PACKAGE_PATH
/opt/ros/kinetic/share:/home/bruce/study/slam/orb/point_map/Examples/ROS

输出信息都是对的,但是依然报错…,头大了很久。

报错信息:

[rosbuild] Building package ORB_SLAM2
[rosbuild] Error from directory check: /opt/ros/kinetic/share/ros/core/rosbuild/bin/check_same_directories.py /opt/ros/kinetic/share/ORB_SLAM2 /home/bruce/study/slam/orb/point_map2/Examples/ROS/ORB_SLAM2
1
Traceback (most recent call last):
  File "/opt/ros/kinetic/share/ros/core/rosbuild/bin/check_same_directories.py", line 48, in 
    raise Exception
Exception
CMake Error at /opt/ros/kinetic/share/ros/core/rosbuild/private.cmake:102 (message):
  [rosbuild] rospack found package "ORB_SLAM2" at
  "/opt/ros/kinetic/share/ORB_SLAM2", but the current directory is
  "/home/bruce/study/slam/orb/point_map2/Examples/ROS/ORB_SLAM2".  You should
  double-check your ROS_PACKAGE_PATH to ensure that packages are found in the
  correct precedence order.
Call Stack (most recent call first):
  /opt/ros/kinetic/share/ros/core/rosbuild/public.cmake:177 (_rosbuild_check_package_location)
  CMakeLists.txt:4 (rosbuild_init)


-- Configuring incomplete, errors occurred!
See also "/home/bruce/study/slam/orb/point_map2/Examples/ROS/ORB_SLAM2/build/CMakeFiles/CMakeOutput.log".
make: *** 没有指明目标并且找不到 makefile。 停止。

原因分析及解决办法:
这是由于在ROS环境下编译使用了多个版本的ORB-SLAM2工程造成的,比如我运行了原版的ORB-SLAM2,然后拷贝了一份改了下文件名字,添加稠密重建模块,再对新的工程编译,就报了这个错误。因为原工程已经在/opt/ros/kinetic/share文件夹下建立了一个软连接ORB_SLAM2,这里包含有原工程的一些信息,我们需要做的就是把该软连接,替换为现在工程的软连接。

(1)先cd到/opt/ros/kinetic/share目录下,删除原来的ORB_SLAM2软连接

sudo rm -r ORB_SLAM2

(2)对当前工程在/opt/ros/kinetic/share目录下建立软连接

sudo ln -s /home/bruce/study/slam/orb/point_map/Examples/ROS/ORB_SLAM2 /opt/ros/kinetic/share/ORB_SLAM2

这样就圆满解决问题了!!!

你可能感兴趣的:(Ubuntu,SLAM)