How to handle or control the start moment of nodes? [closed]
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.
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.
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.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.
@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.From the tutorial
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.
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 ?I'm not sure, I'd have to see the link. But, take a look at the roslaunch Architecture on the wiki.