Ask Your Question
1

How to run two cameras in ROS at different times?

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

Ralff gravatar image

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

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

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 imageRalff ( 2014-02-10 15:33:39 -0600 )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 imageRalff ( 2014-09-03 14:02:25 -0600 )edit
0

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

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

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: 2014-02-10 10:11:48 -0600

Seen: 200 times

Last updated: Feb 10 '14