赞
踩
此前的步骤请参考《在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
错误信息:
- 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
- [rosrun] Couldn't find executable named Mono below /home/kinetic/mywork/catkin_ws/src/ORB_SLAM2-master-origin/Examples/ROS/ORB_SLAM2
- [rosrun] Found the following, but they're either not files,
- [rosrun] or not executable:
- [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时候就会出错,错误信息如下:
- kinetic@ros-vm:~/mywork/catkin_ws/src/ORB_SLAM2-master-origin$ ./build_ros.sh
- Building ROS nodes
- -- The C compiler identification is GNU 5.4.0
- -- The CXX compiler identification is GNU 5.4.0
- -- Check for working C compiler: /usr/bin/cc
- -- Check for working C compiler: /usr/bin/cc -- works
- -- Detecting C compiler ABI info
- -- Detecting C compiler ABI info - done
- -- Detecting C compile features
- -- Detecting C compile features - done
- -- Check for working CXX compiler: /usr/bin/c++
- -- Check for working CXX compiler: /usr/bin/c++ -- works
- -- Detecting CXX compiler ABI info
- -- Detecting CXX compiler ABI info - done
- -- Detecting CXX compile features
- -- Detecting CXX compile features - done
- -- Found PythonInterp: /usr/bin/python (found version "2.7.12")
- [rosbuild] Building package ORB_SLAM2
- [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
- 1
- Traceback (most recent call last):
- File "/opt/ros/kinetic/share/ros/core/rosbuild/bin/check_same_directories.py", line 46, in <module>
- raise Exception
- Exception
- CMake Error at /opt/ros/kinetic/share/ros/core/rosbuild/private.cmake:102 (message):
- [rosbuild] rospack found package "ORB_SLAM2" at "", but the current
- directory is
- "/home/kinetic/mywork/catkin_ws/src/ORB_SLAM2-master-origin/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/kinetic/mywork/catkin_ws/src/ORB_SLAM2-master-origin/Examples/ROS/ORB_SLAM2/build/CMakeFiles/CMakeOutput.log".
- 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 目录中运行
- $ chmod +x build_ros.sh
- $ ./build_ros.sh
这步之后,就会发现在~/mywork/catkin_ws/src/ORB_SLAM2-master-origin/Examples/ROS/ORB_SLAM2目录下有绿色的mono文件生成,此时就可以成功运行如下代码不会报错(说找不到可执行文件mono啦):
- $ rosrun ORB_SLAM2 Mono /home/kinetic/mywork/catkin_ws/src/ORB_SLAM2-master-
- 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
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。