Plugin & Action Configuration Reference

Copy Markdown View Source

BB.Jido.Plugin.Robot

Attach to an agent's plugins: list with a per-agent config map.

use Jido.Agent,
  name: "my_robot",
  plugins: [{BB.Jido.Plugin.Robot, %{robot: MyRobot}}]

Config

Config is validated against the plugin's config_schema when the agent is defined — a missing :robot, a mistyped value, or an unrecognised key (e.g. a typo'd gated_action:) raises at compile time rather than surfacing later at runtime.

KeyTypeRequiredDefaultDescription
:robotmodule()yesThe Beam Bots robot module
:topics[[atom()]]no[[:state_machine]]PubSub paths the bridge subscribes to
:message_types[module()]no[]Payload modules to filter on ([] = no filter)
:throttle_mspos_integer()nonilMinimum interval between same-type signals
:gated_actions[module()]no[]Actions refused before execution unless BB.Safety.state/1 is :armed

With gated_actions: [BB.Jido.Action.Command, BB.Jido.Action.Reactor], routed signals resolving to those actions fail closed with {:error, {:safety_not_armed, state}} via the plugin's prepare_action/3 hook. The gate authorises the configured robot, so a gated action whose params name a different robot is rejected with {:error, {:robot_mismatch, %{configured: ..., requested: ..., action: ...}}} rather than authorised against the wrong robot's safety state. The gate covers signal-routed execution only — direct run/2 calls bypass it, so keep BB.Jido.Action.SafetyAware on actions that must be guarded everywhere.

State

The plugin owns the agent's :robot state slice:

FieldTypeInitialDescription
:robotmodule()the configured robotMirror of config[:robot] for convenience
:safety_stateatom():unknownCached safety state (:armed, :disarmed, :disarming, or :error); updated by the routed BB.Jido.Action.UpdateSafetyState when a bb.state.transition signal carries a safety transition
:last_safety_errorBB.Safety.HardwareError.t() | nilnilLast hardware error; updated by the routed BB.Jido.Action.RecordSafetyError when the [:safety, :error] topic is bridged
:last_joint_statemap()%{}Last read %{positions: ..., velocities: ...}; updated whenever BB.Jido.Action.GetJointState runs

Built-in actions

ActionDefault routePurpose
BB.Jido.Action.Commandbb.command.executeRun a BB command via BB.Command.await/2
BB.Jido.Action.Reactorbb.reactor.runRun a bb_reactor workflow with context.private.bb_robot set
BB.Jido.Action.WaitForStatebb.state.waitBlock until robot reaches a target state
BB.Jido.Action.GetJointState(none — call directly)Read positions/velocities from BB.Robot.Runtime; caches them at :last_joint_state
BB.Jido.Action.UpdateSafetyStatebb.state.transitionCache safety transitions at :safety_state
BB.Jido.Action.RecordSafetyErrorbb.safety.errorRecord hardware errors at :last_safety_error

Child processes

The plugin's child_spec/1 returns one supervised child:

ChildType:idRestart
BB.Jido.PubSubBridge:worker{BB.Jido.Plugin.Robot, :pub_sub_bridge, robot}:transient

BB.Jido.PubSubBridge options

The bridge is mounted by the plugin, but you can also start it directly under a different supervisor if you want PubSub-to-Signal forwarding without an agent.

{:ok, bridge} =
  BB.Jido.PubSubBridge.start_link(
    robot: MyRobot,
    agent: agent_pid_or_name,
    topics: [[:state_machine]]
  )
OptionTypeRequiredDefaultDescription
:robotmodule()yesRobot module to subscribe against
:agentGenServer.server()yesWhere to cast signals (pid, registered name, via-tuple)
:topics[[atom()]]no[[:state_machine]]PubSub paths
:message_types[module()]no[]Payload filter
:throttle_mspos_integer()nonilSame-type throttle in ms
:nameGenServer.name()noStandard GenServer.start_link option

All standard GenServer.start_link options (:timeout, :debug, :spawn_opt, :hibernate_after) are also accepted.

Action schemas

Each action's :schema is documented below using [type:, required:, default:] notation matching the NimbleOptions format that Jido.Action accepts.

BB.Jido.Action.Command

ParamTypeRequiredDefault
:robot:atom
:command:atom
:goal:map%{}
:timeout:pos_integer30_000

BB.Jido.Action.Reactor

ParamTypeRequiredDefault
:robot:atom
:reactor:atom
:inputs:map%{}

BB.Jido.Action.WaitForState

ParamTypeRequiredDefault
:robot:atom
:target:atom
:timeout:pos_integer30_000

BB.Jido.Action.GetJointState

ParamTypeRequiredDefault
:robot:atom