How to best handle dependencies on topics, services etc to gracefully handle startup and error recovery?
Is there a standard approach we should be using to handle dependencies on topics and services? Our system has a number of nodes and some nodes provide interfaces to external sensors. We'd like to be able to cleanly handle startup and error recovery conditions.
We are considering a few different situations and looking for advice:
If we have a node 'A' that depends on topics and services provided by other nodes, nodes 'B', and 'C' how should node 'A' determine when it is ready and should go online? -- Should 'A' wait to complete its startup until it sees the topics provided by 'B' and 'C' providing data values? Eg. node 'A' has some flags and flip them when data comes in and when they are all flipped node 'A' can go online?
We'd like our system to reasonably handle sensors going away. Maybe not in all cases but for particular sensors this is important. If we have sensors that go away, how do we indicate that information through to the users of the node that provides access to those sensors? -- For example should node 'B' stop publishing its topics if its sensor goes away? In that case should node 'A' be tracking the last update time for the topic provided by 'B' and if a timer expires node 'A' can use the lack of data to detect the sensor going offline and itself go offline, waiting until data is available before resuming its operation?
We've looked around and can't seem to find any guidance on this, however we suspect this may be due to our not searching using the correct terminology or missing or misunderstanding the design intent of Ros2.
We'd appreciate any tips or pointers you might have.