Ubuntu18.04 Azure Kinect ROS Driver配置
1.创建工作空间
mkdir -p ~/KinectDK_ws/src
cd ~/KinectDK_ws/src
catkin_init_workspace
cd ..
catkin_make
echo "source ~/KinectDK_ws/devel/setup.bash" >> ~/.bashrc
2.下载ROS驱动
cd ~/KinectDK_ws/src
git clone https://github.com/microsoft/Azure_Kinect_ROS_Driver.git
3.收集库文件
下载连接:
https://packages.microsoft.com/ubuntu/18.04/prod/pool/main/libk/
3.1 下载libk4a1.3/里的deb文件和k4a1.3-deb/里的deb文件
3.2 解压文件
3.3 创建文件夹:
cd ~/KinectDK_ws/src
mkdir -p ext/sdk
3.4 整理文件
在sdk文件夹下分别创建3个文件夹:
-
bin文件夹: 把编译SDK时build文件夹里面的那个bin文件夹拷贝过来
-
include文件夹:SDK源码里的include文件夹和从deb文件里提取出的include文件夹合并,拷贝过来
-
lib文件夹:从deb文件里提取出的两个lib文件夹合并,拷贝过来
最终结构如下:
.
└── sdk
├── bin
│ ├── allocator_ut
│ ├── azure_c_shared_test
│ ├── AzureKinectFirmwareTool
│ ├── calibration_info
│ ├── calibration_ut
│ ├── capturesync_ut
│ ├── color_ft
│ ├── color_ut
│ ├── cpp_projection_ft
│ ├── custom_track_ut
│ ├── depth_ft
│ ├── depthmcu_ut
│ ├── depth_ut
│ ├── deversion
│ ├── dynlib_ut
│ ├── enumerate_devices
│ ├── executables_ft
│ ├── executables_ft_custom
│ ├── fastcapture_streaming
│ ├── fastcapture_trigger
│ ├── fastpointcloud
│ ├── functional_custom_test_list.txt
│ ├── functional_test_list.txt
│ ├── global_ft
│ ├── green_screen
│ ├── handle_ut
│ ├── imu_ft
│ ├── imu_ut
│ ├── k4a_cpp_ft
│ ├── k4a_example_test
│ ├── k4arecord_custom_track
│ ├── k4arecorder
│ ├── k4aviewer
│ ├── latency_perf
│ ├── libk4arecord.so -> libk4arecord.so.1.4
│ ├── libk4arecord.so.1.4 -> libk4arecord.so.1.4.0
│ ├── libk4arecord.so.1.4.0
│ ├── libk4a.so -> libk4a.so.1.4
│ ├── libk4a.so.1.4 -> libk4a.so.1.4.0
│ ├── libk4a.so.1.4.0
│ ├── libtest_dynlib.so -> libtest_dynlib.so.1
│ ├── libtest_dynlib.so.1 -> libtest_dynlib.so.1.0
│ ├── libtest_dynlib.so.1.0
│ ├── logging_ut
│ ├── multidevice_ft
│ ├── opencv_example
│ ├── perf_test_list.txt
│ ├── playback_external_sync
│ ├── playback_perf
│ ├── playback_ut
│ ├── queue_ut
│ ├── record_ut
│ ├── rwlock_ft
│ ├── streaming_samples
│ ├── testutil
│ ├── throughput_perf
│ ├── transformation_example
│ ├── transformation_ut
│ ├── undistort
│ ├── unit_test_list.txt
│ └── viewer_opengl
├── include
│ ├── k4a
│ │ ├── k4a_export.h
│ │ ├── k4a.h
│ │ ├── k4a.hpp
│ │ ├── k4atypes.h
│ │ └── k4aversion.h.in
│ ├── k4ainternal
│ │ ├── allocator.h
│ │ ├── calibration.h
│ │ ├── capture.h
│ │ ├── capturesync.h
│ │ ├── color.h
│ │ ├── color_mcu.h
│ │ ├── common.h
│ │ ├── deloader.h
│ │ ├── depth.h
│ │ ├── depth_mcu.h
│ │ ├── dewrapper.h
│ │ ├── dynlib.h
│ │ ├── firmware.h
│ │ ├── global.h
│ │ ├── handle.h
│ │ ├── image.h
│ │ ├── imu.h
│ │ ├── k4aplugin.h
│ │ ├── logging.h
│ │ ├── math.h
│ │ ├── matroska_common.h
│ │ ├── matroska_read.h
│ │ ├── matroska_write.h
│ │ ├── queue.h
│ │ ├── rwlock.h
│ │ ├── tewrapper.h
│ │ ├── transformation.h
│ │ └── usbcommand.h
│ └── k4arecord
│ ├── playback.h
│ ├── playback.hpp
│ ├── record.h
│ ├── record.hpp
│ └── types.h
└── lib
└── x86_64-linux-gnu
├── cmake
│ ├── k4a
│ │ ├── k4aConfig.cmake
│ │ ├── k4aConfigVersion.cmake
│ │ ├── k4aTargets.cmake
│ │ └── k4aTargets-relwithdebinfo.cmake
│ └── k4arecord
│ ├── k4arecordConfig.cmake
│ ├── k4arecordConfigVersion.cmake
│ ├── k4arecordTargets.cmake
│ └── k4arecordTargets-relwithdebinfo.cmake
├── libdepthengine.so.2.0
├── libk4arecord.so -> libk4arecord.so.1.3
├── libk4arecord.so.1.3 -> libk4arecord.so.1.3.0
├── libk4arecord.so.1.3.0
├── libk4a.so -> libk4a.so.1.3
├── libk4a.so.1.3 -> libk4a.so.1.3.0
└── libk4a.so.1.3.0
11 directories, 114 files
4.修改 k4a_ros_device.h
路径:Azure_Kinect_ROS_Driver/include/azure_kinect_ros_driver/k4a_ros_device.h
4.1 将std::atomic_int64_t last_capture_time_usec_;
改为:std::atomic<int64_t> last_capture_time_usec_;
4.2 将std::atomic_uint64_t last_imu_time_usec_;
改为:std::atomic<uint64_t> last_imu_time_usec_;
4.3 将 std::atomic_bool imu_stream_end_of_file_;
改为: std::atomic<bool> imu_stream_end_of_file_;
5.编译
cd ~/KinectDK_ws
catkin_make
出现如下错误:
CMakeFiles/azure_kinect_ros_driver_node.dir/src/k4a_ros_device.cpp.o:在函数‘cv::Mat::Mat(int, int, int, void*, unsigned long)’中:
k4a_ros_device.cpp:(.text._ZN2cv3MatC2EiiiPvm[_ZN2cv3MatC5EiiiPvm]+0x296):对‘cv::Mat::updateContinuityFlag()’未定义的引用
collect2: error: ld returned 1 exit status
解决方法:添加opencv依赖
在/KinectDK_ws/src/Azure_Kinect_ROS_Driver/CMakeLists.txt中添加:
find_package(OpenCV REQUIRED)
target_link_libraries(${PROJECT_NAME}_node
${K4A_LIBS}
${OpenCV_LIBRARIES} # add
${catkin_LIBRARIES}
)
target_link_libraries(${PROJECT_NAME}_nodelet
${K4A_LIBS}
${OpenCV_LIBRARIES} #add
${catkin_LIBRARIES}
)
再次编译通过:
6.测试
6.1 运行luanch文件
roslaunch azure_kinect_ros_driver driver.launch
出现错误:
[ERROR] [1627390501.011460316]: Failed to open K4A device at index 0
[ERROR] [1627390501.011490280]: Failed to open a K4A device. Cannot continue.
进行SDK权限设置
cd ~/Azure-Kinect-Sensor-SDK
sudo cp scripts/99-k4a.rules /etc/udev/rules.d/.
重启设备
6.2 查看topic
rostopic list
话题如下:
/depth/camera_info
/depth/image_raw
/depth/image_raw/compressed
/depth/image_raw/compressed/parameter_descriptions
/depth/image_raw/compressed/parameter_updates
/depth/image_raw/compressedDepth
/depth/image_raw/compressedDepth/parameter_descriptions
/depth/image_raw/compressedDepth/parameter_updates
/depth/image_raw/theora
/depth/image_raw/theora/parameter_descriptions
/depth/image_raw/theora/parameter_updates
/depth_to_rgb/camera_info
/depth_to_rgb/image_raw
/depth_to_rgb/image_raw/compressed
/depth_to_rgb/image_raw/compressed/parameter_descriptions
/depth_to_rgb/image_raw/compressed/parameter_updates
/depth_to_rgb/image_raw/compressedDepth
/depth_to_rgb/image_raw/compressedDepth/parameter_descriptions
/depth_to_rgb/image_raw/compressedDepth/parameter_updates
/depth_to_rgb/image_raw/theora
/depth_to_rgb/image_raw/theora/parameter_descriptions
/depth_to_rgb/image_raw/theora/parameter_updates
/imu
/ir/camera_info
/ir/image_raw
/ir/image_raw/compressed
/ir/image_raw/compressed/parameter_descriptions
/ir/image_raw/compressed/parameter_updates
/ir/image_raw/compressedDepth
/ir/image_raw/compressedDepth/parameter_descriptions
/ir/image_raw/compressedDepth/parameter_updates
/ir/image_raw/theora
/ir/image_raw/theora/parameter_descriptions
/ir/image_raw/theora/parameter_updates
/joint_states
/points2
/rgb/camera_info
/rgb/image_raw
/rgb/image_raw/compressed
/rgb/image_raw/compressed/parameter_descriptions
/rgb/image_raw/compressed/parameter_updates
/rgb/image_raw/compressedDepth
/rgb/image_raw/compressedDepth/parameter_descriptions
/rgb/image_raw/compressedDepth/parameter_updates
/rgb/image_raw/theora
/rgb/image_raw/theora/parameter_descriptions
/rgb/image_raw/theora/parameter_updates
/rgb_to_depth/camera_info
/rgb_to_depth/image_raw
/rgb_to_depth/image_raw/compressed
/rgb_to_depth/image_raw/compressed/parameter_descriptions
/rgb_to_depth/image_raw/compressed/parameter_updates
/rgb_to_depth/image_raw/compressedDepth
/rgb_to_depth/image_raw/compressedDepth/parameter_descriptions
/rgb_to_depth/image_raw/compressedDepth/parameter_updates
/rgb_to_depth/image_raw/theora
/rgb_to_depth/image_raw/theora/parameter_descriptions
/rgb_to_depth/image_raw/theora/parameter_updates
/rosout
/rosout_agg
/tf
/tf_static