< >
Home » ROS2与VSLAM入门教程 » ROS2与VSLAM入门教程-深度数据转换为激光数据

ROS2与VSLAM入门教程-深度数据转换为激光数据

ROS2与VSLAM入门教程-深度数据转换为激光数据

说明:

  • 介绍如何把深度相机获取的深度数据转化为激光数据
  • 环境:ubuntu20.04 galactic + d435i深度相机

相关设备

apt安装步骤:

  • apt安装
sudo apt install ros-galactic-depthimage-to-laserscan
  • 新建launch文件,depthimage_to_laserscan.launch.py
import os

from ament_index_python.packages import get_package_share_directory
from launch import LaunchDescription
from launch_ros.actions import Node


def generate_launch_description():
    param_config = os.path.join(get_package_share_directory('depthimage_to_laserscan'), 'cfg', 'param.yaml')
    return LaunchDescription([
        Node(
            package='depthimage_to_laserscan',
            executable='depthimage_to_laserscan_node',
            name='depthimage_to_laserscan_node',
            remappings=[('depth','/camera/depth/image_rect_raw'),
                        ('depth_camera_info', '/camera/depth/camera_info')],
            parameters=[param_config])
    ])
  • 测试
ros2 launch depthimage_to_laserscan.launch.py

源码安装步骤:

  • 安装依赖
sudo apt install ros-galactic-image_geometry 
  • 假设已经有工作空间ros2_common_ws
  • 下载和编译源码
cd ~/ros2_common_ws/src
git clone -b foxy-devel  https://github.com/ros-perception/depthimage_to_laserscan
cd ~/ros2_common_ws/
colcon build --symlink-install --packages-select=depthimage_to_laserscan
  • 加载使用
source ~/ros2_common_ws/install/local_setup.bash 
  • 测试如上
  • 如果因为Qos导致不能订阅深度话题,可以修改DepthImageToLaserScanROS.cpp源码设置Qos为best_effort
需要修复Qos,使用best_effort
// auto qos = rclcpp::SystemDefaultsQoS();
auto qos = rclcpp::QoS(10).best_effort();

纠错,疑问,交流: 请进入讨论区点击加入Q群

获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号


标签: **ROS2与VSLAM入门教程