安装方法参考:http://blog.csdn.net/sunbibei/article/details/51594824
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
安装该部分时,已经安装好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
, 不出意外, 应该能够看到如下效果:
利用命令行从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查看数据。 结果如下图所示:
rosrun kinect2_viewer kinect2_viewer sd cloud 时找不到 kinect2_viewer
# 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.