BB.Reactor.Context (bb_reactor v0.2.3)

Copy Markdown View Source

BB context for reactor execution.

This struct is injected into the reactor context by BB.Reactor.Middleware.Context and made available to all steps as context.private.bb.

Fields

  • :robot_module - The robot module (e.g., MyRobot)
  • :robot - The static BB.Robot struct from robot_module.robot()
  • :robot_state - The current robot state (:disarmed, :idle, :executing, etc.)
  • :execution_id - Unique identifier for this reactor execution

Usage in Steps

def run(arguments, context, options) do
  bb = context.private.bb
  robot = bb.robot_module

  # Use robot module to invoke commands
  apply(robot, :move_to, [goal])
end

Summary

Functions

Create a new BB context for a reactor execution.

Refresh the robot state from the runtime.

Types

t()

@type t() :: %BB.Reactor.Context{
  execution_id: reference(),
  robot: BB.Robot.t(),
  robot_module: module(),
  robot_state: BB.Robot.Runtime.robot_state()
}

Functions

new(robot_module)

@spec new(module()) :: t()

Create a new BB context for a reactor execution.

Arguments

  • robot_module - The robot module to use for this execution

Examples

iex> BB.Reactor.Context.new(MyRobot)
%BB.Reactor.Context{
  robot_module: MyRobot,
  robot: %BB.Robot{...},
  robot_state: :idle,
  execution_id: #Reference<...>
}

refresh_state(context)

@spec refresh_state(t()) :: t()

Refresh the robot state from the runtime.

Call this to get the current robot state if it may have changed.