RQt展示

功能介绍

TogetheROS.Bot兼容ROS2 foxy版本,支持通过RQt预览压缩格式图像,可以大幅度降低网络带宽消耗。

支持平台

平台 运行方式 示例功能
旭日X3派 Ubuntu 20.04 启动MIPI摄像头获取图像,在PC上使用RQt预览

准备工作

旭日X3派

  1. 旭日X3派已烧录好地平线提供的Ubuntu 20.04系统镜像。

  2. 旭日X3派已成功安装tros.b。

  3. PC已安装Ubuntu 20.04系统、ROS2 Foxy桌面版和可视化工具RQt,并且和旭日X3派在同一网段(IP地址前三位相同)。

    ROS2 Foxy安装参考:https://docs.ros.org/en/foxy/Installation/Ubuntu-Install-Debians.html

    PC 端 rqt-image-view安装方法为:sudo apt install ros-foxy-rqt-image-view ros-foxy-rqt

使用方式

旭日X3派

  1. 通过SSH登录开发板,启动板端相关程序

    vim hobot_codec.launch.py

    from launch import LaunchDescription
    from launch_ros.actions import Node
    
    
    def generate_launch_description():
        return LaunchDescription([
            # 启动图片发布pkg
            Node(
                package='mipi_cam',
                executable='mipi_cam',
                output='screen',
                parameters=[
                    {"out_format": "nv12"},
                    {"image_width": 640},
                    {"image_height": 480},
                    {"io_method": "shared_mem"},
                    {"video_device": "F37"}
                ],
                arguments=['--ros-args', '--log-level', 'error']
            ),
            # 启动jpeg图片编码&发布pkg
            Node(
                package='hobot_codec',
                executable='hobot_codec_republish',
                output='screen',
                parameters=[
                    {"channel": 1},
                    {"in_mode": "shared_mem"},
                    {"in_format": "nv12"},
                    {"out_mode": "ros"},
                    {"out_format": "jpeg-compressed"},
                    {"sub_topic": "/hbmem_img"},
                    {"pub_topic": "/image_raw/compressed"}
                ],
                arguments=['--ros-args', '--log-level', 'error']
            )
        ])
    

    保存然后:

    # 配置tros.b环境
    source /opt/tros/setup.bash
    # 拷贝相机标定数据文件
    cp -r /opt/tros/lib/mipi_cam/config/ .
    # 启动F37 camera以及hobot_codec, 发布compressed格式图像
    ros2 launch hobot_codec hobot_codec.launch.py
    
  2. 如程序输出如下信息,说明节点已成功启动

    [INFO] [launch]: All log files can be found below /root/.ros/log/2022-09-02-12-20-36-803599-ubuntu-3564852
    [INFO] [launch]: Default logging verbosity is set to INFO
    [INFO] [mipi_cam-1]: process started with pid [3564970]
    [INFO] [hobot_codec_republish-2]: process started with pid [3564972]
    
  3. PC机上订阅话题,并预览摄像头数据;

    # 配置ROS2环境
    source /opt/ros/foxy/local_setup.bash
    ros2 run rqt_image_view rqt_image_view
    

    选择话题/image_raw/compressed,图像效果图如下:

    ../../_images/rqt-result.png

注意事项

  1. 如遇到PC端ros2 topic list未识别到摄像头topic,做如下排查:

    • 检查旭日X3派是否正常pub图像

      source /opt/tros/setup.bash
      ros2 topic list
      

      输出:

      /camera_info
      /hbmem_img000b0c26001301040202012020122406
      /image_raw
      /image_raw/compressed
      /parameter_events
      /rosout
      
    • 检查PC和旭日X3派网络能否ping通;

    • PC和旭日X3派IP地址是否前三位相同;