step.logic.loop =============== .. py:module:: step.logic.loop Classes ------- .. autoapisummary:: step.logic.loop.LoopForever step.logic.loop.LoopFor Module Contents --------------- .. py:class:: LoopForever(step: step.StepProtocol) Bases: :py:obj:`step.Step` Repeat a step indefinitely until externally cancelled. Wraps the given step in an infinite loop. Each iteration awaits the child step to completion before starting the next. The loop only terminates when the enclosing context cancels it (e.g. via ``do_while_active`` or ``do_until_checkpoint``). :param step: The step to execute repeatedly. Must satisfy ``StepProtocol``. Example:: from raccoon.step.logic import loop_forever from raccoon.step.timing import do_until_checkpoint # Continuously toggle a motor on and off until T=30s toggle = seq([ motor_power(robot.motor(0), 100), wait(0.5), motor_off(robot.motor(0)), wait(0.5), ]) do_until_checkpoint(30.0, loop_forever(toggle)) .. py:attribute:: step .. py:method:: collected_resources() -> frozenset[str] Return all resources this step *and its children* require. Used by ``validate_no_overlap`` for static conflict detection at construction time. Leaf steps don't need to override this — the default delegates to ``required_resources``. Composite steps override to union their children's collected resources. .. py:class:: LoopFor(step: step.StepProtocol, iterations: int) Bases: :py:obj:`step.Step` Repeat a step a fixed number of times. Wraps the given step in a counted loop. Each iteration awaits the child step to completion before starting the next. After all iterations complete, the step finishes normally. :param step: The step to execute repeatedly. Must satisfy ``StepProtocol``. :param iterations: Number of times to run the step. Must be a positive integer. Example:: from raccoon.step.logic import loop_for # Drive forward and back 3 times loop_for(seq([drive_forward(20), drive_backward(20)]), iterations=3) .. py:attribute:: step .. py:attribute:: iterations .. py:method:: collected_resources() -> frozenset[str] Return all resources this step *and its children* require. Used by ``validate_no_overlap`` for static conflict detection at construction time. Leaf steps don't need to override this — the default delegates to ``required_resources``. Composite steps override to union their children's collected resources.