UBUNTU18.04下使用ros1编译kinect2踩坑
撤销:Ctrl/Command + Z
重做:Ctrl/Command + Y
加粗:Ctrl/Command + B
斜体:Ctrl/Command + I
标题:Ctrl/Command + Shift + H
无序列表:Ctrl/Command + Shift + U
有序列表:Ctrl/Command + Shift + O
检查列表:Ctrl/Command + Shift + C
插入代码:Ctrl/Command + Shift + K
插入链接:Ctrl/Command + Shift + L
插入图片:Ctrl/Command + Shift + G
查找:Ctrl/Command + F
替换:Ctrl/Command + G
下面展示一些 内联代码片
。
// An highlighted block
git clone https://github.com/OpenKinect/libfreenect2.git
cd libfreenect2
mkdir build
cd build
cmake ..
make
sudo make install
如果缺少依赖请先装上想应的依赖
sudo apt-get install build-essential cmake pkg-config libturbojpeg libjpeg-turbo8-dev mesa-common-dev freeglut3-dev libxrandr-dev libxi-dev
sudo apt-get install libglfw3-dev
sudo apt-get install libopenni2-dev
sudo apt-get install libusb-1.0-0-dev
设定udev rules
sudo cp libfreenect2/platform/linux/udev/90-kinect2.rules /etc/udev/rules.d/
重新插拔Kinect2.在build目录下运行
./bin/Protonect pl //测试OpenGL是否正常
./bin/Protonect cpu //测试CPU是否正常
需要在ros的工作空间下编译
// An highlighted block
cd ~/catkin_pcl/src/
git clone https://github.com/code-iai/iai_kinect2.git
cd iai_kinect2
rosdep install -r --from-paths .
如果出现报错
ERROR: the following packages/stacks could not have their rosdep keys resolved
to system dependencies:
kinect2_viewer: Cannot locate rosdep definition for [kinect2_bridge]
kinect2_calibration: Cannot locate rosdep definition for [kinect2_bridge]
kinect2_bridge: Cannot locate rosdep definition for [kinect2_registration]
Continuing to install resolvable dependencies...
All required rosdeps installed successfully
运行
rosdep install --from-paths ~/catkin_pcl/src/iai_kinect2 --ignore-src -r
编译
cd ~/catkin_pcl
catkin_make -DCMAKE_BUILD_TYPE="Release"
如果出现CV-AA等类似opencv版本不匹配的问题
更改iai-kinect2功能包下,kinect2_bridge,kinect2_calibration,kinect2_viewer,kinect2_registration下的cmakelist文件把find_package(OpenCV REQUIRED)更改为find_package(OpenCV 3 REQUIRED)
编译成功后source一下
echo "source ~/catkin_pcl/devel/setup.sh" >> ~/.bashrc
roslaunch kinect2_bridge kinect2_bridge.launch
如果出现不能链接kinect的情况或者kinect not working的情况
检查是否下载了opencl
若是没有下载opencl可以更改kinect2_bridge.launch文件,使用roslaunch启动:
<launch>
<arg name="base_name" default="kinect2"/>
<arg name="sensor" default=""/>
<arg name="publish_tf" default="false"/>
<arg name="base_name_tf" default="$(arg base_name)"/>
<arg name="fps_limit" default="-1.0"/>
<arg name="calib_path" default="$(find kinect2_bridge)/data/"/>
<arg name="use_png" default="false"/>
<arg name="jpeg_quality" default="90"/>
<arg name="png_level" default="1"/>
<arg name="depth_method" default="opengl"/>
<arg name="depth_device" default="-1"/>
<arg name="reg_method" default="cpu"/>
<arg name="reg_device" default="-1"/>
若出现
Failed to load nodelet [/kinect2_points_xyzrgb_XX] of type [depth_image_proc/point_cloud_xyzrgb]
切到src目录,运行
git clone --branch kinetic https://github.com/ros-perception/image_pipeline.git
catkin_make --pkg image_pipeline
roslaunch kinect2_bridge kinect2_bridge.launch
rosrun kinect2_viewer kinect2_viewer