alsora / ros2-ORB_SLAM2

ROS2 node wrapping the ORB_SLAM2 library
GNU General Public License v3.0
130 stars 30 forks source link

colcon build error #9

Closed kyuhyong closed 1 year ago

kyuhyong commented 2 years ago

Hello, Trying to run this project on my laptop (ubuntu 20.04 installed + ROS foxy + build installed opencv3.4.11) I build installed ORB_SLAM2 from https://github.com/raulmur/ORB_SLAM2 located in my home directory "~ /SLAM/ORB_SLAM2/" and added export ORB_SLAM2_ROOT_DIR=~ /SLAM/ORB_SLAM2/ to my .bashrc No errors found during the build and libORB_SLAM2.so file is created under lib directory.

Then I git cloned this repository under ~ /ws/src and tried colcon build however I am getting below errors. What am I missing here?

/home/myhome/ws/src/ros2-ORB_SLAM2/src/rgbd/rgbd.cpp: In function ‘int main(int, char**)’:
/home/myhome/ws/src/ros2-ORB_SLAM2/src/rgbd/rgbd.cpp:25:84: error: no matching function for call to ‘ORB_SLAM2::System::System(char*&, char*&, ORB_SLAM2::System::eSensor, bool&)’
   25 |     ORB_SLAM2::System SLAM(argv[1], argv[2], ORB_SLAM2::System::RGBD, visualization);
      |                                                                                    ^

Above function declared in System.h in ORB_SLAM2 appears to be as below.

System(const string &strVocFile, const string &strSettingsFile, const eSensor sensor, const bool bUseViewer = true);

However same function declared in https://github.com/alsora/ORB_SLAM2 is different as

System(const string &strVocFile, const string &strSettingsFile, const eSensor sensor);

It seems build.sh copied headers from the latter into /usr/local/include/ORB_SLAM2 thus inconsistent with the ros2-ORB_SLAM2 Could you explain how to properly build install ORB_SLAM2 and colcon build the package?

I also failed to create docker image as it is not been able to finish colcon build inside.

Thanks,

alsora commented 2 years ago

Hi, first of all, I haven't used this repo in a couple of years, so I can't guarantee that it's still up-to-date. There are two ways for using ROS 2 with ORB_SLAM2.

  1. Use the standard https://github.com/raulmur/ORB_SLAM2 and the master branch of this repo. This is a very simple ROS 2 wrapper, as it leaves everything unchanged in the ORB_SLAM2 repo.
  2. Use my fork of ORB_SLAM2 (https://github.com/alsora/ORB_SLAM2) and the orbslam_dev branch of this repo. This is a modified version of ORB_SLAM2 that drops some non-ROS visualization dependencies (e.g. pangolin) and adopts a more ROS-based approach.

It looks like you are mixing stuffs.

kyuhyong commented 1 year ago

Thank you for your comment. I managed to fix issue myself It seems like I forgot to add this line into .bashrc file. $ export LD_LIBRARY_PATH=~/Pangolin/build/src/:~/ORB_SLAM2/Thirdparty/DBoW2/lib:~/ORB_SLAM2/Thirdparty/g2o/lib:~/ORB_SLAM2/lib:$LD_LIBRARY_PATH

  1. I fixed the issue by adding install process to the standard ORB_SLAM2 which will try to install headers and library into ubuntu's /usr/local directory. https://github.com/kyuhyong/ORB_SLAM2

  2. I tried to use your fork but it's header isn't compatible with the standard version as mentioned earlier.