maandag 8 juni 2015

Webcam on ROS

For many applications having a webcam running on ROS makes a lot of sense. Getting it running is not very difficult. As always, there are some choices to make.

On ROS indigo, the default driver is libuvc_camera but this is not the best one. The package uvc_cam used to be excellent but is no longer maintained. The best package I know of is usb_cam which I'll be using here.

Here is how to get it working in five simple steps:
Step 1: 
in a catkin workspace / src folder do:
git clone https://github.com/bosch-ros-pkg/usb_cam.git

Step 2:
then run catkin_make from the catkin workspace root folder.

Step 3:
Make sure the <catkin_workspace>/devel/setup.bash file is sourced.

Step 4:
Create a .launch file with the following contents:
<launch>
  <node name="usb_cam" pkg="usb_cam" type="usb_cam_node" output="screen" >
    <param name="video_device" value="/dev/video1" />
    <param name="image_width" value="640" />
    <param name="image_height" value="480" />
    <param name="pixel_format" value="mjpeg" />
    <param name="camera_frame_id" value="usb_cam" />
    <param name="io_method" value="mmap"/>
  </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>

change the /dev/video1 to /dev/video0 if needed.
Mostly, on a laptop video0 would be the built-in device and video1 would be the external usb webcam.

Step 5:
roslaunch <newly created launchfile>

1 opmerking:

  1. Hello,

    I followed the step, but I got this error:
    CMake Error at /opt/ros/indigo/share/catkin/cmake/assert.cmake:17 (message):


    Assertion failed: check for file existence, but filename
    (RT_LIBRARY-NOTFOUND) unset. Message: RT Library

    Call Stack (most recent call first):
    /opt/ros/indigo/share/catkin/cmake/tools/rt.cmake:42 (assert_file_exists)
    /opt/ros/indigo/share/catkin/cmake/all.cmake:147 (include)
    /opt/ros/indigo/share/catkin/cmake/catkinConfig.cmake:20 (include)
    CMakeLists.txt:52 (find_package)


    -- Configuring incomplete, errors occurred!
    See also "/home/darwin/work/ros_ws/usbcam_ws/build/CMakeFiles/CMakeOutput.log".
    See also "/home/darwin/work/ros_ws/usbcam_ws/build/CMakeFiles/CMakeError.log".
    Invoking "cmake" failed

    BeantwoordenVerwijderen