我是靠谱客的博主 朴实向日葵,最近开发中收集的这篇文章主要介绍vslam从入门到入土:使用D435的orb-slam2在ubuntu18中的安装0.更新所有库1.ROS2.Pangolin3. Realsense安装4. orb-slam2 安装5. 摄像头在ros中启动测试orb-slam2运行:,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

0.更新所有库

sudo apt update
sudo apt upgrade

1.ROS

建议使用ROS官方网的步骤  melodic/Installation/Ubuntu - ROS Wiki

一定要看清楚版本 ubuntu18 是 melodic

2.Pangolin

https://github.com/stevenlovegrove/Pangolin.git

安装依赖

sudo apt-get install libglew-dev
sudo apt-get install cmake
sudo apt-get install libpython2.7-dev
sudo apt-get install ffmpeg libavcodec-dev libavutil-dev libavformat-dev libswscale-dev libavdevice-dev
sudo apt-get install libdc1394-22-dev libraw1394-dev
sudo apt-get install libjpeg-dev libpng12-dev libtiff5-dev libopenexr-dev

pangolin安装:

cd Pangolin
mkdir build
cd build
cmake ..
make -j
sudo make install

3. Realsense安装

参考  Ubuntu18.04 安装D435i ROS_哦*&的博客-CSDN博客

1.注册公钥:

sudo apt-key adv --keyserver keys.gnupg.net --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE || sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE

2、添加包仓库列表

sudo add-apt-repository "deb https://librealsense.intel.com/Debian/apt-repo $(lsb_release -cs) main" -u

3.添加库

sudo apt-get install git libssl-dev libusb-1.0-0-dev pkg-config libgtk-3-dev
sudo apt-get install libglfw3-dev libgl1-mesa-dev libglu1-mesa-dev
sudo apt-get install librealsense2-dkms
sudo apt-get install librealsense2-utils
sudo apt-get install librealsense2-dev
sudo apt-get install librealsense2-dbg

4.运行脚本

git clone https://github.com/IntelRealSense/librealsense
cd librealsense
./scripts/setup_udev_rules.sh

5.编译

mkdir build
cd build
cmake ../ -DBUILD_EXAMPLES=true
make -j
sudo make install

安装realsense-ros:

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src/
git clone https://github.com/IntelRealSense/realsense-ros.git
git clone https://github.com/pal-robotics/ddynamic_reconfigure.git
cd ~/catkin_ws
catkin_make clean
catkin_make -DCATKIN_ENABLE_TESTING=False -DCMAKE_BUILD_TYPE=Release
catkin_make install
cd
echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc

测试realsense_ros:

roslaunch realsense2_camera rs_camera.launch

若上列命令出现neither a launch file in package,打开终端执行下列命令再重新输入上述命令

source catkin_ws/devel/setup.bash

4. orb-slam2 安装

cd ~/catkin_ws/src/
git clone https://github.com/raulmur/ORB_SLAM2.git ORB_SLAM2
cd ORB_SLAM2
chmod +x build.sh
./build.sh

出现 error: ‘usleep’ was not declared in this scope usleep(5000)

在以下文件内添加头文件:

#include<unistd.h>

Examples/Moncular/mono_euroc.cc
Examples/Moncular/mono_kitti.cc
Examples/Moncular/mono_tum.cc
Examples/RGB-D/rgbd_tum.cc
Examples/Stereo/stereo_euroc.cc
Examples/Stereo/stereo_kitti.cc

Examples/ROS/ORB_SLAM2/src/AR/ViewerAR.cc
文件:/home/wyh/catkin_ws/src/ORB_SLAM2/src
src/LocalMapping.cc
src/LoopClosing.cc
src/System.cc
src/Tracking.cc
src/Viewer.cc

进入catkin_ws/src/ORB_SLAM2/include,打开Loopclsing.h, 第50行

将 const KeyFrame*  改成 KeyFrame* const

然后

chmod +x build_ros.sh
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:~/catkin_ws/src/ORB_SLAM2/Examples/ROS
./build_ros.sh

5. 摄像头在ros中启动测试

在ORB-SLAM2/Examples/ROS/ORB-SLAM2/src中修改ros_rgbd.cc的topic订阅

message_filters::Subscriber<sensor_msgs::Image> rgb_sub(nh, "/camera/color/image_raw", 1);
message_filters::Subscriber<sensor_msgs::Image> depth_sub(nh, "/camera/aligned_depth_to_color/image_raw", 1);

在Examples/RGB-D把TUM1.yaml复制多一个并且命名为D435.yaml,然后把你的D435内参填入D435.yaml。

内参获取:

roslaunch realsense2_camera rs_rgbd.launch
rostopic echo /camera/color/camera_info

报错:

Resource not found: rgbd_launch
ROS path [0]=/opt/ros/noetic/share/ros
ROS path [1]=/home/casso/catkin_ws/src
ROS path [2]=/opt/ros/noetic/share
The traceback for the exception was written to the log file

解决:

sudo apt install ros-melodic-rgbd-launch

重新编译:

chmod +x build.sh
./build.sh
chmod +x build_ros.sh
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:~/catkin_ws/src/ORB_SLAM2/Examples/ROS
./build_ros.sh

orb-slam2运行:

把所有终端关闭

1.打开ros

roscore

2.打开摄像头

新终端输入:

roslaunch realsense2_camera rs_rgbd.launch

3.在catkin_ws/src/ORB_SLAM2中打开终端运行以下命令,把字典、相机内参导入orb-slam2。

新终端输入:

rosrun ORB_SLAM2 RGBD Vocabulary/ORBvoc.txt Examples/RGB-D/D435.yaml

----------------------------------------------------------------------------------------------------------------------------

结尾感谢:

作者:高翔博士  《视觉SLAM十四讲》

作者:哦*&    ubuntu18.04 D435i ROS ORB-SLAM2_哦*&的博客-CSDN博客

最后

以上就是朴实向日葵为你收集整理的vslam从入门到入土:使用D435的orb-slam2在ubuntu18中的安装0.更新所有库1.ROS2.Pangolin3. Realsense安装4. orb-slam2 安装5. 摄像头在ros中启动测试orb-slam2运行:的全部内容,希望文章能够帮你解决vslam从入门到入土:使用D435的orb-slam2在ubuntu18中的安装0.更新所有库1.ROS2.Pangolin3. Realsense安装4. orb-slam2 安装5. 摄像头在ros中启动测试orb-slam2运行:所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(43)

评论列表共有 0 条评论

立即
投稿
返回
顶部