基于XTDrone的视觉SLAM章节,进行环境配置。中途遇到了一些问题,一一解决后成功完成了,记录该流程。
一、遇到的问题与参考链接
- XTDrone相关参考连接:链接
- 依赖安装教程:ORB SLAM2 编译&运行
- pangolin编译错误(因为需要0.5版本,而最新的是0.6,会导致错误)的删除:编译orbslam2时,Pangolin could not be found because dependency Eigen3 could not be found,解决方法
- 安装0.5版本的pangolin:ubuntu18.04下 安装SLAM-Pangolin(亲测有效)
- Error: libuvc.so.0:链接
二、整个安装流程
- 安装各种依赖:
sudo apt install -y libgl1-mesa-dev
sudo apt install -y libglew-dev
sudo apt install -y cmake
sudo apt install -y libpython2.7-dev
sudo apt install -y python-pip
sudo python -mpip install numpy pyopengl Pillow pybind11
sudo apt install -y pkg-config
sudo apt install -y libegl1-mesa-dev libwayland-dev libxkbcommon-dev wayland-protocols
sudo apt install -y ffmpeg libavcodec-dev libavutil-dev libavformat-dev libswscale-dev libavdevice-dev
sudo apt install -y libdc1394-22-dev libraw1394-dev
sudo apt install -y libjpeg-dev libpng-dev libtiff5-dev libopenexr-dev
# 1)安装 GLEW:
sudo apt-get install -y libglew-dev
# 2)安装 libuvc:
git clone https://github.com/ktossell/libuvc
cd libuvc
mkdir build
cd build
cmake ..
make && sudo make install
- 提前解决 libuvc.so.0问题:
sudo /sbin/ldconfig -v
- 安装0.5版本的pangolin
先下载并解压缩到ubuntu的用户目录:
https://github.com/stevenlovegrove/Pangolin/releases/tag/v0.5
再进行安装
cd Pangolin
mkdir build
cd build
cmake ..
make -j8
sudo make install
- 如果前面安装了0.6版本的Pangolin而导致出错,可以通过以下方法进行删除,再进行第三步
1 在pangolin的build文件夹下 sudo make uninstall
2 /usr/local/include 删除pangolin文件夹
- 进行ORBSLAM2编译
如果没啥问题,就应该完成了
cp -r ~/XTDrone/sensing/slam/vslam/ORB_SLAM2/ ~/catkin_ws/src/
mkdir ~/catkin_ws/scripts/
cp ~/catkin_ws/src/ORB_SLAM2/xtdrone* ~/catkin_ws/scripts/
cd ~/catkin_ws/src/ORB_SLAM2
chmod +x build.sh
./build.sh
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/catkin_ws/src/ORB_SLAM2/Examples/ROS #将这句放到~/.bashrc中,以后使用更方便
chmod +x build_ros.sh
./build_ros.sh
- 进行测试
# 启动仿真
cd PX4_Firmware
roslaunch px4 indoor1.launch
# 启动ORBSLAM2
cd ~/catkin_ws/scripts/
sh xtdrone_run_stereo.sh
# 无人机链接
cd ~/XTDrone/communication
python multirotor_communication.py iris 0
# 无人机控制
cd ~/XTDrone/control/keyboard
python multirotor_keyboard_control.py iris 1 vel
- 测试效果