本文主要是介绍Ubuntu 18.04 安装iai_kinect2遇到的问题,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
运行环境为:Ubuntu 18.04 Ros melodic
一、所需环境
libfreenect2,下载安装教程https://github.com/OpenKinect/libfreenect2
对于git clone因为网络问题用不了的同学,建议windows下载了以后把u盘拷进ubuntu系统。
二、安装libfreenect2
1. 下载u盘文件https://github.com/OpenKinect/libfreenect2
https://github.com/code-iai/iai_kinect2
2. 拷进/home/用户名/工作空间/src文件夹
3.解压libfreenect2的压缩包,并把文件夹改名为libfreenect2
4.cd /home/用户名/工作空间/src/libfreenect2
5.安装build tools(已经有了就跳过)sudo apt-get install build-essential cmake pkg-config
6.安装libusb(同理) sudo apt-get install libusb-1.0-0-dev
7.安装turboJPEG sudo apt-get install libturbojpeg0-dev
8.安装OpenGL sudo apt-get install libglfw3-dev
至此,必要的依赖安装完毕,可以继续安装步骤
9.cd ..
保证自己在libfreenect2的根目录底下
10. mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/home/用户名/freenect2 (你打算把freenect2文件夹放的地址)
make
sudo make install
安装完毕,测试:
cd ~/工作空间/src/libfreenect2/build/bin
./Protonect
看看有没有出现四张图片
三、运行./Protonect报错
failed to compile vertex shader!
0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.40, 1.00 ES, and 3.00 ES
failed to compile fragment shader!
0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.40, 1.00 ES, and 3.00 ES
failed to link shader program!
error: linking with uncompiled/unspecialized shadererror: linking with uncompiled/unspecialized shader
failed to compile vertex shader!
0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.40, 1.00 ES, and 3.00 ES
failed to compile fragment shader!
0:1(10): error: GLSL 3.30 is not supported. Supported versions are: 1.10, 1.20, 1.30, 1.40, 1.00 ES, and 3.00 ES
failed to link shader program!
error: linking with uncompiled/unspecialized shadererror: linking with uncompiled/unspecialized shader
解决办法:由于这个软件最近的更新是在好多年前了,所以当时支持的OpenGl版本没有这么新。但是其实3.3版本运行是没有问题的,因此,在运行./Protonect之前,先终端运行
export MESA_GL_VERSION_OVERRIDE=3.3
即可。
为了避免每次启动都需要运行一遍代码,进行如下操作:
1. 文件目录打开主目录
2. ctrl+H显示隐藏文件
3. 双击.bashrc
4.文件最后添加export MESA_GL_VERSION_OVERRIDE=3.3
四、不建议安装依赖Opencl
官方安装教程里写:install Opencl(optional)
但是如果不install CUDA(optional)的话基本会报错
想要安装CUDA必须要安装NVIDIA显卡驱动。但是在Ubuntu系统中安装显卡驱动非常容易把系统搞崩掉,然后就开不了机,非常麻烦。建议不需要用ubuntu跑pytorch等机器学习算法的同学就别折腾了。真的想安装的话请仔细按照官方教程对应版本安装正确,然后做好系统崩溃的准备
五、安装iai_kinect2
官方安装教程https://github.com/code-iai/iai_kinect2
1. 解压iai_kinect2文件到/home/用户名/工作空间/src,并更改名称为iai_kinect2
2. cd ~/工作空间/src/iai_kinect2
rosdep install -r --from-paths .
报错说Cannot locate rosdep definition for [kinect2_bridge]...是没关系的,只要保证基础的rosdep update能正常运行就可以
cd ~/工作空间
catkin_make -Dfreenect2_DIR=path_to_freenect2/home/用户名/freenect2 -DCMAKE_BUILD_TYPE=''Release''
path_to_freenect2后面填你安装libfreenect2的时候cmake的地址
3. 由于本文没有安装opencl所以需要修改launch文件,不然会报错,因为默认会使用opencl。
如果报错如下,则都是这个问题
[Error] [DepthPacketStreamParser] Packet buffer is NULL
[Error] [DepthPacketStreamParser] Packet buffer is NULL
[Error] [DepthPacketStreamParser] Packet buffer is NULL
[Error] [DepthPacketStreamParser] Packet buffer is NULL
[Error] [DepthPacketStreamParser] Packet buffer is NULL
[Error] [DepthPacketStreamParser] Packet buffer is NULL
[Error] [DepthPacketStreamParser] Packet buffer is NULL
[Info] [Freenect2DeviceImpl] canceling depth transfers...
[Info] [Freenect2DeviceImpl] stopped
[Info] [OpenCLDepthPacketProcessorImpl] building OpenCL program...
[Error] [OpenCLDepthPacketProcessorImpl] program = cl::Program(context, source, &err): -34
[ WARN] [1669112719.835973091]: [Kinect2Bridge::initCalibration] using sensor defaults for color intrinsic parameters.
[ WARN] [1669112719.836011857]: [Kinect2Bridge::initCalibration] using sensor defaults for ir intrinsic parameters.
[ WARN] [1669112719.836024210]: [Kinect2Bridge::initCalibration] using defaults for rotation and translation.
[ WARN] [1669112719.836036329]: [Kinect2Bridge::initCalibration] using defaults for depth shift.
[ INFO] [1669112719.927726400]: [DepthRegistration::New] Using OpenCL registration method!
[ INFO] [1669112719.927769985]: [DepthRegistration::New] Using OpenCL registration method!
[ERROR] [1669112719.943127018]: [DepthRegistrationOpenCL::init] [depth_registration_opencl.cpp](180) cl::Platform::get(&platforms) failed: -1001
[Info] [Freenect2DeviceImpl] closing...
[Info] [Freenect2DeviceImpl] releasing usb interfaces...
[Info] [Freenect2DeviceImpl] deallocating usb transfer pools...
[Info] [Freenect2DeviceImpl] closing usb device...
[Info] [Freenect2DeviceImpl] closed
[ERROR] [1669112719.943487276]: [Kinect2Bridge::start] Initialization failed!
[Info] [Freenect2DeviceImpl] closing...
[Info] [Freenect2DeviceImpl] already closed, doing nothing
[Error] [OpenCLAllocator] queue.enqueueUnmapMemObject(b->buffer, b->data, NULL, &event): -36
[Error] [OpenCLAllocator] queue.enqueueUnmapMemObject(b->buffer, b->data, NULL, &event): -36
[Error] [OpenCLAllocator] queue.enqueueUnmapMemObject(b->buffer, b->data, NULL, &event): -36
[FATAL] [1669112720.045885313]: Failed to load nodelet '/kinect2_bridge` of type `kinect2_bridge/kinect2_bridge_nodelet` to manager `kinect2'
[kinect2_bridge-2] process has died [pid 14981, exit code 255, cmd /opt/ros/melodic/lib/nodelet/nodelet load kinect2_bridge/kinect2_bridge_nodelet kinect2 __name:=kinect2_bridge __log:=/home/wyf/.ros/log/953c25e6-6a41-11ed-876a-0c9d925c2b6a/kinect2_bridge-2.log].
log file: /home/wyf/.ros/log/953c25e6-6a41-11ed-876a-0c9d925c2b6a/kinect2_bridge-2*.log
4. 首先确认./Protonect gl
和./Protonect cpu命令全都能正常显示四张图片
如果有哪个不能显示,请检查libfreenect2的安装问题
5. 打开~/工作空间/src/iai_kinect2/kinect2_bridge/launch/kinect2_bridge.launch文件,把depth_method那一行改为''opengl'';把reg_method那一行改为''cpu''
6. 运行roscore
开新终端,运行roslaunch kinect2_bridge kinect2_bridge.launch
正常来说应该显示waitting for client to connect并且没有报错
新终端运行rosrun kinect2_viewer kinect2_viewer
因为没有标定,所以点云是错位的。正常显示点云即说明安装成功
这篇关于Ubuntu 18.04 安装iai_kinect2遇到的问题的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!