本配置教程安装环境及需求如下:
Ubuntu 14.04.4 LTS (14.04.5也可以)
kernel 4.4.0-040400-generic
ros-indigo-desktop
gcc 4.9.3(貌似4.8.5也可以使用,第一步升级GCC4.9.3可以跳过)
realsense_camera
librealsense
一般情况下,安装完Ubuntu14.04.5及ros-indigo-desktop(完全安装)后,kernel4.4.0-040400-generic 就已经配置上了。
而在terminal输入'gcc-v',查看到当前gcc版本为4.8.4,需要升级为4.9.3
1.升级GCC4.9.3(这个步骤可以跳过,其实可以不升级)
在Terminal中输入下面的命令,在加上几分钟的等待,即可完成安装:
$
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
$
sudo apt-get update
$
sudo apt-get install gcc-4.9 g++-4.9
安装完成后,你会发现如果直接使用gcc/g++命令,默认采用的版本仍然是原来的4.8.4版本。你如果要使用新版的gcc/g++,必须采用命令gcc-4.9/g++-4.9。下面讲解如何将版本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
就可将gcc/g++的默认版本设为4.9.4。update-alternatives是一个管理工具,能够管理同一个软件的不同版本。上命令中,参数slave保证gcc和g++版本的联动调整。而60是表示的优先级,你可以选用任何你喜欢的大于0的整数。那么,此时你再利用gcc命令查看当前的版本,就会发现已经是新版本了,如下图:
但是,接下来的一个问题是,如果你还想继续使用原来的版本,怎么办?况且原来版本并没有删除。同样还是利用update-alternatives,及如下的命令:
sudo
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50
--slave /usr/bin/g++ g++ /usr/bin/g++-4.8
上面的优先级设为50,所有当前默认为4.9.2版本。你可以使用命令
sudo
update-alternatives --query gcc
来查看被update-alternatives管理的gcc不同版本,这同样可以针对g++。
既然gcc/g++的不同版本已被update-alternatives管理,那么如何在这两个不同的gcc/g++版本间进行切换使用呢?
采用如下图所示的命令,接着再输入对应的序号,就可以在不同的版本间进行切换:
2.安装realsense_camera
参考地址:
http://wiki.ros.org/realsense_camera
http://wiki.ros.org/librealsense#Installation_Prerequisites
先安装
librealsense
Useone of the following methods to enable the downloading of kernelsources on the system. This only needs to be done once per system orif the OS is re-installed or upgrade to a new major release.
(一般采用第一种方式就可以)
Method 1 (Script)(采用该方案即可)
wget -O enable_kernel_sources.sh http://bit.ly/en_krnl_src bash ./enable_kernel_sources.sh'
or
Updateyour /etc/apt/sources.listfile and/or /etc/apt/sources.list.d/*.listto uncomment (or add) the deb-srcentries for all of the entries for the mainrepositories. Below is an examplefor ubuntu 16.04 (Xenial).
deb-src http://us.archive.ubuntu.com/ubuntu/ xenial main restricted deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse deb-src http://security.ubuntu.com/ubuntu xenial-security main restricted
After the manual edits arecomplete, run the update commands to ensure the entries are correctand update the package database.
sudo apt-get update
If the package has failed toinstall because the kernel sources were not available, the packagewill need to be re-installed after the update.
sudo apt-get --reinstall install 'ros-indigo-librealsense'
如果安装过程出现问题,则参考如下方案:
roslaunch realsense_camera [cam_type]_nodelet_[mode].launch
[ERROR]: /camera/driver - No cameras detected! [ERROR]: /camera/driver - Error calling rs_create_context ( api_version:11100 ): uvcvideo kernel module is not loaded ...
sudo modprobe uvcvideo
modprobe: ERROR: could not insert 'uvcvideo': Required key not available
Solution: (需要关掉Secure Boot,参考以下链接https://wiki.ubuntu.com/UEFI/SecureBoot/DKMS)
DKMS does not work with Secure Boot. You need to disable it(https://wiki.ubuntu.com/UEFI/SecureBoot/DKMS).DKMSFails to Build:
make KERNELRELEASE=4.4.0-43-generic -C /var/lib/dkms/uvcvideo/1.1.1-3-realsense/build/linux-src M=drivers/media/usb/uvc/....(bad exit status: 2) Error! Bad return status for module build on kernel: 4.4.0-43-generic (x86_64)
Solution:
Removethe failed DKMS installation
dkms remove -m uvcvideo -v "1.1.1-3-realsense" --all
再安装
realsense_
camera
Most users should only need toinstall the prebuilt ROS Debian packages.
sudo apt-get install 'ros-indigo-realsense-camera'
This will also install the requiredros-*-librealsense library on your system.
Description: Instructions for building bothlibrealsense AND realsense_camera package from source files in thesame workspace.
Keywords: realsense,librealsense, build, source, sources
# Create the catkin workspace
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src #Download the source files
git
clone https://github.com/intel-ros/realsense.git
git clone https://github.com/IntelRealSense/librealsense.git
#Checkout the latest stable code
cd ~/catkin_ws/src/realsense
git checkout -b stable-branch stable
cd ~/catkin_ws/src/librealsense
git checkout -b stable-branch stable
# Update the dependencies database
rosdep update
#Attempt to install dependencies
#Requires that your login has sudo privileges to instal as root using
apt-get
cd ~/catkin_ws
rosdep -y install --from-paths src --ignore-src
cd ~/catkin_ws
catkin_make --pkg librealsense
cd ~/catkin_ws
#Remove any existing realsense_camera binaries
catkin_make
clean --pkg realsense_camera
#Build the package
catkin_make --pkg realsense_camera
source ~/catkin_ws/devel/setup.bash
roslaunch realsense_camera r200_nodelet_default.launch(这句如果有问题,可能需要Linux安装摄像头的驱动,按照下一步安装摄像头驱动)
2.安装realsense_camera驱动
roslaunch realsense_camera r200_nodelet_default.launch(这句会有问题,因为目前Linux还未安装摄像头的驱动,下一步我们需要安装摄像头驱动)
Ensure apt-get is up to date
sudoapt-get update && sudo apt-get upgrade
Note: Use sudoapt-get dist-upgrade
, instead of sudoapt-get upgrade
, in case you have an older Ubuntu 14.04version (with deprecated nvidia-331*
packages installed), as this prevents the linux 4.4* kernel tocompile properly.
这一步运行的时候可能会出现security模式的问题,可以退出安全模式,看到一个窗口时先按esc,再确定,设置8位密码,然后确定即可。
Install libusb-1.0 and pkg-configvia apt-get
sudoapt-get install libusb-1.0-0-dev pkg-config
glfw3 is not available in apt-geton Ubuntu 14.04. Use included installer script:
scripts/install_glfw3.sh
(该文件在下载的librealsensepackage下面,我们需要先cd到librealsense目录下,执行该命令)
For 16.04 you can install glfw3via sudo apt-get install libglfw3-dev
We use QtCreator as an IDE forLinux development on Ubuntu
Note: QtCreatoris presently configured to use the V4L2 backend by default
sudoapt-get install qtcreator
sudoscripts/install_qt.sh
(we also need qmake from thefull qt5 distribution)
all.pro
contains librealsense and all example applications
From the QtCreator top menu:Clean => Run QMake => Build
Built QtCreator projects will beplaced into ./bin/debug
or./bin/release
We also provide a cmake file ifyou'd prefer to use your own favourite text editor
mkdirbuild
cdbuild
cmake..
make&& sudo make install
The library will be installed in/usr/local/lib
and header file in /usr/local/include
Note: If youwould also like to compile the code examples use:
cmake.. -DBUILD_EXAMPLES:BOOL=true
make&& sudo make install
The example executables will build into ./examples
and install into /usr/local/bin
.
此时,摄像头即可运行~