usb_cam Package理解

0. 简介:
A ROS Driver For V4L USB Camera.
0.1: ROS Driver和Linux driver的区别:
ROS并非全操作系统,它只是架设在Ubuntu上的一个次级系统。提供了一系列通讯方式,工具和包,让开发者更容易工作的一个平台。 
所以,ROS Driver与Linux Driver完全不同。 Linux Driver是在内核模式下获取硬件信息,反馈到用户模式下。并提供在用户模式下控制内核模式下才能访问的硬件的途径(ioctl)。
ROS Driver则不同,它完全是在用户模式下,从Linux层面获取数据。并通过Topic发送Message。使得其它ROS Node可以通过topic得到信息的程序。
usb_cam就是个典型的ROS Driver. 通过它,理解ROS Driver的层级和用途。
它并非Linux传统意义上的Driver, 它其实只是个应用程序,通过V4L2接口设置Camera并获取数据, 利用ROS接口发布Topic,供其它Node实用.
1. usb_cam的下载和组织结构:
1.1: 下载并编译:
$cd ~/catkin_ws/src
$cd ~catkin_ws
$catkin_make
1.2:目录文件分析:
分析代码组织架构,最好的方法是分析CMakeLists.txt. 从中可以看到,主要的C/C++源码有2个。
src/usb_cam.cpp最终产生libusb_cam.so, 它使用V4L2 接口访问Camera,并提供一些必要的格式转换工具。
nodes/usb_cam_node.cpp最终产生usb_cam_node。(它使用了前面产生的库)。它初始化ROS,利用libusb_cam.so获取Camera数据。并利用image_transport发布各种格式的Image。
1.3:usb_cam_node相关讲解:
usb_cam_node 利用libusb_cam.so使用通用接口访问USB Camera。并publishe Image使用格式为:sensor_msgs::Image.
可以使用image_transport 库去传输压缩格式Image。
1.3.1: Publish Topic:
~/image  ( sensor_msgs/Image )
  • The image
1.3.2:Parameter:
~video_device  (string , default: "/dev/video0" )
  • The device the camera is on.
~image_width  (integer , default: 640 )
  • Image width
~image_height  (integer , default: 480 )
  • Image height
~pixel_format  (string , default: "mjpeg" )
  • Possible values are mjpeg, yuyv, uyvy
~io_method  (string , default: "mmap" )
  • Possible values are mmap, read, userptr
~camera_frame_id  (string , default: "head_camera" )
  • The camera's tf frame
~framerate  (integer , default: 30 )
  • The required framerate
~contrast  (integer , default: 32 )
  • Contrast of video image (0-255)
~brightness  (integer , default: 32 )
  • Brightness of video image (0-255)
~saturation  (integer , default: 32 )
  • Saturation of video image (0-255)
~sharpness  (integer , default: 22 )
  • Sharpness of video image (0-255)
~autofocus  (boolean , default: false )
  • Enable camera's autofocus
~focus  (integer , default: 51 )
  • If autofocus is disabled, the focus of the camera (0=at infinity)
~camera_info_url  (string , default:  )
  • An url to the camera calibration file that will be read by the CameraInfoManager class
~camera_name  (string , default: head_camera )
  • The camera name. This must match the name in the camera calibration
这些参数就是V4L2常用的设置参数。
2. usb_cam使用:
2.1: 字符模式下使用: 
$roscore
$rosrun usb_cam usb_cam_node
$rosrun rqt_image_view rqt_image_view 

2.2: launch文件例子
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值