Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fail building ROS2 nodes for ORB_SLAM2 #7

Open
zoldaten opened this issue Dec 25, 2022 · 13 comments
Open

fail building ROS2 nodes for ORB_SLAM2 #7

zoldaten opened this issue Dec 25, 2022 · 13 comments
Labels
enhancement New feature or request

Comments

@zoldaten
Copy link

hi!
cant build nodes for ROS2 Foxy to use with ORB_SLAM2.
did you build them from scratch or use docker image from https://github.com/alsora/ros2-ORB_SLAM2/tree/f890df18983ead8cd2ae36676036d535ee52951b ?

@zoldaten
Copy link
Author

ok. got it working - https://youtu.be/MaZRohrtnrQ
built nodes from scratch using repo above and issues to it that means EXPORT...

@tentone
Copy link
Owner

tentone commented Dec 27, 2022

Hello

Sorry for my late reponse, Glad that you were able to figure it out.

Could you please provided updated intructions that could be integrated into the project readme?

Thanks a lot!

@tentone tentone added the enhancement New feature or request label Dec 27, 2022
@zoldaten
Copy link
Author

i`ll try to sum up changes.

@zoldaten
Copy link
Author

i did almost everything from your README and a bit more )
ros2:
sudo apt update && sudo apt install curl gnupg2 lsb-release
12 sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
13 echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
14 mkdir -p ~/ros2_galactic
15 cd ros2_galactic/
16 wget https://github.com/ros2/ros2/releases/download/release-galactic-20221209/ros2-galactic-20221209-linux-focal-amd64.tar.bz2
17 ls
18 tar xf ros2-galactic-20221209-linux-focal-amd64.tar.bz2
19 mc
20 cd ..
21 sudo apt install ros-foxy-desktop python3-argcomplete
22 sudo rm /var/lib/apt/lists/lock
23 sudo rm /var/cache/apt/archives/lock
24 sudo rm /var/lib/dpkg/lock*
25 sudo dpkg --configure -a
26 sudo apt update
27 echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(. /etc/os-release && echo $UBUNTU_CODENAME) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
28 sudo apt install ros-foxy-desktop python3-argcomplete
29 sudo apt install ros-foxy-ros-base python3-argcomplete
30 sudo apt install ros-dev-tools
31 source /opt/ros/foxy/setup.bash
32 ros2 run demo_nodes_cpp talker
33 echo "source /opt/ros/foxy/setup.bash" >> ~/.bashrc
34 printenv | grep -i ROS
35 sudo rm -r ros2_galactic/
36 printenv | grep -i ROS
37 mkdir -p ~/ros2_ws/src
38 cd ~/ros2_ws
39 cd src/
40 cd ..
41 git clone https://github.com/ros2/examples src/examples -b foxy
42 colcon build --symlink-install
43 colcon test
44 . install/setup.bash

tello:
git clone https://github.com/tentone/tello-ros2.git
put part of ROS to ros2_ws/src
59 cd ros2_ws/
60 colcon build --symlink-install
61 . install/setup.bash
62 cd src/
63 ls
64 ros2 launch launch.py
65 pip3 install av
66 sudo apt install python3-pip
67 pip3 install av
68 ros2 launch launch.py
69 pip3 install djitellopy

the hard part was about ORB_SLAM2 as i use opencv4.2 installed trought apt (not build from source).
git clone https://github.com/raulmur/ORB_SLAM2.git ORB_SLAM2
271 cd ORB_SLAM2/
272 chmod +x build.sh
273 ./build.sh
275 sed -i 's/++11/++14/g' CMakeLists.txt
1.
need to add:
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
to
nano /home/al/ORB_SLAM2/src/LoopClosing.cc
nano /home/al/ORB_SLAM2/src/Viewer.cc
nano /home/al/ORB_SLAM2/src/System.cc
nano /home/al/ORB_SLAM2/src/Tracking.cc
nano /home/al/ORB_SLAM2/src/System.cc
nano /home/al/ORB_SLAM2/src/LocalMapping.cc
nano /home/al/ORB_SLAM2/Examples/Monocular/mono_kitti.cc
nano /home/al/ORB_SLAM2/Examples/Stereo/stereo_kitti.cc
nano /home/al/ORB_SLAM2/Examples/Monocular/mono_tum.cc
nano /home/al/ORB_SLAM2/Examples/RGB-D/rgbd_tum.cc
nano /home/al/ORB_SLAM2/Examples/Monocular/mono_euroc.cc
nano /home/al/ORB_SLAM2/Examples/Stereo/stereo_euroc.cc
2.
nano include/LoopClosing.h
from
Eigen::aligned_allocator<std::pair<const KeyFrame*, g2o::Sim3> > > KeyFrameAndPose;
to
Eigen::aligned_allocator<std::pair<KeyFrame* const, g2o::Sim3> > > KeyFrameAndPose;

  1. changes concern opencv
    *raulmur/ORB_SLAM2@379c763

*ducha-aiki/pymagsac#4
sed -i 's/++11/++14/g' CMakeLists.txt
and
nano CMakeLists.txt

Then replace find_package(Eigen3 REQUIRED) to
list(APPEND CMAKE_INCLUDE_PATH "/usr/local/include")
find_package (Eigen3 3.3 REQUIRED NO_MODULE)

and
find_package(OpenCV 4 QUIET)

put file path (ost.yaml) to
nano /home/al/ros2_ws/build/tello/tello/node.py
path:
self.node.declare_parameter('camera_info_file', '')
to
self.node.declare_parameter('camera_info_file', '/home/al/ros2_ws/src/tello/resource/ost.yaml')

put the same parameters to
~/ORB_SLAM2/Examples/Monocular/TUM1.yaml

@tentone
Copy link
Owner

tentone commented Dec 29, 2022

I will compile these instructions into a .md file and place them in the repo ;)

Thanks a lot!

@MizzouRobotics
Copy link

find_package (Eigen3 3.3 REQUIRED NO_MODULE)

This, but I had to build a custom Eigen 3.3.X from source, then change it to:
find_package (Eigen3 3.3.X EXACT REQUIRED NO_MODULE)

I am having difficulty finding the module after the fact for my ros2 node build. I didn't know if either of you had any insight :)

@MizzouRobotics
Copy link

Actually, I copied from the original source, I copied over the FindORB_SLAM2.cmake from the forked repo and it works. You both are saints

@tentone
Copy link
Owner

tentone commented Jan 18, 2023

Well im a bit late to help, thats great news 👍 thanks!

@peakyquest
Copy link

I followed the same procedure for humble, failed to build ORB_SLAM2

@peakyquest
Copy link

Why do we build ORB_SLAM using the ./build.sh command first and then make changes to it? Why not make the necessary changes for the required versions beforehand and then run the build command?

@peakyquest
Copy link

Never mind, I build the ORB-SLAM2. There is one thing, which is still bothering me to build the orbslam2 ros2 package, that I am getting this error.

CMake Error at CMakeLists.txt:26 (find_package):
By not providing "FindORB_SLAM2.cmake" in CMAKE_MODULE_PATH this project
has asked CMake to find a package configuration file provided by
"ORB_SLAM2", but CMake did not find one.

Could not find a package configuration file provided by "ORB_SLAM2" with
any of the following names:

ORB_SLAM2Config.cmake
orb_slam2-config.cmake

Add the installation prefix of "ORB_SLAM2" to CMAKE_PREFIX_PATH or set
"ORB_SLAM2_DIR" to a directory containing one of the above files. If
"ORB_SLAM2" provides a separate development package or SDK, be sure it has
been installed.

@peakyquest
Copy link

# Try to find ORB_SLAM2
# Set alternative paths to search for using ORB_SLAM2_DIR
# Once done this will define
# You should ensure your ORB_SLAM2 can run correctly
#
# To help the search ORB_SLAM2_ROOT_DIR environment variable as the path to ORB_SLAM2 root folder
#  e.g. `set( ORB_SLAM2_ROOT_DIR=~/ORB_SLAM2) `
set(ORB_SLAM2_ROOT_DIR "~/Documents/ORB_SLAM2")

# message(${ORB_SLAM2_ROOT_DIR})
# message(${ORB_SLAM2_ROOT_DIR}/include)
# message(${ORB_SLAM2_ROOT_DIR}/Thirdparty/DBoW2/DBoW2)

# Find ORB_SLAM2
find_path(ORB_SLAM2_INCLUDE_DIR NAMES System.h
          PATHS ${ORB_SLAM2_ROOT_DIR}/include)

find_library(ORB_SLAM2_LIBRARY NAMES ORB_SLAM2 libORB_SLAM2
             PATHS ${ORB_SLAM2_ROOT_DIR}/lib)

# Find built-in DBoW2
find_path(DBoW2_INCLUDE_DIR NAMES Thirdparty/DBoW2/DBoW2/BowVector.h
          PATHS ${ORB_SLAM2_ROOT_DIR})

find_library(DBoW2_LIBRARY NAMES DBoW2
             PATHS ${ORB_SLAM2_ROOT_DIR}/Thirdparty/DBoW2/lib)

# Find built-in g2o
find_library(g2o_LIBRARY NAMES g2o
             PATHS ${ORB_SLAM2_ROOT_DIR}/Thirdparty/g2o/lib)



include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set ORB_SLAM2_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(ORB_SLAM2  DEFAULT_MSG
                                  ORB_SLAM2_LIBRARY ORB_SLAM2_INCLUDE_DIR DBoW2_INCLUDE_DIR DBoW2_LIBRARY g2o_LIBRARY)

mark_as_advanced(ORB_SLAM2_INCLUDE_DIR ORB_SLAM22_LIBRARY )

set(ORB_SLAM2_LIBRARIES ${ORB_SLAM2_LIBRARY} ${DBoW2_LIBRARY} ${g2o_LIBRARY})
set(ORB_SLAM2_INCLUDE_DIRS ${ORB_SLAM2_INCLUDE_DIR} ${DBoW2_INCLUDE_DIR})

I have written this. It finds the ORB_SLAM2Config.cmake.

I am getting a new error

/home/haroon/colcon_ws/src/dev_robotisim/orbslam2/src/monocular/mono.cpp:9:10: fatal error: ORB_SLAM2/System.h: No such file or directory
9 | #include "ORB_SLAM2/System.h"
| ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
/home/haroon/colcon_ws/src/dev_robotisim/orbslam2/src/monocular/monocular-slam-node.cpp:5:10: fatal error: ORB_SLAM2/MapPoint.h: No such file or directory
5 | #include "ORB_SLAM2/MapPoint.h"
| ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
gmake[2]: *** [CMakeFiles/mono.dir/build.make:90: CMakeFiles/mono.dir/src/monocular/monocular-slam-node.cpp.o] Error 1
gmake[2]: *** Waiting for unfinished jobs....
gmake[2]: *** [CMakeFiles/mono.dir/build.make:76: CMakeFiles/mono.dir/src/monocular/mono.cpp.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:137: CMakeFiles/mono.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2

Failed <<< orbslam2 [0.61s, exited with code 2]

@peakyquest
Copy link

nevermind I find a way out. Thanks for the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants