Ask Your Question
2

Running 2 different cameras using usb_cam

asked 2015-10-02 14:56:25 -0500

DavidLavy gravatar image

Hello, I'm using the usb_cam package and I'm trying to launch my 2 cameras at the same time. I'm using the following launch file:


<launch>
 <group ns="camera1">
  <node name="usb_cam1" 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>
 </group>

<group ns="camera2">
  <node name="usb_cam2" pkg="usb_cam" type="usb_cam_node" output="screen" >
    <param name="video_device" value="/dev/video2" />
    <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>
 </group>
</launch>

I see that my two cameras launch (there is a light that turns on) but I don't get any images. My terminal gives me this msg:

$ roslaunch 2cams_test.launch 
... logging to /home/davicho/.ros/log/3a1f0a6e-6889-11e5-8461-0071cc3abcf5/roslaunch-davicho-3304.log
Checking log directory for disk usage. This may take awhile.
Press Ctrl-C to interrupt
Done checking log file disk usage. Usage is <1GB.

started roslaunch server http://davicho:51904/

SUMMARY

PARAMETERS * /camera1/image_view/autosize: True * /camera1/usb_cam1/camera_frame_id: usb_cam * /camera1/usb_cam1/image_height: 480 * /camera1/usb_cam1/image_width: 640 * /camera1/usb_cam1/io_method: mmap * /camera1/usb_cam1/pixel_format: mjpeg * /camera1/usb_cam1/video_device: /dev/video1 * /camera2/image_view/autosize: True * /camera2/usb_cam2/camera_frame_id: usb_cam * /camera2/usb_cam2/image_height: 480 * /camera2/usb_cam2/image_width: 640 * /camera2/usb_cam2/io_method: mmap * /camera2/usb_cam2/pixel_format: mjpeg * /camera2/usb_cam2/video_device: /dev/video2 * /rosdistro: indigo * /rosversion: 1.11.13

NODES /camera2/ image_view (image_view/image_view) usb_cam2 (usb_cam/usb_cam_node) /camera1/ image_view (image_view/image_view) usb_cam1 (usb_cam/usb_cam_node)

auto-starting new master process[master]: started with pid [3316] ROS_MASTER_URI=http://localhost:11311

setting /run_id to 3a1f0a6e-6889-11e5-8461-0071cc3abcf5 process[rosout-1]: started with pid [3329] started core service [/rosout] process[camera1/usb_cam1-2]: started with pid [3346] process[camera1/image_view-3]: started with pid [3356] process[camera2/usb_cam2-4]: started with pid [3357] process[camera2/image_view-5]: started with pid [3376] (image_raw:3356): Gtk-WARNING *: Unable to locate theme engine in module_path: "adwaita", (image_raw:3376): Gtk-WARNING *: Unable to locate theme engine in module_path: "adwaita",

Why is this happening? I've been reading about launch files, and I understood that by using two different nodes this would be able to launch multiple cameras, but I'm not succeeding.

Thanks in advance.

edit retag flag offensive close merge delete

Comments

Hi Sir, I used you method for my dual usb cameras and it works very well. However, in the terminal it throws heaps of the following warnings. Any idea how to solve it? Thanks [swscaler @ 0x2be20a0] deprecated pixel format used, make sure you did set range correctly

stevensu1838 gravatar image stevensu1838  ( 2018-12-12 22:48:17 -0500 )edit

2 Answers

Sort by » oldest newest most voted
2

answered 2016-10-26 15:23:06 -0500

nelsoncampos gravatar image

Hello,

First you need to change from

<param name="pixel_format" value="mjpeg" />

to

<param name="pixel_format" value="yuyv" />

Then you need to remap topic name from

<remap from="image" to="/usb_cam/image_raw"/>

to

ex: <remap from="image" to="/group_name/node_name/image_raw"/>

<remap from="image" to="/camera1/usb_cam1/image_raw"/>

Your code should be like:

<launch>
 <group ns="camera1">
  <node name="usb_cam1" 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="yuyv" />
    <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="/camera1/usb_cam1/image_raw"/>
    <param name="autosize" value="true" />
  </node>
 </group>

<group ns="camera2">
  <node name="usb_cam2" pkg="usb_cam" type="usb_cam_node" output="screen" >
    <param name="video_device" value="/dev/video2" />
    <param name="image_width" value="640" />
    <param name="image_height" value="480" />
    <param name="pixel_format" value="mjpeg" />
    <param name="camera_frame_id" value="yuyv" />
    <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="/camera2/usb_cam2/image_raw"/>
    <param name="autosize" value="true" />
  </node>
 </group>
</launch>
edit flag offensive delete link more

Comments

that helps a little for me, but I still don't understand something: Can I change the topic which each node publishes? I'm using usb_cam too and each node will run in different devices, I need them to publish on different topics so the server can send them instructions individually.

サイトダニエロ gravatar image サイトダニエロ  ( 2020-06-18 08:47:23 -0500 )edit
0

answered 2015-10-04 13:02:15 -0500

wsAndy gravatar image

Maybe you can launch one camera first. And sometimes if you link two more cameras in a USB-HUB , some thing strange will appear too. And you can also change the camera driver , for example, uvc_camera

edit flag offensive delete link more

Comments

uvc_camera is deprecated for indigo. And not sure how to use the libuvc_camera as they show as an alternative. I was sort of successful trying to launch two scripts, but I had to relaunched them several times because they kept crashing until it worked.

DavidLavy gravatar image DavidLavy  ( 2015-10-04 20:30:09 -0500 )edit

I'd like to have a script that works from the start

DavidLavy gravatar image DavidLavy  ( 2015-10-04 20:30:16 -0500 )edit

Hi I changed <param name="pixel_format" value="mjpeg" /> to <param name="pixel_format" value="yuyv" />, now I have two web cams running.

GT gravatar image GT  ( 2016-10-19 18:59:13 -0500 )edit

Hi guys, I get a "VIDIOC_STREAMON error 28, No space left on device" error when I try to run this above script. Do you know how to fix it?

robot_commander gravatar image robot_commander  ( 2017-10-24 17:06:42 -0500 )edit

2 camera successful config: <param name="pixel_format" value="yuyv" /><param name="image_width" value="320" /><param name="image_height" value="240" /><param name="fps" value="30" />

JackWu gravatar image JackWu  ( 2021-09-09 03:57:56 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-10-02 14:56:25 -0500

Seen: 7,604 times

Last updated: Oct 26 '16