背景:
NVIDIA Jetson TX2 用RealSense T265 跑 ORB-SLAM3 ros
下载:
git clone https://github.com/UZ-SLAMLab/ORB_SLAM3.git
这时 Examples 里面没有ROS
├── Examples
│ ├── Calibration
│ ├── Monocular
│ ├── Monocular-Inertial
│ ├── REAMDME.md
│ ├── RGB-D
│ ├── RGB-D-Inertial
│ ├── Stereo
│ └── Stereo-Inertial
├── Examples_old
│ ├── Monocular
│ ├── Monocular-Inertial
│ ├── REAMDME.md
│ ├── RGB-D
│ ├── RGB-D-Inertial
│ ├── ROS
│ ├── Stereo
│ └── Stereo-Inertial
...
参考 https://github.com/UZ-SLAMLab/ORB_SLAM3/issues/442
将Examples_old文件夹下ROS文件夹复制到Examples文件夹下
sudo jtop
jetson TX2 刷机时,OpenCV 4.1.1 已安装,可以用这个版本的
修改 xxx/ORB_SLAM3/CMakeLists.txt
find_package(OpenCV 4.1.1)
if(NOT OpenCV_FOUND)
message(FATAL_ERROR "OpenCV > 4.4 not found.")
endif()
还有 xxx/ORB_SLAM3/Examples/ROS/ORB_SLAM3/CMakeLists.txt
find_package(OpenCV 4.1.1 QUIET)
if(NOT OpenCV_FOUND)
find_package(OpenCV 2.4.3 QUIET)
if(NOT OpenCV_FOUND)
message(FATAL_ERROR "OpenCV > 2.4.3 not found.")
endif()
endif()
错误1. No module named ‘rospkg’
File "/opt/ros/melodic/share/rosunit/cmake/../scripts/test_results_dir.py", line 43, in <module>
import rospkg
ModuleNotFoundError: No module named 'rospkg'
CMake Error at /opt/ros/melodic/share/ros/core/rosbuild/public.cmake:356 (message):
Failed to invoke
'/opt/ros/melodic/share/rosunit/cmake/../scripts/test_results_dir.py'
Call Stack (most recent call first):
CMakeLists.txt:4 (rosbuild_init)
当前在 conda base 环境中,Python 3.9.7
$ conda env list
# conda environments:
#
base * /home/wx/newdisk/3rdparty/mambaforge
imu_b9 /home/wx/newdisk/3rdparty/mambaforge/envs/imu_b9
退出conda base 环境
conda deactivate
此时:
$ pip list
Package Version
----------------------------- -------------------
...
rosparam 1.14.12
rospkg 1.3.0
rospy 1.14.12
rosservice 1.14.12
rostest 1.14.12
rostopic 1.14.12
rosunit 1.14.9
roswtf 1.14.12
...
rtabmap-ros 0.20.18
rviz 1.13.21
...
错误2. fatal error: sophus/se3.hpp: No such file or directory
ImuTypes.h:29:10: fatal error: sophus/se3.hpp: No such file or directory
#include
^~~~~~~~~~~~~~~~
compilation terminated.
CMakeFiles/MonoAR.dir/build.make:198: recipe for target 'CMakeFiles/MonoAR.dir/src/AR/ViewerAR.cc.o' failed
make[2]: *** [CMakeFiles/MonoAR.dir/src/AR/ViewerAR.cc.o] Error 1
make[2]: *** Waiting for unfinished jobs....
参考:在ubuntu18.04系统上使用ROS跑ORB-SLAM3时遇到的问题总结 在
xxx/Examples/ROS/ORB_SLAM3/CMakeLists.txt 的 include_directories
${PROJECT_SOURCE_DIR}/../../../Thirdparty/Sophus
如下:
include_directories(
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/../../../
${PROJECT_SOURCE_DIR}/../../../include
${PROJECT_SOURCE_DIR}/../../../include/CameraModels
${PROJECT_SOURCE_DIR}/../../../Thirdparty/Sophus
${Pangolin_INCLUDE_DIRS}
)
错误3. error: conversion from ‘Sophus::SE3f {aka Sophus::SE3}’ to non-scalar type ‘cv::Mat’ requested
/home/wxf/newdisk/ros/ORB_SLAM3/Examples/ROS/ORB_SLAM3/src/AR/ros_mono_ar.cc:151:41: error: conversion from ‘Sophus::SE3f {aka Sophus::SE3<float>}’ to non-scalar type ‘cv::Mat’ requested
cv::Mat Tcw = mpSLAM->TrackMonocular(cv_ptr->image,cv_ptr->header.stamp.toSec());
~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
参考:buildros.sh
错误4. error while loading shared libraries: libpango_core.so
error while loading shared libraries: libpango_core.so: cannot open shared object file: No such file or directory
参考 error while loading shared libraries: libpango_windowing.so: cannot open shared object file: No such
sudo ldconfig
错误5. Gtk-Message: 14:43:08.216: Failed to load module “canberra-gtk-module”
Gtk-Message: 14:43:08.216: Failed to load module "canberra-gtk-module"
参考:解决 Failed to load module canberra-gtk-module
sudo apt-get install libcanberra-gtk-module