Robotics StackExchange | Archived questions

How to handle or control the start moment of nodes?

Hello, ROS experts. I described my situation.
Could you tell me some advice for me?
I hope it will be not too abstract to you.

I want to handle or control a start moment of nodes.
Is it possible in ROS?

I have make a package included some sensors like camera, lidar, radar, etc...
When our system begin to start process, It have to check whether the sensors is working well at that's time.
So, I added a code on packages of sensors to publish a topic which have a error message.
And, A package we call by Control Node will subscribe to check the error which was published by nodes of sensors.

If it will work as I thought, the Control Node must start before sensors. Is it always will start before the others? If not, How to control that?

I have used ros kinetic on ubuntu 16.04.

Asked by harderthan on 2018-07-11 03:31:01 UTC

Comments

First, be aware that the nodes are launched in the same order of the launch file so you should have your Control Node at the beginning of your launchfile.

Asked by Delb on 2018-07-11 03:38:01 UTC

Secondly, if for any reasons the initialization of Control Node is longer than the other nodes then you can have a publisher on a /start topic in your Control Node, publish on it when it's initialized and have your other nodes subscribing to /start waiting for the topic to be published on.

Asked by Delb on 2018-07-11 03:40:57 UTC

And I would suggest instead of a Control Node to directly check inside your different callbacks if the messages received are correct and do things only if true.

Asked by Delb on 2018-07-11 03:43:22 UTC

@Delb Do you have a link for that? As far as I know, roslaunch intentionally does not guarantee to start nodes in the order that they're listed in a launch file.

Asked by jayess on 2018-07-11 10:18:41 UTC

From the tutorial

Roslaunch intentionally does not provide any control on the order or timing of node start up

Asked by jayess on 2018-07-11 10:19:27 UTC

No I don't, it just always the behavior I've noted so I took it for granted. I'll dig deeper then thank you for pointing that out.

Asked by Delb on 2018-07-11 10:26:25 UTC

Roslaunch intentionally does not provide any control on the order or timing of node start up

Doesn't it state that there isn't any control on when the ros::init in each node file is called rather than which node file to call ?

Asked by Delb on 2018-07-11 10:30:16 UTC

I'm not sure, I'd have to see the link. But, take a look at the roslaunch Architecture on the wiki.

Asked by jayess on 2018-07-11 10:35:01 UTC

Okay so ros::init has nothing to do with this. But after digging into ros_comm I found in server.py that the process in the launch files are stored in an array and this array is browsed in a for loop. Since the XML is parsed in order I don't see how it could mix the initial order.

Asked by Delb on 2018-07-12 04:10:23 UTC

It would be interesting though if I could reproduce this "issue" but unfortunately I can't. Have you ever seen this behavior yourself ?

Asked by Delb on 2018-07-12 04:12:25 UTC

Answers

Thank you, @Delb and @jayess.

In my case, I'll use the way that make a topic to publish /start as start signal.

The link @jayess provided is helpful to me.
The point is that roslaunch does not provide and guarantee any control on order or timing of node start up.

Asked by harderthan on 2018-07-11 23:04:41 UTC

Comments