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.
I would actually not start or shutdown nodes, but coordinate when they perform any work.
For nodes that operate on dataflows, use a
mux
ordemux
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 themux
to .... 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 ..
.. resource(s) that should be released whenever it's not active).
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
neural network. but then not do any forward passes until a flag is triggered.
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?
@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.?