step.logic.loop_dsl

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

Source: loop.py

Classes

LoopForeverBuilder

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

LoopForBuilder

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

Functions

loop_forever([step])

Repeat a step indefinitely until externally cancelled.

loop_for([step, iterations])

Repeat a step a fixed number of times.

Module Contents

class step.logic.loop_dsl.LoopForeverBuilder

Bases: raccoon.step.step_builder.StepBuilder

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

step(value: step.StepProtocol)
step.logic.loop_dsl.loop_forever(step: step.StepProtocol = _UNSET)

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).

Parameters:

step – The step to execute repeatedly. Must satisfy StepProtocol.

Returns:

A LoopForeverBuilder (chainable via .step(), .on_anomaly(), .skip_timing()).

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))
class step.logic.loop_dsl.LoopForBuilder

Bases: raccoon.step.step_builder.StepBuilder

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

step(value: step.StepProtocol)
iterations(value: int)
step.logic.loop_dsl.loop_for(step: step.StepProtocol = _UNSET, iterations: int = _UNSET)

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.

Parameters:
  • step – The step to execute repeatedly. Must satisfy StepProtocol.

  • iterations – Number of times to run the step. Must be a positive integer.

Returns:

A LoopForBuilder (chainable via .step(), .iterations(), .on_anomaly(), .skip_timing()).

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)