如何⽤orbslam2运⾏数据集以及让⾃⼰电脑相机运⾏单⽬slam
1、下载orbslam2
2、下载数据集(tum和kitti的)
3、按照orbslam2的readme配置环境
Prerequisites
We have tested the library in **Ubuntu 12.04**, **14.04** and **16.04**, but it should be easy to compile in other platforms.
A powerful computer (e.g. i7) will ensure real-time performance and provide more stable and accurate results.
## C++11 or C++0x Compiler
We use the new thread and chrono functionalities of C++11.
现在都⽀持c++11了
## Pangolin
pangolin安装⽅法
先安装依赖
sudo apt-get install libglew-dev
sudo apt-get install libboost-dev libboost-thread-dev libboost-filesystem-dev
sudo apt-get install libpython2.7-dev
mkdir build
cmake -DCPP11_NO_BOOSR=1 ..
make -j16(这⾥16看⾃⼰电脑线程多少⽽定)
sudo make install
opencv安装⽅法
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install cmake
sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg.dev libtiff4.dev libswscale-dev libjasper-dev
mkdir build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
make -j16(这⾥16看⾃⼰电脑线程多少⽽定)
sudo make install
sudo gedit /etc/f.f
末尾添加/usr/local/lib
sudo ldconfig
sudo gedit /etc/bash.bashrc
末尾添加两⾏
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
source /etc/bash.bashrc
sudo updatedb
Eigen3安装⽅法
mkdir build
cmake ..
make -j16(这⾥16看⾃⼰电脑线程多少⽽定)
sudo make install
DBoW2 and g2o
这两个作者放到了第三⽅库⾥,不⽤安装,但需要修改⼀个地⽅,防⽌后⾯出错,将g2o 的cmakelists中的-march=native删除,保存
## ROS (optional)
We provide some examples to process the live input of a monocular, stereo or RGB-D camera using [ROS](). Building these examples is optional. In case you want to use ROS, a version Hydro or newer is needed.
ROS安装⽅法
⾸先配置ubuntu软件库
避免后⾯会出现⽆法定位软件包的错误,这⾥ROS提供了国内的安装源,添加国内安装源命令
sudo sh -c '. /etc/lsb-release && echo "deb mirrors.ustc.edu/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
设置密钥
sudo apt-key adv --keyserver hkp://keyserver.ubuntu:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
更新软件
sudo apt update
sudo apt-key adv --keyserver keyserver.ubuntu --recv-keys F42ED6FBAB17C654
再更新软件
sudo apt update
安装ros melodic
sudo apt-get install ros-melodic-desktop-full
安装rosdep
sudo apt install python-rosdep
rosdep初始化
cd /etc
sudo gedit hosts
在打开的⽂件末尾加⼊
151.101.84.133 raw.githubusercontent
保存退出,再进⾏rosdep初始化
sudo rosdep init
rosdep 更新
rosdep update
添加ros环境变量
echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
source ~/.bashrc
安装rosinstall
sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential
4、使⽤⾃⼰电脑相机运⾏单⽬slam
创建ros⼯作空间
mkdir -p ~/test/src
cd ~/test
catkin_make
在主⽬录下,ctrl+h,打开.bashrc,末端输⼊source ~/test/devel/setup.bash,保存
source ~/.bashrc
安装usb_cam包
cd ~/test
catkin_make
roslaunch usb_cam usb_cam-test.launch,测试后退出
编译报错及解决⽅案
将下载解压后的orbslam2放到src下⾯
修改~/test/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src/
原 /camera/image_raw 改为/usb_cam/image_raw
将ORM_SLAM2的cmakelists中的-march=native以及 g2o 的cmakelists中的-march=native删掉(g2o前⾯提到过)
然后编译
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:~/test/src/ORB_SLAM2/Examples/ROS
./build_ros.sh
1、出现这个错误ORB_SLAM2/: error: ‘usleep’ was not declared in this scope usleep(5000)
解决⽅案:
到对应的⽂件的⾸部加⼊ 头⽂件
#include<unistd.h>
根据实际情况,提⽰哪个⽂件usleep有问题,就去加这个头⽂件。
需要增加unistd.h的⽂件还有:
Examples/Monocular/
Examples/Monocular/
Examples/Monocular/
Examples/RGB-D/
Examples/Stereo/
Examples/Stereo/
2、出现这个错误CMakeFiles/RGBD.dir/build.make:197: recipe for target ‘…/RGBD’ failed
解决⽅案:
修改~/test/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/⽂件夹下的⽂件,在set(LIBS xxxxx 的后⾯加上-lboost_system)
3、出现这个错误No module named 'rospkg'
解决⽅案:
ubuntu怎么安装python先切换到python3(如果⽤python2就把3改成2),如果是anaconda3就默认python3,不需要前两⾏
alias python=python3
source ~/.bashrc
pip3 install rospkg
4、出现这个错误
Framebuffer with requested attributes not available. Using available framebuffer. You may see visual artifacts.init done opengl support available
New Map created with 118 points 段错误(核⼼已转储)
解决⽅案:
将ORM_SLAM2的cmakelists中的-march=native以及 g2o 的cmakelists中的-march=native删掉(g2o前⾯提到过)
编译成功后
roslaunch usb_cam usb_cam-test.launch
rosrun ORB_SLAM2 Mono ~/test/src/ORB_SLAM2/
~/test/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/Asus.yaml
结果如下:

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。