BB.Reactor.Step.Command (bb_reactor v0.2.3)

Copy Markdown View Source

Reactor step that executes a BB command.

This step wraps BB.Command execution with process monitoring to detect safety disarm events. When a command stops due to safety state change, the step returns {:halt, :safety_disarmed} to stop the reactor.

Options

  • :command - (required) The command name as an atom (e.g., :move_to)
  • :timeout - Timeout in milliseconds (default: :infinity)
  • :compensate - Command to run during undo (e.g., :return_home)

Result

Returns a BB.Reactor.Step.Command.Result struct containing:

  • :command - The command name that was executed
  • :goal - The goal map passed to the command
  • :outcome - The result returned by the command
  • :robot_module - The robot module used

Compensation (Undo)

If :compensate is specified and the reactor needs to roll back this step, the compensation command is invoked with %{original: result} as its goal, giving it access to the original command, goal, and outcome.

Safety Handling

The step monitors the command process. If the command exits with :disarmed reason (due to safety state change), the step returns {:halt, :safety_disarmed} which stops the reactor execution.