how to run a node from another node?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

how to run a node from another node?

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.
Reply | Threaded
Open this post in threaded view
|

Re: how to run a node from another node?

Minolo
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!

_______________________________________________
ros-users mailing list
[hidden email]
https://code.ros.org/mailman/listinfo/ros-users
Reply | Threaded
Open this post in threaded view
|

Re: how to run a node from another node?

safdar_zaman
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
Reply | Threaded
Open this post in threaded view
|

Re: how to run a node from another node?

Tim Niemueller
In reply to this post by safdar_zaman
On 06.02.2011 21:41, safdar_zaman wrote:
>
> 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
_______________________________________________
ros-users mailing list
[hidden email]
https://code.ros.org/mailman/listinfo/ros-users