ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

How to run two cameras in ROS at different times?

asked 2014-02-10 10:11:48 -0500

Ralff gravatar image

updated 2016-10-24 08:37:26 -0500

ngrennan gravatar image

I am trying to run two cameras on one single board computer with ROS and OpenCV, but I do not want to run the cameras at the same time. I want to run camera A until a specific moment then turn camera A off and turn camera B on; then B off and A on, and so on...

I am not sure how to do this effectively or at all really. I understand how to start up both cameras with a launch file or turn them off and on manually, but I want to do this automatically as certain parameters are met. Any ideas or advice?

Thanks - Ralff

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2014-02-10 10:28:06 -0500

ahendrix gravatar image

This is probably a good use case for the capabilities server: http://wiki.ros.org/capabilities ( tutorial )

The capabilities server allows you to declare launch files as capabilities, and then bring them up and down using ROS service calls.

edit flag offensive delete link more

Comments

Thanks. I will read up on capabilities to see if that will work. By the way, one reason I do not want to run two cameras simultaneously is that I receive an error for exceeding the bus capacity. It also seems more efficient to only run the camera that is being used.

Ralff gravatar image Ralff  ( 2014-02-10 15:33:39 -0500 )edit

I was never able to get the capabilities server working, but I found a way to control two cameras by writing a program to kill and restart the nodes using fork. This wasn't the cleanest method for doing this, but it worked fine for my application.

Ralff gravatar image Ralff  ( 2014-09-03 14:02:25 -0500 )edit
0

answered 2014-02-10 11:06:40 -0500

fergs gravatar image

One option is to have whatever node is using the image topics (and presumably contains the logic about what image topic it wants at a given time) unsubscribe/subscribe on demand. In theory, unsubscribing and then resubscribing would be less expensive than starting/stopping the node. This does assume the camera node does a lazy publish (that is, it checks if there is a subscriber, and if not it won't bother grabbing a frame from the camera and publishing it), however, this is typically quite common.

Another option would be to use dynamic reconfigure to start/stop the publishing, but this would certainly require modifying the camera node as I'm not aware of any camera nodes that have such an interface.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2014-02-10 10:11:48 -0500

Seen: 436 times

Last updated: Feb 10 '14