当前位置:   article > 正文

【SLAM随手记】ROS中编译ORB-SLAM2出错及解决方案:[rosrun] Couldn't find executable named Mono_[rosbuild] rospack found package "orb_slam2" at ""

[rosbuild] rospack found package "orb_slam2" at "",

此前的步骤请参考《在ROS中使用usb摄像头跑ORB SLAM2》:

https://blog.csdn.net/Goding_learning/article/details/52950993

【摘要】本文针对运行编译ROS中编译ORB-SLAM2时候遇到的问题,即运行rosrun命令后出现的问题。因编译时候就出现问题,所以后面rosrun运行时肯定也会出现问题,会提示找不到某目录下的可执行文件mono,命令和错误信息分别如下:

rosrun ORB_SLAM2 Mono /home/xx/catkin_ws/src/ORB_SLAM2/Vocabulary/ORBvoc.txt /home/xx/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/Asus.yaml 

错误信息:

  1. kinetic@ros-vm:~/mywork/catkin_ws/src/ORB_SLAM2-master-origin/Examples/ROS/ORB_SLAM2$ rosrun ORB_SLAM2 Mono /home/xx/catkin_ws/src/ORB_SLAM2/Vocabulary/ORBvoc.txt /home/xx/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/Asus.yaml
  2. [rosrun] Couldn't find executable named Mono below /home/kinetic/mywork/catkin_ws/src/ORB_SLAM2-master-origin/Examples/ROS/ORB_SLAM2
  3. [rosrun] Found the following, but they're either not files,
  4. [rosrun] or not executable:
  5. [rosrun] /home/kinetic/mywork/catkin_ws/src/ORB_SLAM2-master-origin/Examples/ROS/ORB_SLAM2/Mono

即运行rosrun命令后出现的问题。

具体解决办法见https://github.com/raulmur/ORB_SLAM2/issues/498,即添加catkin_ws/src/ORB_SLAM2/Examples/ROS路径到~/.bashrc文件,使得系统知道已经安装了ROS。否则在ROS的工作目录catkin_ws文件夹中编译适用于ROS系统的ORB-SLAM2时候就会出错,错误信息如下:

  1. kinetic@ros-vm:~/mywork/catkin_ws/src/ORB_SLAM2-master-origin$ ./build_ros.sh
  2. Building ROS nodes
  3. -- The C compiler identification is GNU 5.4.0
  4. -- The CXX compiler identification is GNU 5.4.0
  5. -- Check for working C compiler: /usr/bin/cc
  6. -- Check for working C compiler: /usr/bin/cc -- works
  7. -- Detecting C compiler ABI info
  8. -- Detecting C compiler ABI info - done
  9. -- Detecting C compile features
  10. -- Detecting C compile features - done
  11. -- Check for working CXX compiler: /usr/bin/c++
  12. -- Check for working CXX compiler: /usr/bin/c++ -- works
  13. -- Detecting CXX compiler ABI info
  14. -- Detecting CXX compiler ABI info - done
  15. -- Detecting CXX compile features
  16. -- Detecting CXX compile features - done
  17. -- Found PythonInterp: /usr/bin/python (found version "2.7.12")
  18. [rosbuild] Building package ORB_SLAM2
  19. [rosbuild] Error from directory check: /opt/ros/kinetic/share/ros/core/rosbuild/bin/check_same_directories.py /home/kinetic/mywork/catkin_ws/src/ORB_SLAM2-master-origin/Examples/ROS/ORB_SLAM2
  20. 1
  21. Traceback (most recent call last):
  22. File "/opt/ros/kinetic/share/ros/core/rosbuild/bin/check_same_directories.py", line 46, in <module>
  23. raise Exception
  24. Exception
  25. CMake Error at /opt/ros/kinetic/share/ros/core/rosbuild/private.cmake:102 (message):
  26. [rosbuild] rospack found package "ORB_SLAM2" at "", but the current
  27. directory is
  28. "/home/kinetic/mywork/catkin_ws/src/ORB_SLAM2-master-origin/Examples/ROS/ORB_SLAM2".
  29. You should double-check your ROS_PACKAGE_PATH to ensure that packages are
  30. found in the correct precedence order.
  31. Call Stack (most recent call first):
  32. /opt/ros/kinetic/share/ros/core/rosbuild/public.cmake:177 (_rosbuild_check_package_location)
  33. CMakeLists.txt:4 (rosbuild_init)
  34. -- Configuring incomplete, errors occurred!
  35. See also "/home/kinetic/mywork/catkin_ws/src/ORB_SLAM2-master-origin/Examples/ROS/ORB_SLAM2/build/CMakeFiles/CMakeOutput.log".
  36. make: *** 没有指明目标并且找不到 makefile。 停止。

【解决办法】

1、首先去目录/home/(此处是你创建ROS工作空间的路径)/catkin_ws/src/ORB_SLAM2-master-origin(这个是ROS下ORB-SLAM2的总目录,该目录由ORB-SLAM2.tar.gz解压缩生成)/Examples/ROS/ORB_SLAM2中删除此前错误build过程生成的名为build的文件夹(如果有的话);

2、添加“/home/(此处是你创建ROS工作空间的路径)/catkin_ws/src/ORB_SLAM2-master-origin(这个是ROS下ORB-SLAM2的总目录,该目录由ORB-SLAM2.tar.gz解压缩生成)/Examples/ROS”到你的ROS_PACKAGE_PATH,即

$ vim ~/.bashrc

在最后一行添加如下代码,再source一下,这样就添加了ORB-SLAM2的ROS文件夹的路径到ROS系统路径中(让两者可以互通互联了):

export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/...(这里填上你 catkin_ws/ORB_SLAM2的具体路径)/ORB_SLAM2/Examples/ROS

再source一下:

$ source ~/.bashrc

3、去目录/home/(此处是你创建ROS工作空间的路径)/catkin_ws/src/ORB_SLAM2-master-origin 目录中运行

  1. $ chmod +x build_ros.sh
  2. $ ./build_ros.sh

这步之后,就会发现在~/mywork/catkin_ws/src/ORB_SLAM2-master-origin/Examples/ROS/ORB_SLAM2目录下有绿色的mono文件生成,此时就可以成功运行如下代码不会报错(说找不到可执行文件mono啦):

  1. $ rosrun ORB_SLAM2 Mono /home/kinetic/mywork/catkin_ws/src/ORB_SLAM2-master-
  2. origin/Vocabulary/ORBvoc.txt /home/kinetic/mywork/catkin_ws/src/ORB_SLAM2-master-origin/Examples/ROS/ORB_SLAM2/Asus.yaml

上面命令中“/home/kinetic/mywork/catkin_ws/src/ORB_SLAM2-master-origin”是我的ROS工作空间目录下ORB-SLAM2的安装目录,读者可根据自己的具体情况来修改。

 

【注】此前的步骤请参考《在ROS中使用usb摄像头跑ORB SLAM2》:

https://blog.csdn.net/Goding_learning/article/details/52950993

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/292843
推荐阅读
相关标签
  

闽ICP备14008679号