如何在ROS上使用usb_cam节点?

时间:2015-07-11 08:39:28

标签: camera robotics ros

我使用ros-indigo和ubuntu 14.04。我使用usb_cam从相机中获取帧,但我现在无法执行相同的任务。

如果我运行rosbuild_ws/package_dir$ roslaunch camera.launch命令,我会得到以下输出:

Unable to open camera calibration file [/home/user/.ros/camera_info/head_camera.yaml]
[ WARN] [1436602681.552893640]: Camera calibration file /home/user/.ros/camera_info/head_camera.yaml not found.
[ INFO] [1436602681.552918876]: Starting 'head_camera' (/dev/video0) at 640x480 via mmap (yuyv) at 30 FPS
[ WARN] [1436602681.584193482]: unknown control 'white_balance_temperature_auto'

[ WARN] [1436602681.587047162]: unknown control 'focus_auto'

为了处理这些错误和警告,我尝试安装usb_Cam。我运行rosdep install usb_cam,终端说#All required rosdeps installed successfully。我使用roscd usb_cam转到usb_cam文件夹。

然后我在命令下运行:

/opt/ros/indigo/share/usb_cam$ rosmake usb_cam
No Makefile in package usb_cam
[ rosmake ]         Results:                                                            
[ rosmake ] Built 39 packages with 0 failures.                                  
[ rosmake ] Summary output to directory 

最后,我运行rosbuild_ws/package_dir$ roslaunch camera.launch,但我收到同样的消息。我看不到从USB相机拍摄的画面。如何使用usb_cam从usb cam获取帧?

camera.launch的内容:

<!-- This will read a camera and show a streaming feed in a display window. -->

<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> 
  <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>

1 个答案:

答案 0 :(得分:0)

我不确定警告,但我相信你已经可以使用相机了。 关于帧速率,您可以在usb_cam / nodes / usb_cam_node.cpp中找到它 默认帧速率应为30。 您可以找到所需的所有参数:

node_.param("video_device", video_device_name_, std::string("/dev/video0"));
    node_.param("brightness", brightness_, -1); //0-255, -1 "leave alone"
    node_.param("contrast", contrast_, -1); //0-255, -1 "leave alone"
    node_.param("saturation", saturation_, -1); //0-255, -1 "leave alone"
    node_.param("sharpness", sharpness_, -1); //0-255, -1 "leave alone"
    // possible values: mmap, read, userptr
    node_.param("io_method", io_method_name_, std::string("mmap"));
    node_.param("image_width", image_width_, 640);
    node_.param("image_height", image_height_, 480);
    node_.param("framerate", framerate_, 30);
    // possible values: yuyv, uyvy, mjpeg, yuvmono10, rgb24
    node_.param("pixel_format", pixel_format_name_, std::string("mjpeg"));
    // enable/disable autofocus
    node_.param("autofocus", autofocus_, false);
    node_.param("focus", focus_, -1); //0-255, -1 "leave alone"
    // enable/disable autoexposure
    node_.param("autoexposure", autoexposure_, true);
    node_.param("exposure", exposure_, 100);
    node_.param("gain", gain_, -1); //0-100?, -1 "leave alone"
    // enable/disable auto white balance temperature
    node_.param("auto_white_balance", auto_white_balance_, true);
    node_.param("white_balance", white_balance_, 4000);

    // load the camera info
    node_.param("camera_frame_id", img_.header.frame_id, std::string("head_camera"));
    node_.param("camera_name", camera_name_, std::string("head_camera"));
    node_.param("camera_info_url", camera_info_url_, std::string(""));

然后您可以在启动文件中更改它们,如下所示:

   <param name="autoexposure" value="false" />
    <param name="auto_whitebalance" value="false" />
    <param name="auto_focus" value="false" />
    <param name="auto_brigthness" value="false" />

我也是新手,希望可以提供一些帮助。