【SLAM随意記】ROSでのORB-SLAM 2コンパイルエラーおよび解決策:[rosrun]Couldn't find executable named Mono

4911 ワード

これまでの手順は、「ROSでusbカメラを使用してORB SLAM 2を走る」を参照してください.
https://blog.csdn.net/Goding_learning/article/details/52950993
【要約】本稿では、コンパイルROSでORB-SLAM 2をコンパイルする際に発生する問題、すなわち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_SLAM 2/Examples/ROS経路~/.bashrcファイルは、ROSがインストールされていることをシステムに知らせる.そうでなければROSの作業ディレクトリcatkin_wsフォルダでROSシステムに適したORB-SLAM 2をコンパイル中にエラーが発生し、エラーメッセージは以下の通りです.
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 
    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_SLAM 2-master-origin(これはROS下のORB-SLAM 2の総ディレクトリであり、このディレクトリはORB-SLAM 2.tar.gz解凍によって生成される)/Examples/ROS/ORB_SLAM 2では、これまでエラーbuildプロセスで生成されたbuildというフォルダを削除します(存在する場合).
2、「/home/(ここではROSワークスペースを作成するパス)/catkin_ws/src/ORB_SLAM 2-master-origin(これはROS下のORB-SLAM 2の総ディレクトリであり、このディレクトリはORB-SLAM 2.tar.gz解凍によって生成される)/Examples/ROS」をROSに追加するPACKAGE_PATH、すなわち
$ vim ~/.bashrc

最後の行に次のコードを追加し、ソースを追加すると、ORB-SLAM 2の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_SLAM 2-master-originディレクトリで実行
$ chmod +x build_ros.sh
$ ./build_ros.sh

このステップの後、~/mywork/catkin_ws/src/ORB_SLAM2-master-origin/Examples/ROS/ORB_SLAM 2ディレクトリの下に緑色の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_SLAM 2-master-origin」は私のROSワークスペースディレクトリの下にあるORB-SLAM 2のインストールディレクトリで、読者は自分の状況に応じて修正することができます.
 
【注】これまでの手順は「ROSでusbカメラを使ってORB SLAM 2を走る」を参照してください.
https://blog.csdn.net/Goding_learning/article/details/52950993