Ubuntu18.04 Azure Kinect ROS Driver配置

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

在这里插入图片描述

  • 2
    点赞
  • 18
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

BkbK-

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值