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

View Source

Shared utilities for robot validation and initial state fetching.

Used by all BB.Kino widgets to validate robot modules and fetch initial state data.

Summary

Functions

Fetches the initial state for a robot.

Fetches just the safety-related state for a robot.

Validates that the given module is a BB robot.

Functions

fetch_initial_state(robot_module)

@spec fetch_initial_state(module()) :: map()

Fetches the initial state for a robot.

Returns a map containing:

  • :robot_struct - the robot topology struct
  • :positions - current joint positions
  • :velocities - current joint velocities
  • :state - runtime state (:disarmed, :idle, :executing, :error, :disarming)
  • :armed - boolean indicating if robot is armed

fetch_safety_state(robot_module)

@spec fetch_safety_state(module()) :: map()

Fetches just the safety-related state for a robot.

Returns a map containing:

  • :state - safety state (:disarmed, :armed, :disarming, :error)
  • :armed - boolean
  • :in_error - boolean

validate_robot(robot_module)

@spec validate_robot(module()) :: {:ok, module()} | {:error, String.t()}

Validates that the given module is a BB robot.

Returns {:ok, robot_module} if valid, or {:error, reason} if not.