鱼香ROS社区
    • 版块
    • 最新
    • 未解决
    • 已解决
    • 群组
    • 注册
    • 登录
    紧急通知:禁止一切关于政治&VPN翻墙等话题,发现相关帖子会立马删除封号
    提问前必看的发帖注意事项: 社区问答规则(小鱼个人)更新 | 高质量帖子发布指南

    ROS2相机驱动选择Video编号

    已定时 已固定 已锁定 已移动
    文档资料
    ros2 camera
    1
    1
    448
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • 小鱼小
      小鱼 技术大佬
      最后由 编辑

      大家好,我是小鱼。今天早上有个鱼粉在群里问在ROS2中选择相机编号?

      在这里插入图片描述

      问题

      在ROS2的Foxy版本中,你可以使用下面的命令来运行相机。

      source /opt/ros/foxy/setup.bash
      ros2 run image_tools cam2image 
      

      我们如果电脑中有多个video设备怎么办?

      使用下面的命令来查看video

      ll /dev/video*
      crw-rw----+ 1 root video 81, 0 3月   7 11:02 /dev/video0
      crw-rw----+ 1 root video 81, 1 3月   7 11:02 /dev/video1
      crw-rw----+ 1 root video 81, 2 3月   7 11:02 /dev/video2
      crw-rw----+ 1 root video 81, 3 3月   7 11:02 /dev/video3
      crw-rw----+ 1 root video 81, 4 3月   8 20:50 /dev/video4
      crw-rw----+ 1 root video 81, 5 3月   8 20:50 /dev/video5
      crw-rw----+ 1 root video 81, 6 3月   8 01:32 /dev/video6
      

      可以看到小鱼有7个video,那我们先要在运行的时候指定video编号该怎么办?我们看看这个节点的help信息。

      $ ros2 run image_tools cam2image --help
      Usage: cam2image [-h] [--ros-args [-p param:=value] ...]
      Publish images from a camera stream.
      Example: ros2 run image_tools cam2image --ros-args -p reliability:=best_effort
      
      Options:
        -h, --help	Display this help message and exit
      
      Parameters:
        reliability	Reliability QoS setting. Either 'reliable' (default) or 'best_effort'
        history	History QoS setting. Either 'keep_last' (default) or 'keep_all'.
      		If 'keep_last', then up to N samples are stored where N is the depth
        depth		Depth of the publisher queue. Only honored if history QoS is 'keep_last'. Default value is 10
        frequency	Publish frequency in Hz. Default value is 30
        burger_mode	Produce images of burgers rather than connecting to a camera
        show_camera	Show camera stream. Either 'true' or 'false' (default)
        width		Width component of the camera stream resolution. Default value is 320
        height	Height component of the camera stream resolution. Default value is 240
        frame_id		ID of the sensor frame. Default value is 'camera_frame'
      Note: try running v4l2-ctl --list-formats-ext to obtain a list of valid values.
      

      很遗憾,没有指定video编号这个参数。

      解决方案

      查阅Github可以看到,在foxy的下一个版本galactic中增加了这个功能。

      使用--ros-args -p device_id:=id号即可指定video编号。

      source /opt/ros/galactic/setup.bash
      ros2 run image_tools cam2image --ros-args -p device_id:=0
      

      你可以选择同时安装两个版本的ros2,运行相机时使用galactic,经小鱼测试,foxy版本依然可以正常收到话题数据。

      还有一种办法就是下载源码编译,依然可以在foxy版本下正常使用~

      新书配套视频:https://www.bilibili.com/video/BV1GW42197Ck/

      1 条回复 最后回复 回复 引用 0
      • 第一个帖子
        最后一个帖子
      皖ICP备16016415号-7
      Powered by NodeBB | 鱼香ROS