Ubuntu1604+SLAM+kinectv1
工具安装
sudo apt-get install cmake git
sudo apt-get install gcc g++
Boost安装
sudo apt-get install libboost-all-dev
安装Pangolin
安装依赖
OpenGL
sudo apt install libgl1-mesa-dev
Glew
sudo apt install libglew-dev
下载源码
git clone https://github.com/stevenlovegrove/Pangolin.git
修改源码
注意这里是必要操作确保Pangolin之后可用
打开相应的源码文件
gedit Path_To_Pangolin/Pangolin/src/display/device/display_x11.cpp
将文件中对应代码修改成如下形式
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 // Desired attributes
static int visual_attribs[] =
{
GLX_X_RENDERABLE , True,
GLX_DRAWABLE_TYPE , GLX_WINDOW_BIT,
GLX_RENDER_TYPE , GLX_RGBA_BIT,
GLX_X_VISUAL_TYPE , GLX_TRUE_COLOR,
GLX_RED_SIZE , 8,
GLX_GREEN_SIZE , 8,
GLX_BLUE_SIZE , 8,
GLX_ALPHA_SIZE , 8,
GLX_DEPTH_SIZE , 24,
GLX_STENCIL_SIZE , 8,
GLX_DOUBLEBUFFER , glx_doublebuffer ? False : False,
//GLX_SAMPLE_BUFFERS , glx_sample_buffers,
//GLX_SAMPLES , glx_sample_buffers > 0 ? glx_samples : 0,
None
};
编译
cd Pangolin
mkdir build
cd build
cmake ..
make -j2
安装
sudo make install
安装OpenCV3.2.0
安装依赖
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
下载OpenCV3.2.0的文件包
去官网下载(考验网速的时候)
编译安装
cd OpenCV3.2.0
mkdir build
cd build
cmake ..
make -j
sudo make install
验证
终端输入
pkg-config —cflags —libs opencv
显示如下信息表示安装成功
1 | -I/usr/local/include/opencv -I/usr/local/include -L/usr/local/lib -lopencv_shape -lopencv_stitching -lopencv_objdetect -lopencv_superres -lopencv_videostab -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_video -lopencv_photo -lopencv_ml -lopencv_imgproc -lopencv_flann -lopencv_viz -lopencv_core |
安装Eigen3
sudo apt-get install libeigen3-dev
sudo cp -r /usr/local/include/eigen3/Eigen /usr/local/include
kinectv1驱动安装
OpenNI
安装依赖
sudo apt-get install git build-essential python libusb-1.0-0-dev freeglut3-dev openjdk-8-jdk
sudo apt-get install doxygen graphviz mono-complete
安装
git clone https://github.com/OpenNI/OpenNI.git
cd OpenNI
git checkout Unstable-1.5.4.0
cd Platform/Linux/CreateRedist
chmod +x RedistMaker
./RedistMaker
cd ../Redist/OpenNI-Bin-Dev-Linux-[xxx] (where [xxx] is your architecture and this particular OpenNI release)
sudo ./install.sh
Kinect Sensor
git clone https://github.com/avin2/SensorKinect
cd SensorKinect
cd Platform/Linux/CreateRedist
chmod +x RedistMaker
./RedistMaker
cd ../Redist/Sensor-Bin-Linux-[xxx] (where [xxx] is your architecture and this particular OpenNI release)
chmod +x install.sh
sudo ./install.sh
测试
cd OpenNI/Platform/Linux/Bin/x64-Release/NiViewer
./NiViewer
运行结果为深黄色图像
安装ROS
按照官网步骤如下命令逐条运行
1 | sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' |
安装及测试驱动
sudo apt-get install libfreenect-dev
方法1
sudo apt-get install ros-kinetic-openni-camera
sudo apt-get install ros-kinetic-openni-launch
rosstack profile
rospack profile
roslaunch openni_launch openni.launch
rosrun rqt_image_view rqt_image_view
方法2
sudo apt-get install ros-kinetic-freenect-camera
ros-kinetic-freenect-stack ros-kinetic-freenect-launch
roslaunch freenect_launch freenect-registered-xyzrgb.launch
rosrun rqt_image_view rqt_image_view
安装ORB-SLAM2
下载源码
git clone https://github.com/raulmur/ORB_SLAM.git
修改bash
gedit ~/.bashrc
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH_TO_PARENT_OF_ORB_SLAM
(在后面添加)
source ~/.bashrc编译build.sh
修改build.sh为如下内容
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 echo "Configuring and building Thirdparty/DBoW2 ..."
cd Thirdparty/DBoW2
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j
cd ../../g2o
echo "Configuring and building Thirdparty/g2o ..."
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j
cd ../../../
echo "Uncompress vocabulary ..."
cd Vocabulary
tar -xf ORBvoc.txt.tar.gz
cd ..
echo "Configuring and building ORB_SLAM2 ..."
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j2chmod +x build.sh
./build.sh如果出错则需要增加交换空间
sudo dd if=/dev/zero of=/var/swapfile1 bs=1024 count=2097152(2G可根据情况调整)
sudo mkswap /var/swapfile1
sudo swapon /var/swapfile1(每次重启终端需要重新挂载)
free -m 用于产看swap大小
编译build_ros.sh
chmod +x build_ros.sh
./build_ros.sh
运行ORB-SLAM2
在ORB-SLAM2根目录下建立文件kinect_orbslam2.launch内容如下
1 | <launch> |
args下两条路径根据实际情况修改
运行项目
roslaunch kinect_orbslam2.launch