Robotics StackExchange | Archived questions

Turn on/off node on events

I am working on a program that activates Yolo object detection if there is movement. Then it turns off yolo when it has completed its task. I was able to use the roslaunch api to launch yolo on a movement event but I can't get it to shut down the node. What's the best way to do this type of thing in ROS? Yolo uses the GPU and I don't want it running when it isn't needed.

Asked by CodeMade on 2018-12-23 13:03:54 UTC

Comments

I would actually not start or shutdown nodes, but coordinate when they perform any work.

For nodes that operate on dataflows, use a mux or demux and switch it to an "unconnected" input whenever you don't want the node to perform any work. If it needs to do something, switch the mux to ..

Asked by gvdhoorn on 2018-12-23 14:52:09 UTC

.. the topic that carries the messages that you want the node to process. After it's finished, switch the mux back to the unconnected input.

Coordinating things this way is much easier and should result in the same "idle behaviour" as not running the node (unless the node claims some ..

Asked by gvdhoorn on 2018-12-23 14:53:26 UTC

.. resource(s) that should be released whenever it's not active).

Asked by gvdhoorn on 2018-12-23 14:53:45 UTC

Thanks for the comments. The node does use a lot of resources which is why I want to shut it down. I ended up using the roslaunch API to start and stop the node. The problem now is that the node take about 6 seconds to start. I need it to start immediately. So I am looking into how to load the

Asked by CodeMade on 2018-12-26 13:22:27 UTC

neural network. but then not do any forward passes until a flag is triggered.

Asked by CodeMade on 2018-12-26 13:22:58 UTC

I'm confused: I'm not entirely familiar with the yolo node, but wouldn't it just "idle" when there are no incoming image messages?

Asked by gvdhoorn on 2018-12-27 05:31:07 UTC

@CodeMade were you able to come up with something to reduce CPU/GPU usage or so that YOLO isn't running all the time, but is ready to go when a button is pressed for eg.?

Asked by jorgemia on 2020-06-25 11:57:19 UTC

Answers