Ask Your Question
0

Running two nodes for two webcams with usb_cam

asked 2016-03-25 09:17:31 -0500

Sood gravatar image

I'm trying to run two different webcams. What I understood was I need to create two different nodes and set the parameters differently to run them. Both are Logitech C270 cameras.

What I did was copy the usb_cam_node.cpp file to usb_cam_node1.cpp and usb_cam_node2.cpp. I then run them as follows:

rosrun usb_cam usb_cam_node1 _video_device:=/dev/video1 _camera_name:=cam1
rosrun usb_cam usb_cam_node2 _video_device:=/dev/video2 _camera_name:=cam2

I added executables to the CMakeList.txt as follows:

add_executable(${PROJECT_NAME}_node1 nodes/usb_cam_node1.cpp) add_executable(${PROJECT_NAME}_node2 nodes/usb_cam_node2.cpp)

target_link_libraries(${PROJECT_NAME}_node1
${PROJECT_NAME}
${avcodec_LIBRARIES}
${swscale_LIBRARIES}
${catkin_LIBRARIES}
)

target_link_libraries(${PROJECT_NAME}_node2
${PROJECT_NAME}
${avcodec_LIBRARIES}
${swscale_LIBRARIES}
${catkin_LIBRARIES}
)

However every time I execute one after the other, I get the following error.

[ WARN] [1458914475.903122037]: Shutdown request received.
[ WARN] [1458914475.903222764]: Reason given for shutdown: [new node registered with same name]

Quite obviously the nodes are different. Not sure what's going wrong.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2016-03-25 11:32:17 -0500

gvdhoorn gravatar image

updated 2016-03-25 11:36:28 -0500

What I understood was I need to create two different nodes and set the parameters differently to run them.

yes, but not by copying the source ..

I then run them as follows:

rosrun usb_cam usb_cam_node1 _video_device:=/dev/video1 _camera_name:=cam1
rosrun usb_cam usb_cam_node2 _video_device:=/dev/video2 _camera_name:=cam2

[..]

However every time I execute one after the other, I get the following error.

[ WARN] [1458914475.903122037]: Shutdown request received.
[ WARN] [1458914475.903222764]: Reason given for shutdown: [new node registered with same name]

Quite obviously the nodes are different. Not sure what's going wrong.

No. They're actually not different. It's not the name of the .cpp file that needs to be different, it's the node name. And that is set in usb_cam.node.cpp here.

Since you didn't change that, ROS detects that you have two nodes with the same name running, and shuts one of them down.


But changing the sources to run two instances of the same node is not actually required. You just need to configure them properly. See Running 2 different cameras using usb_cam for an example of a launch file that shows how to do that.

edit flag offensive delete link more

Comments

Thank you so much. I'm new to ROS and I missed things which should be obvious.

Sood gravatar image Sood  ( 2016-03-25 12:33:00 -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

2 followers

Stats

Asked: 2016-03-25 09:17:31 -0500

Seen: 1,251 times

Last updated: Mar 25 '16