Turn on/off node on events

asked 2018-12-23 12:03:54 -0600

CodeMade gravatar image

updated 2018-12-23 12:13:12 -0600

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.

edit retag flag offensive close merge delete

Comments

2

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

gvdhoorn gravatar image gvdhoorn  ( 2018-12-23 13:52:09 -0600 )edit
1

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

gvdhoorn gravatar image gvdhoorn  ( 2018-12-23 13:53:26 -0600 )edit
1

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

gvdhoorn gravatar image gvdhoorn  ( 2018-12-23 13:53:45 -0600 )edit

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

CodeMade gravatar image CodeMade  ( 2018-12-26 12:22:27 -0600 )edit

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

CodeMade gravatar image CodeMade  ( 2018-12-26 12:22:58 -0600 )edit

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?

gvdhoorn gravatar image gvdhoorn  ( 2018-12-27 04:31:07 -0600 )edit

@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.?

jorgemia gravatar image jorgemia  ( 2020-06-25 11:57:19 -0600 )edit