Ask Your Question

Turning ROS nodes on and off (subsumption style)?

asked 2012-09-10 05:52:59 -0500

Pi Robot gravatar image


Is there a good ROS-like way for turning nodes on and off and controlling how different nodes access shared resources? For example, suppose I am creating a voice-command demo and when I say "track face" I want a face tracker node to run. But when I say "track color" I want a color tracker node to run instead while the face tracker is turned off or at least suspended.

Similarly, suppose I am running a head tracking node that controls a pair of pan and tilt servos but I want to be able to manually override control of the servos--perhaps only briefly--then have the head tracking continue. (If I run the head tracker and manual control simultaneously, I get jerky servo motion as the two nodes simultaneously publish joint commands.)

The simplest method that comes to mind is to use shell process control (e.g. shlex and subprocess in Python) but that seems a little hacky. Is there a more ROS-like way to do this?


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2012-09-10 06:10:33 -0500

Lorenz gravatar image

Normally, you have all nodes that you need in a system running all the time, maybe idling most of it. If some actions need to be performed, they are then triggered by some high-level executive, e.g. a python script, that sends a command to the corresponding node that starts and maybe stops processing. For instance, if you have a face-tracking node and a color tracking node, both would provide an action. The executive node would send a goal to the face tracker and preempt it as soon as it is supposed to stop tracking. The color tracker would behave similarly.

Also, a multiplexer could work that allows to enable/disable messages on a node's input topic.

edit flag offensive delete link more


Thanks @Lorenz. Is mux ( what you had in mind for mutiplexing? I just stumbled upon it now after reading your answer.

Pi Robot gravatar image Pi Robot  ( 2012-09-10 13:01:14 -0500 )edit

That multiplexer might not be exactly what you need because it relays from multiple input topics to one output topic. Instead, I would implement a mux that has one input topic and multiple output topics.

Lorenz gravatar image Lorenz  ( 2012-09-10 23:44:13 -0500 )edit

The multiple input version could be useful for the "manually override" of the headtracker, similar like a joystick control would interfere with move_base.

dornhege gravatar image dornhege  ( 2012-09-11 00:36:34 -0500 )edit

Yes, last night I tried mux for the "manual override" situation and it works nicely for that. For switching between the face tracker and color tracker, I need a different method since part of the goal would be to save CPU cycles by not having the unused tracker processing frames while "idle".

Pi Robot gravatar image Pi Robot  ( 2012-09-11 03:50:10 -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


Asked: 2012-09-10 05:52:59 -0500

Seen: 1,447 times

Last updated: Sep 10 '12