UZ-SLAMLab / ORB_SLAM3

ORB-SLAM3: An Accurate Open-Source Library for Visual, Visual-Inertial and Multi-Map SLAM
GNU General Public License v3.0
6.53k stars 2.55k forks source link

build ROS nodes on Raspbian buster raspberry pi - [SOLVED] #640

Open zoldaten opened 2 years ago

zoldaten commented 2 years ago

hi ! i am on raspberry pi4 Raspbian armv7l buster. i spent hours building ROS nodes for ORB_SLAM3 and succeded (exept AR examples). so i decided to provide the solution.

  1. build ORB_SLAM3 by itself and optional install ROS (desktop version!) - (https://varhowto.com/install-ros-noetic-raspberry-pi-4/ they write there to install rosinstall_generator ros_comm --rosdistro noetic --deps --wet-only --tar > noetic-ros_comm-wet.rosinstall but you should use this line instead (or you will faced with missed cv_bridge...etc...): rosinstall_generator desktop --rosdistro noetic --deps --wet-only --tar > noetic-ros_comm-wet.rosinstall

  2. modified CMakeLists.txt as i it crashed (/home/pi/ORB_SLAM3/Examples_old/ROS/ORB_SLAM3): sed -i 's/++11/++14/g' CMakeLists.txt

comment out in CMakeLists.txt AR nodes as they wont build:

# Node for monocular camera (Augmented Reality Demo)
#rosbuild_add_executable(MonoAR
#src/AR/ros_mono_ar.cc
#src/AR/ViewerAR.h
#src/AR/ViewerAR.cc
#)
#target_link_libraries(MonoAR
#${LIBS}
#)

at start of a CMakeLists.txt add: project(ORB_SLAM3)

  1. modify build_ros.sh (/home/pi/ORB_SLAM3)
    
    echo "Building ROS nodes"

cd Examples_old/ROS/ORB_SLAM3 mkdir build cd build cmake .. -DROS_BUILD_TYPE=Release -DPYTHON3_INCLUDE_DIR=/usr/bin/python3.7 -DPYTHON_EXECUTABLE=/usr/bin/python3 make -j


3. **install missed libraries:**
---fmt---
`sudo apt install libfmt-dev`

---Sophus---

git clone https://github.com/strasdat/Sophus.git cd Sophus mkdir build && cd build && cmake .. && sudo make install


replace Sophus in 
`/home/pi/ORB_SLAM3/Thirdparty/Sophus`
with one built by source:
`/home/pi/Sophus`
(just remove one and put in that place other one)

4. **before build in terminal do exports to avoid crash**:

export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:/home/pi/ORB_SLAM3/Examples_old/ROS/ORB_SLAM3 source /opt/ros/noetic/setup.bash

5. **build it already !**

cd ~/ORB_SLAM3 ./build_ros.sh


After it finished you get files in /home/pi/ORB_SLAM3/Examples_old/ROS/ORB_SLAM3

have a nice day!
swagatk commented 1 year ago

@zoldaten : I am still facing issue while compiling the Sophus package in Step 3. I get the following build error:

In file included from /home/pi/Sophus/sophus/common.hpp:36,
                 from /home/pi/Sophus/sophus/types.hpp:7,
                 from /home/pi/Sophus/sophus/rotation_matrix.hpp:9,
                 from /home/pi/Sophus/sophus/so3.hpp:6,
                 from /home/pi/Sophus/sophus/rxso3.hpp:6,
                 from /home/pi/Sophus/test/core/test_rxso3.cpp:3:
/home/pi/Sophus/test/core/test_rxso3.cpp: In lambda function:
/home/pi/Sophus/sophus/common.hpp:50:30: error: declaration of ‘struct Sophus::Tests<Scalar_>::testFit()::<lambda()>::S’ shadows template parameter
 #define SOPHUS_FMT_STRING(x) FMT_STRING(x)
                              ^~~~~~~~~~
/home/pi/Sophus/sophus/common.hpp:64:15: note: in expansion of macro ‘SOPHUS_FMT_STRING’
   fmt::format(SOPHUS_FMT_STRING(description), ##__VA_ARGS__)
               ^~~~~~~~~~~~~~~~~
/home/pi/Sophus/sophus/test_macros.hpp:79:14: note: in expansion of macro ‘SOPHUS_FMT_STR’
       msg += SOPHUS_FMT_STR(descr, ##__VA_ARGS__);                             \
              ^~~~~~~~~~~~~~
/home/pi/Sophus/test/core/test_rxso3.cpp:288:9: note: in expansion of macro ‘SOPHUS_TEST’
         SOPHUS_TEST(passed, !isScaledOrthogonalAndPositive(sR_cols_swapped),
         ^~~~~~~~~~~
/home/pi/Sophus/test/core/test_rxso3.cpp:275:13: note: template parameter ‘S’ declared here
   template <class S = Scalar>
             ^~~~~
make[2]: *** [test/core/CMakeFiles/test_rxso3.dir/build.make:63: test/core/CMakeFiles/test_rxso3.dir/test_rxso3.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:206: test/core/CMakeFiles/test_rxso3.dir/all] Error 2
make: *** [Makefile:141: all] Error 2

That's why I am not able to proceed after this step. I am testing on RPi 4 with Raspbian buster. I have installed the ROS noetic desktop version as you have suggested. The build with '~/ORB_SLAM3/build.sh' file works just fine. Is there anything that I might be doing wrong? I will really appreciate some help here.

zoldaten commented 1 year ago

sudo apt install libfmt-dev should go before build Sophus, i corrected.

swagatk commented 1 year ago

This did not solve my problem either. I am still getting the same error. In fact, I started by following the instructions given at this page. So, I had already installed this package. Is there anything else that I can try? Thanks for replying.