ubuntu 16.04 ROS + kinect v2 driver安装方法;安装驱动时遇到的问题及解决方法

安装方法参考:http://blog.csdn.net/sunbibei/article/details/51594824

安装ROS (Kinetic)

ROS Kinetic ONLY supports Wily (Ubuntu 15.10), Xenial (Ubuntu 16.04) and Jessie (Debian 8) for debian packages.

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://ha.pool.sks-keyservers.net:80 --recv-key 421C365BD9FF1F717815A3895523BAEEB01FA116
sudo apt-get update
sudo apt-get install ros-kinetic-desktop-full
sudo rosdep init
rosdep update
echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
source ~/.bashrc
sudo apt-get install python-rosinstall python-rosinstall-generator python-wstool build-essential
####################关于"hardware_interface"
#####关于controller_manager
sudo apt-get install ros-kinetic-effort-controllers
sudo apt-get install ros-kinetic-joint-state-controller
sudo apt-get install ros-kinetic-ros-control ros-kinetic-ros-controllers

###################与Python兼容问题
conda install setuptools  
pip install -U rosdep rosinstall_generator wstool rosinstall six vcstools  

##########install moveit
sudo apt-get install ros-kinetic-moveit
source /opt/ros/kinetic/setup/bash

##################No module named em 的问题
pip install empy

###################defusedxml.xmlrpc
conda install -c conda-forge defusedxml
mkdir -p ~/catkin_ws/src  
cd ~/catkin_ws/src  
catkin_init_workspace  
cd ..  
catkin_make  

 

打开新的终端,运行ROS核心  roscore
打开新的终端,运行小海龟界面
rosrun turtlesim turtlesim_node
打开新的终端,运行键盘控制程序
rosrun turtle_teleop turtle_teleop_key
如果提示找不到key,可以试下以下两句
roscd turtle_teleop
roslaunch launch/turtle_keyboard.launch

安装libfreenect2

安装该部分时,已经安装好CUDA和k40c GPU驱动

git clone https://github.com/OpenKinect/libfreenect2.git
cd libfreenect2
sudo apt-get install build-essential cmake pkg-config
sudo apt-get install libusb-1.0-0-dev
sudo apt-get install libturbojpeg libjpeg-turbo8-dev
sudo apt-get install libglfw3-dev
sudo apt-get install libopenni2-dev
cd ..
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/freenect2
make
make install

针对上面cmake命令的说明, 第一个参数, 是特别指定安装的位置, 你也可以指定别的你觉得高兴的地方, 但一般标准的路径是上述示例路径或者/usr/local。 第二个参数是增加C++11的支持。

设定udev rules:

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

然后重新插拔Kinect2.

一切搞定, 现在可以尝试运行Demo程序: ./bin/Protonect, 不出意外, 应该能够看到如下效果:

DEMO

安装iai-kinect2

利用命令行从Github上面下载工程源码到工作空间内src文件夹内:

cd ~/catkin_ws/src/
git clone https://github.com/code-iai/iai_kinect2.git
cd iai_kinect2
rosdep install -r --from-paths .
cd ~/catkin_ws
catkin_make -DCMAKE_BUILD_TYPE="Release"

针对于上述命令中最后一行指令, 需要说明的是, 如果前面libfreenect2你安装的位置不是标准的两个路径下, 需要提供参数指定libfreenect2所在路径:

catkin_make -Dfreenect2_DIR=path_to_freenect2/lib/cmake/freenect2 -DCMAKE_BUILD_TYPE="Release"

编译结束, 一切OK的话, 会看到如下提示:

这里写图片描述

最后就是激动人心的时刻了, 在ROS中获取Kinect2的数据。
PS: 很多同学在运行下属命令时,时常会遇到不能执行的问题,大部分情况是没有source对应的目录。应该先执行

gedit ~/.bashrc
source ~/catkin_ws/devel/setup.bash

若对应已经写入~/.bashrc文件的同学,可以忽略。

roslaunch kinect2_bridge kinect2_bridge.launch

这里写图片描述

使用roslaunch发起kinect2相关节点, 可以看到如下结果, 在另外一个命令行中, 输入rostopic list, 可以查看到该节点发布出来的Topic,

还可以输入

rosrun kinect2_viewer kinect2_viewer sd cloud

来开启一个Viewer查看数据。 结果如下图所示:

这里写图片描述

安装过程中遇到的问题:

问题1.

运行 roslaunch kinect2_bridge kinect2_bridge.launch 时一直出现:

[kinect2_bridge.launch] is neither a launch file in package [kinect2_bridge] nor is [kinect2_bridge] a launch file name
The traceback for the exception was written to the log file
或者运行: rosrun kinect2_viewer kinect2_viewer sd cloud 时找不到 kinect2_viewer
这是配置环境变量时导致的,需要在 ~/.bashrc 中添加路径:
gedit ~/.bashrc
然后在打开的文件最后行添加: source /home/wgb/catkin_ws/devel/setup.bash
添加后的部分文件内容:


 

 

[python] view plain copy

print?

  1. <code class="language-python"># enable programmable completion features (you don't need to enable  
  2. # this, if it's already enabled in /etc/bash.bashrc and /etc/profile  
  3. # sources /etc/bash.bashrc).  
  4. if ! shopt -oq posix; then  
  5.   if [ -f /usr/share/bash-completion/bash_completion ]; then  
  6.     . /usr/share/bash-completion/bash_completion  
  7.   elif [ -f /etc/bash_completion ]; then  
  8.     . /etc/bash_completion  
  9.   fi  
  10. fi  
  11.   
  12. # added by Anaconda3 4.4.0 installer  
  13. export PATH="/home/wgb/anaconda3/bin:$PATH"  
  14. source /opt/ros/kinetic/setup.bash  
  15. source /home/wgb/catkin_ws/devel/setup.bash  
  16. source /opt/ros/kinetic/setup.bash  
  17. source /opt/ros/kinetic/setup.bash  
  18. source /opt/ros/kinetic/setup.bash  
  19. source /opt/ros/kinetic/setup.bash  
  20. source /opt/ros/kinetic/setup.bash  
  21. source /home/wgb/catkin_ws/devel/setup.bash</code>  
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi

# added by Anaconda3 4.4.0 installer
export PATH="/home/wgb/anaconda3/bin:$PATH"
source /opt/ros/kinetic/setup.bash
source /home/wgb/catkin_ws/devel/setup.bash
source /opt/ros/kinetic/setup.bash
source /opt/ros/kinetic/setup.bash
source /opt/ros/kinetic/setup.bash
source /opt/ros/kinetic/setup.bash
source /opt/ros/kinetic/setup.bash
source /home/wgb/catkin_ws/devel/setup.bash

问题2.

 
 

--------------------- 本文来自 wuguangbin1230 的CSDN 博客 ,全文地址请点击:https://blog.csdn.net/wuguangbin1230/article/details/77184032?utm_source=copy

猜你喜欢

转载自blog.csdn.net/weixin_39752599/article/details/82869749