BB.Camera.Discovery (bb_camera v0.1.1)

Copy Markdown View Source

Finds the cameras a robot declares.

A static walk of the robot's DSL - the robot-level sensors section plus every link and joint in the topology - keeping the sensors whose callback module implements BB.Camera. It needs nothing running, which is the point: a camera that should be there and isn't is exactly what an operator needs to see, and a UI that can only list cameras once they work is no use while something is broken.

Live hubs are merged in where they exist, so a single pass gives both the declared set and the running state.

Summary

Functions

Whether module is a camera driver.

The declared sensors of robot that are cameras, with their topology position.

Every camera robot declares, running or not.

The hub serving a camera, or :undefined.

Functions

camera?(module)

@spec camera?(module()) :: boolean()

Whether module is a camera driver.

declared(robot)

@spec declared(module()) :: [{BB.Dsl.Sensor.t(), [atom()], BB.Camera.Info.t()}]

The declared sensors of robot that are cameras, with their topology position.

Returns {%BB.Dsl.Sensor{}, parent_path, attached_to} tuples, options and all. Internal: the options are what BB.Camera.stream_info/1 needs and are deliberately not carried into BB.Camera.Info.

discover(robot)

@spec discover(module()) :: [BB.Camera.Info.t()]

Every camera robot declares, running or not.

hub_pid(robot, name)

@spec hub_pid(module(), atom()) :: pid() | :undefined

The hub serving a camera, or :undefined.

A robot that has never started has no registry at all, and asking one that doesn't exist raises rather than answering. Everything here has to work on stopped robots, so the absence of the registry is just another way of saying nothing is running.