Ubuntu1604+SLAM+kinectv1

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

将文件中对应代码修改成如下形式
// 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

显示如下信息表示安装成功
-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

按照官网步骤如下命令逐条运行

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-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
sudo apt-get update
sudo apt-get install ros-kinetic-desktop-full
apt-cache search ros-kinetic(查看可用的安装包)
sudo rosdep init
rosdep update
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
sudo apt install python-rosinstall python-rosinstall-generator python-wstool build-essential

安装及测试驱动

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为如下内容

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 -j2

chmod +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内容如下

<launch> 
  <node pkg="ORB_SLAM2" type="RGBD" name="ORB_SLAM2" output="screen"  
        args="/home/kaneiki/Desktop/SLAM/ORB_SLAM2/Vocabulary/ORBvoc.txt 
         /home/kaneiki/Desktop/SLAM/ORB_SLAM2/Examples/RGB-D/TUM2.yaml"/> 

  <include file="$(find openni_launch)/launch/openni.launch"> 
    <!-- use device registration --> 
    <arg name="depth_registration" value="true" /> 
    <arg name="rgb_processing" value="false" /> 
    <arg name="ir_processing" value="false" /> 
    <arg name="depth_processing" value="false" /> 
    <arg name="depth_registered_processing" value="false" /> 
    <arg name="disparity_processing" value="false" /> 
    <arg name="disparity_registered_processing" value="false" /> 
    <arg name="hw_registered_processing" value="false" /> 
    <arg name="sw_registered_processing" value="false" /> 
  </include> 
</launch> 

args下两条路径根据实际情况修改

运行项目

roslaunch kinect_orbslam2.launch

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值