step.logic.loop¶
Classes¶
Repeat a step indefinitely until externally cancelled. |
|
Repeat a step a fixed number of times. |
Module Contents¶
- class step.logic.loop.LoopForever(step: step.StepProtocol)¶
Bases:
step.StepRepeat 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_activeordo_until_checkpoint).- Parameters:
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))
- step¶
- collected_resources() frozenset[str]¶
Return all resources this step and its children require.
Used by
validate_no_overlapfor static conflict detection at construction time. Leaf steps don’t need to override this — the default delegates torequired_resources. Composite steps override to union their children’s collected resources.
- class step.logic.loop.LoopFor(step: step.StepProtocol, iterations: int)¶
Bases:
step.StepRepeat 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.
- Parameters:
step – The step to execute repeatedly. Must satisfy
StepProtocol.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)
- step¶
- iterations¶
- collected_resources() frozenset[str]¶
Return all resources this step and its children require.
Used by
validate_no_overlapfor static conflict detection at construction time. Leaf steps don’t need to override this — the default delegates torequired_resources. Composite steps override to union their children’s collected resources.