Hanjie's Blog

一只有理想的羊驼

安装Intel OpenCL支持(可选,我的是Intel内置显卡)1

这里下载Intel® Code Builder for OpenCL™ API 2015 for Ubuntu* (64-bit)。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
sudo apt-get install -y rpm alien libnuma1

tar -xvf intel_code_builder_for_opencl_2015_ubuntu_5.0.0.43_x64.tgz
cd intel_code_builder_for_opencl_2015_ubuntu_5.0.0.43_x64

sudo rpm --import PUBLIC_KEY.PUB
cd rpm

sudo fakeroot alien --to-deb opencl-1.2-base-5.0.0.43-1.x86_64.rpm
sudo fakeroot alien --to-deb opencl-1.2-intel-cpu-5.0.0.43-1.x86_64.rpm

sudo dpkg -i opencl-1.2-base_5.0.0.43-2_amd64.deb
sudo dpkg -i opencl-1.2-intel-cpu_5.0.0.43-2_amd64.deb

sudo fakeroot alien --to-deb opencl-1.2-devel-5.0.0.43-1.x86_64.rpm
sudo fakeroot alien --to-deb opencl-1.2-intel-devel-5.0.0.43-1.x86_64.rpm

sudo dpkg -i opencl-1.2-devel_5.0.0.43-2_amd64.deb
sudo dpkg -i opencl-1.2-intel-devel_5.0.0.43-2_amd64.deb

The above installs the library files and installable client driver registration in /opt/intel/opencl-1.2-5.0.0.43. Two more steps were needed to run an OpenCL program.

Add library to search path:

1
sudo gedit /etc/ld.so.conf.d/intelOpenCL.conf


Add the line:

1
/opt/intel/opencl-1.2-5.0.0.43/lib64

Link to the intel icd file in the expected location:

1
2
3
4
5
sudo mkdir /etc/OpenCL
sudo mkdir /etc/OpenCL/vendors

sudo ln /opt/intel/opencl-1.2-5.0.0.43/etc/intel64.icd /etc/OpenCL/vendors/intel64.icd
sudo ln -s /opt/intel/opencl-1.2-5.0.0.43/lib64/libOpenCL.so /usr/lib/libOpenCL.so

还需要将opencl_include_dir放到系统的环境中:

1
sudo gedit ~/.bashrc

填入:

1
export PATH="/opt/intel/opencl-1.2-sdk-5.0.0.43/include:$PATH"
1
2
source ~/.bashrc
sudo ldconfig

测试结果:

1
2
sudo apt-get install clinfo
sudo clinfo

安装NVIDIA的支持(可选)

首先根据这里安装CUDA。

下载Kinectv2的开源驱动libfreenect22,解压缩:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
git clone https://github.com/OpenKinect/libfreenect2.git
cd depends
sh ./download_debs_trusty.sh
sh ./install_ubuntu.sh

sudo dpkg -i libglfw3*_3.0.4-1_*.deb
sudo apt-get install build-essential cmake pkg-config libturbojpeg libjpeg-turbo8-dev mesa-common-dev freeglut3-dev libxrandr-dev libxi-dev

sudo dpkg -i debs/libusb*deb
sudo dpkg -i debs/{libva,i965}*deb; sudo apt-get install -f

sudo apt-add-repository ppa:deb-rob/ros-trusty && sudo apt-get update
cd

cd ..
mkdir build && cd build
cmake .. -DENABLE_CXX11=ON
make
sudo make install

sudo cp ../platform/linux/udev/90-kinect2.rules /etc/udev/rules.d/

如在编译时出现错误:

1
2
3
4
5
6
7
Linking CXX shared library lib/libfreenect2.so
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libturbojpeg.a(libturbojpeg_la-turbojpeg.o): relocation R_X86_64_32 against `.data' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/libturbojpeg.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
make[2]: *** [lib/libfreenect2.so.0.2.0] Error 1
make[1]: *** [CMakeFiles/freenect2.dir/all] Error 2
make: *** [all] Error 2

可重新安装libturbojpeg:

1
sudo apt-get install libturbojpeg

升级内核(14.04):

1
sudo apt-get install linux-generic-lts-wily

or:

1
sudo apt-get install inux-generic-lts-vivid

测试:

1
./bin/Protonect

另外:

libusb可以这么安装:

1
2
3
sudo apt-add-repository ppa:floe/libusb
sudo apt-get update
sudo apt-get install libusb-1.0-0-dev

GLFW3可以这么安装3

1
2
3
4
5
echo "deb http://ppa.launchpad.net/keithw/glfw3/>ubuntu trusty main" | sudo tee -a /etc/apt/sources.list.d/fillwave_ext.list
echo "deb-src http://ppa.launchpad.net/keithw/glfw3/ubuntu trusty main" | sudo tee -a /etc/>apt/sources.list.d/fillwave_ext.list

sudo apt-get update
sudo apt-get install libglfw3-dev

安装iai_kinect2

This is a collection of tools and libraries for a ROS Interface to the Kinect One (Kinect v2).

1
2
3
4
5
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
git clone https://github.com/code-iai/iai_kinect2.git
cd iai_kinect2
rosdep install -r --from-paths .

此时可能会显示有关[kinect2_bridge] and [depth_registration]的错误,不用理它。

1
2
cd ~/catkin_ws
catkin_make -DCMAKE_BUILD_TYPE="Release"

测试

打开一个窗口:

1
roscoe

打开另外一个窗口:

1
2
3
cd ~/catkin_ws/
source devel/setup.sh
roslaunch kinect2_bridge kinect2_bridge.launch

再打开另外一个窗口:

1
2
3
cd ~/catkin_ws/
source devel/setup.bash
rosrun kinect2_viewer kinect2_viewer

安装Pangolin

1
2
3
4
5
6
7
sudo apt-get install libglew-dev libboost-dev libboost-thread-dev libboost-filesystem-dev
git clone https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin
mkdir build
cd build
cmake -DCPP11_NO_BOOST=1 ..
make -j

ORB_SLAM2

1
2
3
4
5
6
sudo apt-get install libblas-dev liblapack-dev

git clone https://github.com/raulmur/ORB_SLAM2.git ORB_SLAM2
cd ORB_SLAM2
chmod +x build.sh
./build.sh

  1. https://software.intel.com/en-us/forums/opencl/topic/390630↩︎

  2. https://github.com/OpenKinect/libfreenect2↩︎

  3. https://github.com/filipwasil/fillwave/issues/58↩︎

系统环境

  • 型号:Thinkpad 460p
  • 显卡:GeForce 940MX & Intel HD Graphics 530
  • 系统:Ubuntu 14.04.5 LTS
  • 内核:4.4.0-31-generic

前期准备

1
2
3
4
sudo apt-get update
sudo apt-get upgrade

sudo apt-get install build-essential libgtk2.0-dev libjpeg-dev libtiff4-dev libjasper-dev libopenexr-dev cmake python-dev python-numpy python-tk libtbb-dev libtbb2 libeigen2-dev libeigen3-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev libqt4-dev libqt4-opengl-dev sphinx-common texlive-latex-extra libv4l-dev libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev git

安装显卡驱动

CUDA 7.5自带的驱动在Ubuntu 14.04.5(4.4 kernel)上会出现安装错误:

1
The driver installation is unable to locate the kernel source.

这是由于CUDA 7.5的驱动是针对3.xx kernels的,所以需要安装较新的驱动1

这里下载安装包cuda_8.0.61_375.26_linux.run

这里下载安装包cuda_7.5.18_linux.run

1
sudo apt-get install linux-headers-$(uname -r) g++

关掉开源的Nouveau驱动2

1
lsmod | grep nouveau #检测Nouveau是否开启,有输出则开启,无输出则为开启

如果Nouveau开启:

1
sudo gedit /etc/modprobe.d/blacklist-nouveau.conf

在创建的文件中输入以下内容关闭掉Nouveau

1
2
blacklist nouveau
options nouveau modeset=0

更新list,使得更改生效

1
sudo update-initramfs -u

重启电脑,进入登录界面的时候,先不要登录进入桌面3,按Ctrl+Alt+F1进入命令行界面,关闭图形化界面:

1
sudo service lightdm stop

安装驱动

继续上个步骤,在命令行界面中进入到cuda_8.0.61_375.26_linux.run所在文件夹,运行:

1
2
chmod +x cuda_8.0.61_375.26_linux.run
sudo sh cuda_8.0.61_375.26_linux.run

注意我们这里只选择安装Driver!

安装CUDA 7.5

1
2
chmod +x cuda_7.5.18_linux.run
sudo sh cuda_7.5.18_linux.run

需要gcc 4.8版本的编译器 注意不要安装openGL,不然会遇到循环登录的问题!

重启图形化界面:

1
sudo service lightdm start

配置环境:

1
sudo gedit ~/.bashrc

添加:

1
2
export PATH=/usr/local/cuda-7.5/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-7.5/lib64:$LD_LIBRARY_PATH

重启电脑,执行:

1
ls /dev/nvidia*

应出现如:

1
/dev/nvidia0  /dev/nvidiactl  /dev/nvidia-uvm  /dev/nvidia-uvm-tools

"/dev/nvidia*: No such file or directory"错误

1
sudo gedit /etc/rc.local

去掉第一行中#!/bin/sh -e-e, 并且在exit 0前添加4

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
/sbin/modprobe nvidia

if [ "$?" -eq 0 ]; then
# Count the number of NVIDIA controllers found.
NVDEVS=`lspci | grep -i NVIDIA`
N3D=`echo "$NVDEVS" | grep "3D controller" | wc -l`
NVGA=`echo "$NVDEVS" | grep "VGA compatible controller" | wc -l`

N=`expr $N3D + $NVGA - 1`
for i in `seq 0 $N`; do
mknod -m 666 /dev/nvidia$i c 195 $i
done

mknod -m 666 /dev/nvidiactl c 195 255

else
exit 1
fi

/sbin/modprobe nvidia-uvm

if [ "$?" -eq 0 ]; then
# Find out the major device number used by the nvidia-uvm driver
D=`grep nvidia-uvm /proc/devices | awk '{print $1}'`

mknod -m 666 /dev/nvidia-uvm c $D 0
else
exit 1
fi

测试

输入:

1
cat /proc/driver/nvidia/version

显示:

1
2
NVRM version: NVIDIA UNIX x86_64 Kernel Module  375.26  Thu Dec  8 18:36:43 PST 2016
GCC version: gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)

输入:

1
nvcc -V

输出:

1
2
3
4
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2015 NVIDIA Corporation
Built on Tue_Aug_11_14:27:32_CDT_2015
Cuda compilation tools, release 7.5, V7.5.17

编译sample

NVIDIA_CUDA-8.0_Samples文件夹下执行:

1
make

进入NVIDIA_CUDA-8.0_Samples/bin/x86_64/linux/release文件夹,运行:

1
./deviceQuery 

删除CUDA的方法

当出现问题需要重装时,可输入:

1
2
3
sudo /usr/local/cuda-7.5/bin/uninstall_cuda_7.5.pl
sudo /usr/bin/nvidia-uninstall
sudo apt-get remove --purge nvidia-*

升级gcc到4.9(可选)

Ubuntu系统默认的是gcc 4.8,版本比较老,在使用时候可能会导致一些错误,所以将gcc升级到4.9版本,并且将4.9作为默认编译器。

查看当前版本:

1
gcc -v

安装gcc 4.9:

1
2
3
4
5
6
7
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.9 g++-4.9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9


sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8

显示和选择使用版本:

1
sudo update-alternatives --config gcc

安装libfreenect2(可选)

由于将来需要使用Kinect2,所以顺带将相应的驱动也装上了:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
git clone https://github.com/OpenKinect/libfreenect2.git
cd depends
sh ./download_debs_trusty.sh
sh ./install_ubuntu.sh

sudo dpkg -i libglfw3*_3.0.4-1_*.deb
sudo apt-get install build-essential cmake pkg-config libturbojpeg libjpeg-turbo8-dev mesa-common-dev freeglut3-dev libxrandr-dev libxi-dev

sudo dpkg -i debs/libusb*deb
sudo dpkg -i debs/{libva,i965}*deb; sudo apt-get install -f

sudo apt-add-repository ppa:deb-rob/ros-trusty && sudo apt-get update
sudo apt-get install libopenni2-dev

cd ..
mkdir build && cd build
cmake .. -DENABLE_CXX11=ON
make
sudo make install

sudo cp ../platform/linux/udev/90-kinect2.rules /etc/udev/rules.d/

测试:

1
./bin/Protonect

安装OpenCV 2.4.10

修改/modules/gpu/src/graphcuts.cpp的内容,将:

1
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)

修改为:

1
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) || (CUDART_VERSION >= 8000)

运行:

1
2
3
4
5
6
7
8
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D CUDA_GENERATION=Kepler -D WITH_TBB=ON -D WITH_LIBV4L=ON ..
make -j7
sudo make install

sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig

卸载OpenCV的方法

1
>sudo make uninstall

安装Pangolin(可选)

1
2
3
4
5
6
7
8
sudo apt-get install libglew-dev libboost-dev libboost-thread-dev libboost-filesystem-dev

git clone https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin
mkdir build
cd build
cmake -DCPP11_NO_BOOST=1 ..
make -j

安装ROS Indigo5

1
2
3
4
5
6
7
8
9
10
11
12
13
sudo sh -c '. /etc/lsb-release && echo "deb http://mirror.sysu.edu.cn/ros/ubuntu/ $DISTRIB_CODENAME main" > /etc/apt/sources.list.d/ros-latest.list'
sudo apt-key adv --keyserver hkp://pool.sks-keyservers.net --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116

sudo apt-get update
sudo apt-get install ros-indigo-desktop-full

sudo rosdep init
rosdep update

echo "source /opt/ros/indigo/setup.bash" >> ~/.bashrc
source ~/.bashrc

sudo apt-get install python-rosinstall

Depends错误

如果在安装时出现Depends: ros-indigo-simulators but it is not going to be installed的错误(安装gazebo2导致的错误),可以先下载老版本的libsdformat-dev,安装,然后再执行sudo apt-get install ros-indigo-desktop-full

安装iai_kinect2(可选)

This is a collection of tools and libraries for a ROS Interface to the Kinect One (Kinect v2).

1
2
3
4
5
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src
git clone https://github.com/code-iai/iai_kinect2.git
cd iai_kinect2
rosdep install -r --from-paths .

此时可能会显示有关[kinect2_bridge] and [depth_registration]的错误,不用理它。

1
2
cd ~/catkin_ws
catkin_make -DCMAKE_BUILD_TYPE="Release"

"libfreenect2.so: undefined reference to clRetainContext@OPENCL_1.0"错误

这是由于CUDA自带的/usr/local/cuda/lib64/libOpenCL.so和其他库提供的/usr/lib/x86_64-linux-gnu/libOpenCL.so冲突导致6,执行以下命令:

1
sudo apt-get remove nvidia-modprobe opencl-headers

测试

打开一个窗口:

1
roscoe

打开另外一个窗口:

1
2
3
cd ~/catkin_ws/
source ./devel/setup.sh
roslaunch kinect2_bridge kinect2_bridge.launch

再打开另外一个窗口:

1
2
3
cd ~/catkin_ws/
source ./devel/setup.bash
rosrun kinect2_viewer kinect2_viewer

安装ORB_SLAM2

1
2
3
4
5
6
sudo apt-get install libblas-dev liblapack-dev

git clone https://github.com/raulmur/ORB_SLAM2.git ORB_SLAM2
cd ORB_SLAM2
chmod +x build.sh
./build.sh

安装OpenCV 3.1

ZED SDK v1.1需要OpenCV 3.1,所以需要再安装一个。在这里下载openCV 3.1版本的源代码。

修改/modules/cudalegacy/src/graphcuts.cpp的内容7,将:

1
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)

修改为:

1
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) || (CUDART_VERSION >= 8000)

运行:

1
2
3
4
5
6
7
8
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON ..
make -j7
sudo make install

sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig

查看当前OpenCV版本号

1
pkg-config --modversion opencv  

OpenCV多版本冲突

由于系统安装了两个版本的OpenCV,在编译时有可能会发生以下错误:

1
/usr/bin/ld: warning: libopencv_highgui.so.2.4, needed by /opt/ros/indigo/lib/libcv_bridge.so, may conflict with libopencv_highgui.so.3.1

这时,可以在CMakeLists.txt文件中指定OpenCV所需版本的的build目录路径来解决冲突问题,如8

1
set(OpenCV_DIR "/home/luohanjie/Documents/Software/opencv-2.4.10/build")

安装ZED SDK

这里下载ZED SDK for Linux。

最新的v2.0版本在Ubuntu 14.04下无法使用,所以使用v1.1版本。

1
2
chmod +x ZED_SDK_Linux_x86_64_v1.1.0
./ZED_SDK_Linux_x86_64_v1.1.0.run

输入 q 退出 license agreement。

安装zed-ros-wrapper

1
2
3
4
5
6
cd ~/catkin_ws/src
git clone https://github.com/stereolabs/zed-ros-wrapper.git
git checkout v1.0.0

cd ..
catkin_make

测试

打开一个窗口,执行:

1
roscore

打开另外一个窗口,执行:

1
2
3
cd ~/catkin_ws
source ./devel/setup.bash
roslaunch zed_wrapper zed.launch

再打一个窗口:

1
rosrun rviz rviz

Then click on add (bottom left), select the By Topic tab, select point_cloud->cloud->PointCloud2 and click OK9.

运行结果:

Screenshot from 2017-05-15 10:20:10

Launch file parameters

Parameter Description Value
svo_file SVO filename path to an SVO file
resolution ZED Camera resolution '0': HD2K
_ _ '1': HD1080
_ _ '2': HD720
_ _ '3': VGA
quality Disparity Map quality '0': NONE
_ _ '1': PERFORMANCE
_ _ '2': MEDIUM
_ _ '3': QUALITY
sensing_mode Depth sensing mode '0': FILL
_ _ '1': STANDARD
openni_depth_mode Convert depth to 16bit in millimeters '0': 32bit float meters
_ _ '1': 16bit uchar millimeters
frame_rate Rate at which images are published int
rgb_topic Topic to which rgb==default==left images are published string
rgb_cam_info_topic Topic to which rgb==default==left camera info are published string
rgb_frame_id ID specified in the rgb==default==left image message header string
left_topic Topic to which left images are published string
left_cam_info_topic Topic to which left camera info are published string
left_frame_id ID specified in the left image message header string
right_topic Topic to which right images are published string
right_cam_info_topic Topic to which right camera info are published string
right_frame_id ID specified in the right image message header string
depth_topic Topic to which depth map images are published string
depth_cam_info_topic Topic to which depth camera info are published string
depth_frame_id ID specified in the depth image message header string
point_cloud_topic Topic to which point clouds are published string
cloud_frame_id ID specified in the point cloud message header string
odometry_topic Topic to which odometry is published string
odometry_frame_id ID specified in the odometry message header string
odometry_transform_frame_id Name of the transformation following the odometry string

  1. https://devtalk.nvidia.com/default/topic/978812/installing-cuda-7-5-fails-on-ubuntu-14-0-4-5-with-error-driver-installation-is-unable-to-locate-the-kernel-source/↩︎

  2. http://www.cnblogs.com/leexiaoming/p/6576274.html↩︎

  3. http://www.jianshu.com/p/35c7fde85968↩︎

  4. http://www.jianshu.com/p/35c7fde85968↩︎

  5. http://wiki.ros.org/cn/indigo/Installation/Ubuntu↩︎

  6. https://github.com/OpenKinect/libfreenect2/issues/804↩︎

  7. http://docs.opencv.org/3.1.0/d7/d9f/tutorial_linux_install.html↩︎

  8. http://www.cnblogs.com/leexiaoming/p/6576274.html↩︎

  9. https://github.com/stereolabs/zed-ros-wrapper/tree/v1.0.0↩︎

摄像头驱动安装

先安装显示工具:

1
2
sudo apt-get update
sudo apt-get install ros-indigo-image-view, v4l-utils

然后安装驱动;

1
2
3
4
5
6
7
8
sudo apt-get update
sudo apt-get install ros-indigo-image-view, v4l-utils

cd ~/catkin_ws/src
git git clone https://github.com/bosch-ros-pkg/usb_cam.git
cd ..
catkin_make
source ~/catkin-ws/devel/setup.bash

进入~/catkin-ws/usb_cam/src/usb_cam/launch/usb_cam-test.launch,以usb_cam-test.launch为参考新建usb_cam.launch,修改里面内容(主要是video_device的值):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<launch>
<node name="usb_cam" pkg="usb_cam" type="usb_cam_node" output="screen" >
<param name="video_device" value="/dev/video0" />
<param name="image_width" value="640" />
<param name="image_height" value="480" />
<param name="pixel_format" value="yuyv" />
<param name="camera_frame_id" value="usb_cam" />
<param name="io_method" value="mmap"/>
</node>
<node name="image_view" pkg="image_view" type="image_view" respawn="false" output="screen">
<remap from="image" to="/usb_cam/image_raw"/>
<param name="autosize" value="true" />
</node>
</launch>

现在一个新窗口运行roscore。 然后在另外一个新窗口:

1
2
3
cd ~/catkin_ws/
source devel/setup.sh
roslaunch usb_cam usb_cam.launch

安装ORB-SLAM2

1
2
3
4
5
6
7
sudo apt-get install libblas-dev
sudo apt-get install liblapack-dev

git clone https://github.com/raulmur/ORB_SLAM2.git
cd ORB_SLAM2
chmod +x build.sh
./build.sh
1
2
3
cd ~
sudo gedit .bashrc
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/ORB_SLAM2/Examples/ROS

其中PATH/ORB_SLAM2/Examples/ROS为你的实际位置(如/home/luohanjie/SLAM/Code/slam_catkin_ws/src/ORB_SLAM2/Examples/ROS)。

ORB_SLAM2/Examples/ROS/ORB_SLAM2/src/ros_mono.cc中某代码修改为:

1
ros::Subscriber sub = nodeHandler.subscribe("/usb_cam/image_raw", 1, &ImageGrabber::GrabImage,&igb);
1
2
3
4
5
cd PATH/ORB_SLAM2/Examples/ROS/ORB_SLAM2
mkdir build
cd build
cmake .. -DROS_BUILD_TYPE=Release
make -j

运行

打开一个窗口运行roscore 然后在另外一个新窗口:

1
2
3
cd ~/catkin_ws/
source devel/setup.sh
roslaunch usb_cam usb_cam.launch

然后在另外一个新窗口:

1
2
3
cd ~/catkin_ws/
source devel/setup.sh
rosrun ORB_SLAM2 Mono PATH_TO_VOCABULARY PATH_TO_SETTINGS_FILE

PATH_TO_VOCABULARY是词典的位置,PATH_TO_SETTINGS_FILE是摄像头标定的yaml文件。

如:

1
rosrun ORB_SLAM2 Mono /home/luohanjie/SLAM/Code/slam_catkin_ws/src/ORB_SLAM2/Vocabulary/ORBvoc.txt /home/luohanjie/SLAM/Code/slam_catkin_ws/src/usb_cam/calib/camera_slam.yml
1
rosrun ORB_SLAM2 Mono /home/luohanjie/SLAM/Code/catkin_ws_orbslam_loadmap/src/ORB_SLAM2/Vocabulary/ORBvoc.txt /home/luohanjie/SLAM/Code/catkin_ws_orbslam_loadmap/src/usb_cam/calib/camera_slam.yml
0%