step.logic.do_while_dsl¶
Auto-generated step builders and DSL functions — DO NOT EDIT.
Source: do_while.py
Classes¶
Builder for DoWhileActive. Auto-generated — do not edit. |
Functions¶
|
Run a task concurrently with a reference step, cancelling the task when the reference finishes. |
Module Contents¶
- class step.logic.do_while_dsl.DoWhileActiveBuilder¶
Bases:
raccoon.step.step_builder.StepBuilderBuilder for DoWhileActive. Auto-generated — do not edit.
- reference_step(value: step.Step)¶
- task(value: step.Step)¶
- step.logic.do_while_dsl.do_while_active(reference_step: step.Step = _UNSET, task: step.Step = _UNSET)¶
Run a task concurrently with a reference step, cancelling the task when the reference finishes.
Both steps start executing at the same time. When
reference_stepcompletes (either normally or via exception),taskis immediately cancelled. This is useful for running a background activity (e.g. sensor polling, motor oscillation) only for as long as a primary action is running.If
taskfinishes beforereference_step, the reference step continues running until it completes on its own.- Parameters:
reference_step – The primary step whose lifetime controls the task. When this step finishes,
taskis cancelled.task – The secondary step that runs concurrently and is cancelled once
reference_stepcompletes.
- Returns:
A DoWhileActiveBuilder (chainable via
.reference_step(),.task(),.on_anomaly(),.skip_timing()).
Example:
from raccoon.step.logic import do_while_active, loop_forever # Flash an LED while the robot drives forward flash_led = loop_forever(seq([ set_digital(0, True), wait(0.25), set_digital(0, False), wait(0.25), ])) do_while_active(drive_forward(50), flash_led)