Discussion:
how to run a node from another node?
safdar_zaman
2011-02-06 20:41:16 UTC
Permalink
Hi all,
How can one run a node from inside another node's code. I mean I want to run
a node when a specific condition is true, and then shutdown it. normally we
run a node from terminal using "rosrun pakg node" but how to run this node
in c/python code?
thanks in advance.
--
View this message in context: http://ros-users.122217.n3.nabble.com/how-to-run-a-node-from-another-node-tp2439377p2439377.html
Sent from the ROS-Users mailing list archive at Nabble.com.
Minolo
2011-02-08 01:54:51 UTC
Permalink
Hello there!

I don't know if I'm in time to help, but I'll still try!

The only way of doing it that comes to mind right now is using the system
call from C (I guess there must be a similar function in python too, sorry
I'm not much of a python guy as of now :p)

So I think you can do what you say with something like:

if(condition)
system("rosrun package node");

Then the node itself should do the work it has to do, then finish. From your
message I don't know if what you want is that the program that ran the
system call should also be the one that kills that new node.

As for a particular ROS function that runs a node itself, I've been looking
for one too but I can't seem to find it. If there's one I would very much
like to hear from it :D

Hope to have helped you. Cheers!
safdar_zaman
2011-02-16 15:33:30 UTC
Permalink
Hi Minolo,
thanks for the reply...in ROS what I know is that to invoke the nodes use
action servers. Make one action client which can call action servers one by
one to invoke node's functionality.
http://www.ros.org/wiki/actionlib_tutorials/Tutorials provides help how to
make actions.

regards,
safda
--
View this message in context: http://ros-users.122217.n3.nabble.com/how-to-run-a-node-from-another-node-tp2439377p2510207.html
Sent from the ROS-Users mailing list archive at Nabble.com.
Tim Niemueller
2011-02-16 17:30:09 UTC
Permalink
Post by safdar_zaman
Hi all,
How can one run a node from inside another node's code. I mean I want to run
a node when a specific condition is true, and then shutdown it. normally we
run a node from terminal using "rosrun pakg node" but how to run this node
in c/python code?
thanks in advance.
You might want to have a look at http://www.ros.org/wiki/rosspawn. It
might just do what you need, i.e. start and stop a node, without setting
parameters from a launch file. Code is at
https://github.com/timn/rosspawn and patches to improve its
functionality are welcome.

Tim
--
KBSG - Knowledge-Based Systems Group AllemaniACs RoboCup Team
========================================================================
http://robocup.rwth-aachen.de RWTH Aachen University
http://kbsg.rwth-aachen.de Ahornstrasse 55
http://www.fawkesrobotics.org D-52056 Aachen
Continue reading on narkive:
Loading...