ORB_SLAM2和ORB_SLAM3在ROS上运行monoslam

1.参考博客

https://blog.csdn.net/xyt723916/article/details/89388188
https://blog.csdn.net/qq_27339501/article/details/109682210
https://blog.csdn.net/qq_42585108/article/details/105519029
https://blog.csdn.net/qq_42585108/article/details/105563648
感谢以上博客的指点
同时也感谢师姐的指点操作basler相机修改发布话题
pylon下更改usb3.0相机的ID,并在ROS下打开两个相机,甚至更多

2. 操作步骤

2.1 拷贝文件

将ORBSLAM2或者ORBSLAM3拷贝到ros工作区/home/jinln/catkin_ws/src下,可以编译一下非ROSslam,也可以不编译,编译即:

cd ORB_SLAM2 / ORB_SLAM3
chmod +x build.sh
./build.sh

2.2 添加bash

将包含Examples/ROS/ORB_SLAM2的路径添加到ROS_PACKAGE_PATH环境变量中。打开.bashrc文件并在最后添加以下行

sudo  gedit ~/.bashrc
# robslam2 
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/home/jinln/catkin_ws/src/ORB_SLAM2/Examples/ROS
# 或者robslam3
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/home/jinln/catkin_ws/src/ORB_SLAM3/Examples/ROS

更新bash

source /home/jinln/catkin_ws/devel/setup.sh

2.3 修改话题

ros_orbslam中的定义的话题为/camera/left/image_raw,需要到/home/jinln/catkin_ws/src/ORB_SLAM3/Examples/ROS/ORB_SLAM3/src/ros_mono.cc 文件中修改这个话题为自己相机画布的话题,我的为/remove_distort_image

    ros::Subscriber sub = nodeHandler.subscribe("/remove_distort_image", 1, &ImageGrabber::GrabImage,&igb);

再编译build_ros.sh脚本

cd catkin_ws/src/ORB_SLAM2 或者 cd catkin_ws/src/ORB_SLAM3
chmod +x build_ros.sh
./build_ros.sh

如果遇到报错

-- Configuring incomplete, errors occurred!
See also "/home/jinln/catkin_ws/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/build/CMakeFiles/CMakeOutput.log".
make: *** No targets specified and no makefile found.  Stop.

则修改Examples/ROS/ORB_SLAM2/文件夹下的CMakeLists.txt文件,改为

set(LIBS 
${OpenCV_LIBS} 
${EIGEN3_LIBS}
${Pangolin_LIBRARIES}
${PROJECT_SOURCE_DIR}/../../../Thirdparty/DBoW2/lib/libDBoW2.so
${PROJECT_SOURCE_DIR}/../../../Thirdparty/g2o/lib/libg2o.so
${PROJECT_SOURCE_DIR}/../../../lib/libORB_SLAM2.so
-lboost_system
)

如果报错

3:23: error: ‘usleep’ was not declared in this scope
         usleep(mT*1000);

添加头文件到对应报错的文件中:

#include 

2.4 发布相机节点

catkin_make
source ~/catkin_ws/devel/setup.bash
roslaunch pylon_camera pylon_camera0.launch

2.5 发布自己修改相机话题

主要内容是去畸变,该工程转到gethub
remove_distort

source devel/setup.bash
roslaunch remove_distort rm_distort.launch

2.6 运行slam

rosrun ORB_SLAM2 Mono PATH_TO_VOCABULARY PATH_TO_SETTINGS_FILE

rosrun ORB_SLAM2 Mono /home/jinln/jinln/QTproject/ORB_SLAM2/Vocabulary/ORBvoc.txt /home/jinln/Desktop/ORB_SLAM2/Examples/Monocular/baslermono.yaml
rosrun ORB_SLAM3 Mono /home/jinln/catkin_ws/src/ORB_SLAM3/Vocabulary/ORBvoc.txt /home/jinln/catkin_ws/src/ORB_SLAM3/Examples/Monocular/baslermono.yaml

3. ORB_SLAM3运行双目

https://blog.csdn.net/ainitutu/article/details/110138858

你可能感兴趣的:(Program,slam,ORB_SLAM2,ORB_SLAM3,monoslam)