step.logic.defer_dsl ==================== .. py:module:: step.logic.defer_dsl .. autoapi-nested-parse:: Auto-generated step builders and DSL functions — DO NOT EDIT. Source: defer.py Classes ------- .. autoapisummary:: step.logic.defer_dsl.DeferBuilder step.logic.defer_dsl.RunBuilder Functions --------- .. autoapisummary:: step.logic.defer_dsl.defer step.logic.defer_dsl.run Module Contents --------------- .. py:class:: DeferBuilder Bases: :py:obj:`raccoon.step.step_builder.StepBuilder` Builder for Defer. Auto-generated — do not edit. .. py:method:: factory(value: Callable[[GenericRobot], step.Step]) .. py:function:: 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. :param 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) )), ]) .. py:class:: RunBuilder Bases: :py:obj:`raccoon.step.step_builder.StepBuilder` Builder for Run. Auto-generated — do not edit. .. py:method:: action(value: Callable[[GenericRobot], Union[None, Awaitable[None]]]) .. py:function:: run(action: Callable[[GenericRobot], Union[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). :param 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), ])