Ask Your Question
0

Run one node in another node?

asked 2015-11-04 19:44:23 -0600

Winston gravatar image

updated 2015-11-10 06:47:15 -0600

The subject looks weird and difficult to understand so I am going to explain what I mean here. I want to know if it is possible to run a node inside another node. For example, when you have written a ROS node A and what you want A to do is to run other several ROS nodes B, C, D and etc. How to implement that? I don't want to use roslaunch to run several nodes in this case because after node A has run other nodes, it also has to do other stuff.

To go further, I want to write a ROS server and what it is supposed to do is waiting for "node request", that is , when a client calls this service, the server tries to run a node instantaneously. That is to say, how to run nodes in a service server? I think this case is essentially the same as the former one.

Any suggestions are appreciated very much.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2015-11-10 15:54:20 -0600

Dimitri Schachmann gravatar image

How about using nodelets? You can load multiple nodelets in a node at runtime and each nodelet runs in it's own thread.

http://wiki.ros.org/nodelet

edit flag offensive delete link more

Comments

Thank you. Could you provide with me some sample codes?

Winston gravatar imageWinston ( 2017-04-21 08:49:12 -0600 )edit
0

answered 2015-11-10 07:01:01 -0600

NEngelhard gravatar image

You could use system calls to execute rosrun commands. What are you trying to achieve?

edit flag offensive delete link more

Comments

Yes, system call is a solution but it may not be the best one. I heard that using system call in source code was not recommended. Any other work around?

Winston gravatar imageWinston ( 2015-11-10 07:17:20 -0600 )edit
1

Could be explain a bit more what you want to achieve? You could maybe just start all nodes with a launch file and only activate them via action or service. At startup, they'd just sleep until activation and then subscribe or advertise so that they don't use CPU or bandwidth.

NEngelhard gravatar imageNEngelhard ( 2015-11-10 07:20:56 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-11-04 19:44:23 -0600

Seen: 933 times

Last updated: Nov 10 '15