Robotics StackExchange | Archived questions

Is there a package for management to control the start order of nodes?

Hello, experts.
This question is the following this link

I wanted to manage the start order of nodes I developed.
Is there a package for management to control the start(initialization) order of nodes?
Would you tell me information about that's packages or tools?

Let's imagine there are many nodes which have dependency of the start moment of others.
For example, the start order of "B" node have dependency on the start order of "A" node. This mean is that "B" node can start to initialize for itself after receiving a signal which "A" node will send to "B" node.
When "A" node is initializing, It may be that we want to stop the progress of initializing the "B" node by a signal like initialization fail.

For a small number of nodes, we just add some code for check that.
We can use a topic named /start or We can use a service and client.
But, for many number of nodes, we have to add similar code in many times.
Patently , It is a duplicate work.
And, when we want to change it's construction about the order, we will have a burden.

Is there a package or tool to help this problem solve easily?
If there is no that, maybe I'll make it.

// On this description, "initialization" of nodes is not "initialization" of linux's process.
// It is the initialization, in your code, as dynamic memory allocation, instance initialization.

Asked by harderthan on 2018-07-13 08:45:27 UTC

Comments

You can use the bash script to sequentially start the nodes in the order you need

Asked by 0xd1ma on 2018-07-15 08:53:38 UTC

@0xd1ma . Thank you for a comment.

Yes, right. If we use the bash script to sequentially, then it will start the nodes in the order I need. But, exactly I want to control the order of initialization progress in node code.

Asked by harderthan on 2018-07-15 19:25:47 UTC

@0xd1ma .

Please think about this. Despite that "A" node started first, "A" node will be albe to finish more late than others.

Asked by harderthan on 2018-07-15 19:26:07 UTC

Answers

I don't have a satisfactory answer for controlling the node launch order. ROS1 wasn't really intended to be used that way.

A better ROS1 approach would be to launch a bunch of servers or action servers simultaneously. A state machine could be used to manage the way each node reacts to error signals (e.g. shut down node B if node A emits X error msg). Two ROS packages for that are FlexBE and SMACH. FlexBE sounds a bit more sophisticated because you can update it on the fly.

Asked by AndyZe on 2018-07-13 11:05:06 UTC

Comments

Could you maybe be a bit more specific and point to the relevant part of the docu?

Asked by NEngelhard on 2018-07-14 01:26:16 UTC

I don't see how FlexBE can help with the OP's question?

Asked by PeteBlackerThe3rd on 2018-07-14 05:18:13 UTC

If you take the narrow view of "how do you run nodes in a specific order" it's not the right answer.

To the bigger question of how do you reconfigure and trigger things without lots of repetitive code, it seems like a good answer.

Asked by AndyZe on 2018-07-14 14:11:41 UTC

So it's simply not the right answer to this question?

Asked by NEngelhard on 2018-07-14 14:31:50 UTC

There's not a satisfactory solution to launching nodes in order because ROS1 wasn't designed like that. It looks like FlexBE gives equivalent functionality, though. SMACH would probably work, too.

Asked by AndyZe on 2018-07-14 15:48:01 UTC

FlexBE and SMACH only care about execution, not about how the nodes are started, so your answer simply is incorrect.

Asked by NEngelhard on 2018-07-14 15:55:28 UTC

@NEngelhard feeling pedantic today, huh?

I hope you give a better suggestion.

Asked by AndyZe on 2018-07-14 15:59:06 UTC

The question was specifically about organizing the start sequence of several nodes. How can FlexBE/SMASH help if your system does not start e.g. due to deadlocks while launching?

Asked by NEngelhard on 2018-07-14 16:08:38 UTC

OP may not have been sure exactly how to phrase his question but he is looking for ways to handle error messages between nodes. Sounds like a state machine to me. Thanks for the downvote.

Asked by AndyZe on 2018-07-14 16:40:05 UTC

@NEngelhard: I think I agree with @AndyZe. Taking the question literally it would seem only the 'order of starting nodes' is important, but the OP later seems to describe something a state machine would be ideal for (ie: node coordination).

ROS Answers policy is to provide the 'best answer' that ..

Asked by gvdhoorn on 2018-07-15 04:49:04 UTC

.. addresses the post. Further interaction with the OP can then be used to clarify anything that is unclear and to incrementally enhance the answer.

We've not heard from the OP yet, so perhaps node coordination is exactly what he could use to solve his problems.

If OP adds a component runtime ..

Asked by gvdhoorn on 2018-07-15 04:50:14 UTC

.. model to his nodes (something akin to what ROS 2 has) then something like FlexBE could be exactly what solves all of this.

That is what I believe @AndyZe has in mind when he talks about the "bigger question".

Asked by gvdhoorn on 2018-07-15 04:51:21 UTC

Thank guys for replies.

@AndyZe, @gvdhoorn
Your answer seem that there is a clear solution in ROS2.
Could you explain more about it?
I don't know exaclty how ROS2 can be a solution to the problem.
(I don't know well about ROS2)

Asked by harderthan on 2018-07-15 05:42:35 UTC

I had a similar problem, as I needed some topics from node 1 first, so node 2 could use them. I used delay as described here link.

Asked by Choco93 on 2018-07-16 03:15:32 UTC

Comments

Please check upper comments on my topic. exactly I want to control the order of initialization progress in node code.

Asked by harderthan on 2018-07-16 23:24:49 UTC

The link I shared can be used to initialize nodes in order by adding delay in them. You can call service to launch second node when condition of second node is met.

Asked by Choco93 on 2018-07-17 01:41:30 UTC

You can also modify the shell script so instead of delay, it would check if certain topic has data in it, and if it has, then launch second node.

Asked by Choco93 on 2018-07-17 01:43:06 UTC