Set delay between starting nodes within launch file
I would like to put my nodes inside a launch file. The first node need to be up and running before the second node. Is it possible to set some timeout before the second starts. Like usleep(time)
in roscpp
<launch>
<node name="talker" pkg="roscpp_tutorials" type="talker" />
//delay of e.g. 1second
<node name="listener" pkg="roscpp_tutorials" type="listener" />
</launch>
Is this technically possible?
Ros has no such feature. Why do you need this function? What do you really want to achieve? Having hardcoded dependencies like this is a bad sign. What happens to your second node if the first one has to be restarted?
Thank you, but I do not face dependencies, this was about is it theoretically possible. E.g. holding a presentation and not wanting to go to the pc. I say some stuff about the window popping up of the first node, then after 30s I can gently move over the the second. But this is ok.
A potential proper solution is for one node to wait until another node is ready before properly starting up, similar to how
rosservice call --wait
works. You can probably also use a service to indicate whether a node has started up. In fact, it'd probably be nice if nodes by default took a "wait" arg that allows setting dependencies between nodes