BB.Kino.Shared.PubSubHandler (bb_kino v0.3.3)

View Source

Common patterns for subscribing and unsubscribing from BB PubSub.

Used by widgets that need to receive real-time updates from robots.

Summary

Functions

Subscribes to one or more paths on a robot's PubSub.

Subscribes to all actuator messages.

Subscribes to all sensor messages.

Subscribes to state machine transitions.

Unsubscribes from one or more paths on a robot's PubSub.

Functions

subscribe(robot, paths, opts \\ [])

@spec subscribe(module(), [[atom()]], keyword()) :: :ok

Subscribes to one or more paths on a robot's PubSub.

Options

  • :message_types - list of message type modules to filter by

Examples

subscribe(MyRobot, [[:sensor], [:actuator]])
subscribe(MyRobot, [[:sensor, :joint1]], message_types: [BB.Message.Sensor.JointState])

subscribe_actuators(robot, opts \\ [])

@spec subscribe_actuators(
  module(),
  keyword()
) :: :ok

Subscribes to all actuator messages.

subscribe_sensors(robot, opts \\ [])

@spec subscribe_sensors(
  module(),
  keyword()
) :: :ok

Subscribes to all sensor messages.

subscribe_state_machine(robot)

@spec subscribe_state_machine(module()) :: :ok

Subscribes to state machine transitions.

State transitions are published to [:state_machine] and contain from and to states.

unsubscribe(robot, paths)

@spec unsubscribe(module(), [[atom()]]) :: :ok

Unsubscribes from one or more paths on a robot's PubSub.