Supervisor for a sensor and the estimators nested inside it.
Strategy is :rest_for_one, with two children: the sensor first, then a
:one_for_one supervisor holding its estimators. When the sensor dies its
estimators are stopped and started again after it, so each one subscribes to
whatever the new sensor provides rather than racing it. An estimator dying
on its own restarts only itself; the estimators sit under a supervisor of
their own so that one crashing doesn't take the estimators after it down
too, as it would if they were siblings under :rest_for_one.
That ordering is what makes a source that dies with its sensor - a camera's
hub, say - safe to subscribe to in an estimator's init/1. Under a
:one_for_one parent an estimator could be restarted before its sensor was,
find nothing to subscribe to, and spend the parent's restart budget failing.
The cost is that a sensor-nested estimator always loses its state when its sensor crashes, whatever its source.
Its restart budget is configurable via the sensor_max_restarts and
sensor_max_seconds settings on the robot DSL. A sensor that keeps crashing
spends this budget before its parent sees a failure, so a lower
sensor_max_restarts escalates a flapping sensor sooner. The estimators'
supervisor has OTP's default budget; an estimator that keeps crashing
exhausts it, and reaches this supervisor as one failure.
A sensor with no nested estimators gets no supervisor of its own; it stays a direct child of its link, joint or robot-level sensor supervisor.
Summary
Functions
The child spec for sensor, declared at path: this supervisor if the
sensor has nested estimators, otherwise the sensor's own.
Starts the supervisor for sensor and its estimators.
Functions
@spec child_spec_for(module(), BB.Dsl.Sensor.t(), [atom()], Keyword.t()) :: Supervisor.child_spec()
The child spec for sensor, declared at path: this supervisor if the
sensor has nested estimators, otherwise the sensor's own.
path is the link or joint path the sensor sits under, or [] for a
robot-level sensor.
@spec start_link({module(), BB.Dsl.Sensor.t(), [atom()], Keyword.t()}) :: Supervisor.on_start()
Starts the supervisor for sensor and its estimators.