Interfacing USB webcams in ROS

We can start interfacing with an ordinary webcam or a laptop cam in ROS. There are no exact specific packages for webcam - ROS interfaces. If the camera is working in Ubuntu/Linux, it may be supported by the ROS driver too. After plugging the camera, check whether a /dev/videoX device file has been created, or check with some application such as Cheese, VLC, and such others. The guide to check whether the web cam is supported on Ubuntu is available at https://help.ubuntu.com/community/Webcam.

We can find the video devices present on the system using the following command:

$ ls /dev/ | grep video    

If you get an output of video0, you can confirm a USB cam is available for use.

After ensuring the webcam support in Ubuntu, we can install a ROS webcam driver called usb_cam using the following command:

  • In ROS Jade
    $ sudo apt-get install ros-jade-usb-cam  
  • In ROS Indigo
    $ sudo apt-get install ros-indigo-usb-cam

We can install the latest package of usb_cam from the source code. The driver is available on GitHub at https://github.com/bosch-ros-pkg/usb_cam

The usb_cam package contains a node called usb_cam_node, which is the driver of USB cams. There are some parameters that need to be set before running this node. We can run the ROS node along with its parameters. The usb_cam-test.launch launch file can launch the USB cam driver with the necessary parameters:

<launch> 
  <node name="usb_cam" pkg="usb_cam" type="usb_cam_node" output="screen" > 
    <param name="video_device" value="/dev/video0" /> 
    <param name="image_width" value="640" /> 
    <param name="image_height" value="480" /> 
    <param name="pixel_format" value="yuyv" /> 
    <param name="camera_frame_id" value="usb_cam" /> 
    <param name="io_method" value="mmap"/> 
  </node> 
 
<!-- Launching image_view node --> 
 
  <node name="image_view" pkg="image_view" type="image_view" respawn="false" output="screen"> 
    <remap from="image" to="/usb_cam/image_raw"/> 
    <param name="autosize" value="true" /> 
  </node> 
</launch> 

This launch file will start usb_cam_node with the video device /dev/video0, with a resolution of 640x480. The pixel format here is YUV (https://en.wikipedia.org/wiki/YUV). After initiating usb_cam_node, it will start an image_view node for displaying the raw image from the driver. We can launch the previous file using the following command:

$ roslaunch usb_cam usb_cam-test.launch

We will get the following message with an image view as shown next:

Figure 1 : USB camera view using image view tool

The topics generated by the driver are shown next. There are raw, compressed, and Theora codec topics generated by the driver.

Figure 2 : List of topics generated by the USB camera driver

We can visualize the image in another window using the following command:

    $ rosrun image_view image_view image:=/usb_cam/image_raw  

After getting the camera image message, the first thing we have to do is camera calibration.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.139.224