1:安装cmake,gcc,g++,git,已经安装的忽略
sudo apt-get update
sudo apt-get install cmake gcc g++ git
2:安装Pangolin,我下载的是0.6稳定版
请将下载好的文件夹改名为Pangolin,放于主目录中。随后,新打开一个终端,依次输入以下命令:
sudo apt-get install libxkbcommon-dev
sudo apt-get install wayland-protocols
sudo apt install libglew-dev
cd Pangolin
mkdir build
cd build
cmake ..
make -j
sudo make install
库安装完成后,测试一下,能不能使用,请新打开一个终端,输入一下命令:
cd Pangolin
cd examples/HelloPangolin
mkdir build && cd build
cmake ..
make
./HelloPangolin
sudo apt-get install libeigen3-dev
4:安装opencv3(安装4会冲突!)
下载opencv3.4.15,https://github.com/opencv/opencv/archive/3.4.15.zip
打开一个新终端,输入以下命令:
sudo apt-get install build-essential
sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
cd opencv3.4.15
mkdir build
cd build
cmake ..
make -j
sudo make install
安装完成后,打开一个新终端:输入:
sudo gedit /etc/ld.so.conf.d/opencv.conf
这时会出现一个文档,在文档最后一行添加:
/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 apt-get install mlocate
sudo updatedb
测试opencv:输入如下代码:
cd opencv3.4.15/samples/cpp/example_cmake
cmake .
make
./opencv_example
出现错误:E: Unable to locate package libjasper-dev
解决:
sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt update
sudo apt install libjasper1 libjasper-dev
原链接需要修改很多错误,需要慢慢去百度,解决error。可参考下面我改好的链接
链接: https://pan.baidu.com/s/1–EDwLK86capVd13FC3EWw 提取码: cx3y
cd ORB_SLAM2
chmod +x build.sh
./build.sh
需要在ROS环境下运行ORB_SLAM,则需要执行下列三条命令:
chmod +x build_ros.sh
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:~/ORB-SLAM2/src/ORB_SLAM2/Examples/ROS
./build_ros.sh
如果出现如下错误:
解决方案:
修改home/orb_slam/src/ORB_SLAM2/Examples/ROS/ORB_SLAM2/文件夹下的CMakeLists.txt文件。
在set(LIBS xxxxx 的后面加上下列这一句代码:
-lboost_system
再次执行./build_ros.sh 后成功
/ORB_SLAM2/Examples/ROS/ORB_SLAM2/src,目录下,将ros_stereo.cc复制一份,重新命名zed_stereo_rect.cc并修改其内容:
1.修改节点名称
// 要修改的程序都在Examples/ROS/ORB_SLAM2/src下
// 单目数据集就改ros_mono.cc,双目数据集就改ros_stereo.cc
// 这里以双目为例,查找到message_filters所在行进行修改
message_filters::Subscriber<sensor_msgs::Image> left_sub(nh, "/zed2/zed_node/left/image_rect_gray2", 1);
message_filters::Subscriber<sensor_msgs::Image> right_sub(nh, "/zed2/zed_node/right/image_rect_gray2", 1);
2.修改cmakelist
# Node for ZED camera
rosbuild_add_executable(zed_Stereo_rect
src/zed_stereo_rect.cc
)
target_link_libraries(zed_Stereo_rect
${LIBS}
)
./build_ros.sh
4.运行
cd ORB_SLAM2/src/ORB_SLAM2
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:~/ORB-SLAM2/src/ORB_SLAM2/Examples/ROS
rosrun ORB_SLAM2 zed_Stereo_rect Vocabulary/ORBvoc.txt Examples/Stereo/EuRoC.yaml false
rosbag play xxx.bag
运行成功,可在界面中观察运行情况,结束后可生成位姿文件。