step.logic.defer_dsl

Auto-generated step builders and DSL functions — DO NOT EDIT.

Source: defer.py

Classes

DeferBuilder

Builder for Defer. Auto-generated — do not edit.

RunBuilder

Builder for Run. Auto-generated — do not edit.

Functions

defer([factory])

Defer step construction until execution time.

run([action])

Execute an arbitrary callable as a step.

Module Contents

class step.logic.defer_dsl.DeferBuilder

Bases: raccoon.step.step_builder.StepBuilder

Builder for Defer. Auto-generated — do not edit.

factory(value: Callable[[GenericRobot], step.Step])
step.logic.defer_dsl.defer(factory: Callable[[GenericRobot], step.Step] = _UNSET)

Defer step construction until execution time.

Wraps a factory callable that receives the robot instance and returns a step. The factory is called when the Defer step executes, not when the step tree is built. This allows steps to depend on runtime values such as sensor readings, odometry data, or results computed by earlier steps in a sequence.

Parameters:

factory – A callable that takes a GenericRobot and returns a Step to execute. Called exactly once when the deferred step runs.

Returns:

A DeferBuilder (chainable via .factory(), .on_anomaly(), .skip_timing()).

Example:

from raccoon.step.logic import defer

# Turn by an angle computed from a sensor reading at runtime
seq([
    scan_step,
    defer(lambda robot: turn_left(
        compute_angle_from_scan(robot)
    )),
])
class step.logic.defer_dsl.RunBuilder

Bases: raccoon.step.step_builder.StepBuilder

Builder for Run. Auto-generated — do not edit.

action(value: Callable[[GenericRobot], None | Awaitable[None]])
step.logic.defer_dsl.run(action: Callable[[GenericRobot], None | Awaitable[None]] = _UNSET)

Execute an arbitrary callable as a step.

Wraps a sync or async callable so it can be used inline in a step sequence. This is useful for one-off side effects, logging, variable assignments, or any imperative code that does not warrant its own step class. The callable receives the robot instance and its return value is ignored (unless it returns an awaitable, which is then awaited).

Parameters:

action – A callable that takes a GenericRobot and optionally returns an awaitable. Sync and async callables are both supported.

Returns:

A RunBuilder (chainable via .action(), .on_anomaly(), .skip_timing()).

Example:

from raccoon.step.logic import run

# Log the current heading between two drive steps
seq([
    drive_forward(25),
    run(lambda robot: print(f"Heading: {robot.odometry.get_heading()}")),
    drive_forward(25),
])