1. ROS Kinect V2相机编程
Kinect V2连接电脑后,执行命令:
relaybot@ubuntu:~$ cd catkin_ws/
relaybot@ubuntu:~/catkin_ws$ roslaunch kinect2_bridge kinect2_bridge.launch
#... logging to /home/relaybot/.ros/log/9d46ee9c-2333-11e8-932e-68f728588803/roslaunch-ubuntu-4043.log
#Checking log directory for disk usage. This may take awhile.
#Press Ctrl-C to interrupt
#Done checking log file disk usage. Usage is <1GB.
#started roslaunch server
- 编程
launch文件
寻找到launch
文件位置roscd kinect2_bridge
:
~/catkin_ws/src/iai_kinect2/kinect2_bridge$
补充libfreenect2
编程问题
issue 链接
问题描述:
编译libfreenect2
的example
遇到问题:
relaybot@ubuntu:~/mumu/KinectV2/libfreenect2/build$ cd ..
relaybot@ubuntu:~/mumu/KinectV2/libfreenect2$ cd examples/
relaybot@ubuntu:~/mumu/KinectV2/libfreenect2/examples$ mkdir build
relaybot@ubuntu:~/mumu/KinectV2/libfreenect2/examples$ cd build/
relaybot@ubuntu:~/mumu/KinectV2/libfreenect2/examples/build$ cmake ..
CMake Error at CMakeLists.txt:34 (FIND_PACKAGE):
By not providing "Findfreenect2.cmake" in CMAKE_MODULE_PATH this project
has asked CMake to find a package configuration file provided by
"freenect2", but CMake did not find one.
Could not find a package configuration file provided by "freenect2" with
any of the following names:
freenect2Config.cmake
freenect2-config.cmake
Add the installation prefix of "freenect2" to CMAKE_PREFIX_PATH or set
"freenect2_DIR" to a directory containing one of the above files. If
"freenect2" provides a separate development package or SDK, be sure it has
been installed.
-- Configuring incomplete, errors occurred!
这里主要是搜索路径不对
解决方案
If you can rebuild the library requiring ocl-icd (e.g. libfreenect2), built it with
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/freenect2
to override the search path in cuda-8-0.conf.
编译成功:
~/libfreenect2/examples/build$ cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/freenect2
-- checking for module 'glfw3'
-- found glfw3, version 3.1.2
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/libX11.so;/usr/lib/x86_64-linux-gnu/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Found X11: /usr/lib/x86_64-linux-gnu/libX11.so
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/libGL.so
-- Configuring done
-- Generating done
-- Build files have been written to: /home/relaybot/mumu/KinectV2/libfreenect2/examples/build
make
遇到失败
#~/libfreenect2/examples/build$ make
Scanning dependencies of target Protonect
[ 33%] Building CXX object CMakeFiles/Protonect.dir/Protonect.cpp.o
[ 66%] Building CXX object CMakeFiles/Protonect.dir/viewer.cpp.o
[100%] Building CXX object CMakeFiles/Protonect.dir/home/relaybot/mumu/KinectV2/libfreenect2/src/flextGL.cpp.o
#Linking CXX executable Protonect
#/home/relaybot/freenect2/lib/libfreenect2.so: undefined reference to `clRetainContext@OPENCL_1.0'
#/home/relaybot/freenect2/lib/libfreenect2.so: undefined reference to `clGetDeviceIDs@OPENCL_1.0'
#/home/relaybot/freenect2/lib/libfreenect2.so: undefined reference to `clReleaseCommandQueue@OPENCL_1.0'
#/home/relaybot/freenect2/lib/libfreenect2.so: undefined reference to `clRetainDevice@OPENCL_1.2'
#/home/relaybot/freenect2/lib/libfreenect2.so: undefined reference to `clGetExtensionFunctionAddress@OPENCL_1.0'
#/home/relaybot/freenect2/lib/libfreenect2.so: undefined reference to `clBuildProgram@OPENCL_1.0'
#/home/relaybot/freenect2/lib/libfreenect2.so: undefined reference to `clCreateKernel@OPENCL_1.0'
解决方案:
If you have a prebuilt library linked with ocl-icd (e.g. libfreenect2)
and you can't rebuild it, use
LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu make
to build your own program to override the search path in cuda-8-0.conf.
#有一个与ocl-icd(例如libfreenect2)链接的预建库,并且你不能重建它,请使用
LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu make
#构建你自己的程序来覆盖cuda- 8-0.conf
//~/libfreenect2/examples/build$ LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu make
Linking CXX executable Protonect
/*make 链接成功*/
[100%] Built target Protonect
//relaybot@ubuntu:~/mumu/KinectV2/libfreenect2/examples/build$ ./Protonect
编写自己的程序也是如此:
relaybot@ubuntu:~/mumu/KinectV2/code1$ mkdir build
relaybot@ubuntu:~/mumu/KinectV2/code1$ cd build/
relaybot@ubuntu:~/mumu/KinectV2/code1/build$ cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/freenect2
-- Configuring done
-- Generating done
-- Build files have been written to: /home/relaybot/mumu/KinectV2/code1/build
relaybot@ubuntu:~/mumu/KinectV2/code1/build$ LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu make
//Scanning dependencies of target main
//[100%] Building CXX object CMakeFiles/main.dir/main.cpp.o
//Linking CXX executable main
//[100%] Built target main
relaybot@ubuntu:~/mumu/KinectV2/code1/build$ ./main
//以下省略.......
ORB-SALM2 的 ROS 编译
遇到错误
[rosbuild] Error from directory check: /opt/ros/indigo/share/ros/core/rosbuild/bin/check_same_directories.py/home/wf/LearnVIORB-master/Examples/ROS/ORB_VIO
1
Traceback (most recent call last):
File "/opt/ros/indigo/share/ros/core/rosbuild/bin/check_same_directories.py", line 46, in
raise Exception
Exception
CMake Error at /opt/ros/indigo/share/ros/core/rosbuild/private.cmake:102 (message):
[rosbuild] rospack found package "ORB_VIO" at "", but the current
directory is "/home/wf/LearnVIORB-master/Examples/ROS/ORB_VIO". You should
double-check your ROS_PACKAGE_PATH to ensure that packages are found in the
correct precedence order.
Call Stack (most recent call first):
/opt/ros/indigo/share/ros/core/rosbuild/public.cmake:177 (_rosbuild_check_package_location)
CMakeLists.txt:4 (rosbuild_init)
-- Configuring incomplete, errors occurred!
export ROS_PACKAGE_PATH=${ROS_PACKAGE_PATH}:PATH/ORB_SLAM2/Examples/ROS
添加以上信息到~/.basnrc
并且重启
记住一定要重启才能生效
执行 ./build_ros.sh
遇到
usleep
错误