automation
Automator ¶
Automator(
steerer: Steerer | None,
*,
default_automation: Callable | None = None,
on_interrupt: Callable | None = None,
notify: bool = True
)
An automator allows running automations, i.e. coroutines that can be paused and resumed.
See Click-and-drive for a simple example of an automation.
steerer: If provided, manually steering the robot will pause a currently running automation.
default_automation: If provided, it allows the automator to start a new automation without passing an automation (e.g. via an "Play"-button like offered by the automation controls). The passed function should return a new coroutine on every call (see Play-pause-stop example).
on_interrupt: Optional callback that will be called when an automation pauses or stops (the cause is provided as string parameter).
notify: If True, the automator will send notifications when an automation starts, pauses, resumes, stops or fails.
abort ¶
abort(because: str) -> None
Stops the current automation because of a failure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
because
|
str
|
the reason for aborting the automation |
required |
disable ¶
disable(because: str) -> None
Disables the automator.
No automations can be started while the automator is disabled. If an automation is running or paused it will be stopped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
because
|
str
|
the reason for disabling the automator |
required |
enable ¶
enable() -> None
Enables the automator.
It is enabled by default.
It can be disabled by calling disable().
pause ¶
pause(because: str) -> None
Pauses the current automation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
because
|
str
|
the reason for pausing the automation |
required |
set_default_automation ¶
set_default_automation(
default_automation: Callable | None,
) -> None
Sets the default automation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
default_automation
|
Callable | None
|
the default automation to use |
required |
start ¶
start(
coro: Coroutine | None = None, *, paused: bool = False
) -> None
Starts a new automation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coro
|
Coroutine | None
|
the coroutine to start, if None the default automation will be used |
None
|
paused
|
bool
|
whether to start the automation paused |
False
|
stop ¶
stop(because: str) -> None
Stops the current automation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
because
|
str
|
the reason for stopping the automation |
required |
Events¶
| Name | Description |
|---|---|
| AUTOMATION_STARTED | an automation has been started |
| AUTOMATION_PAUSED | an automation has been paused (string argument: description of the cause) |
| AUTOMATION_RESUMED | an automation has been resumed |
| AUTOMATION_STOPPED | an automation has been stopped (string argument: description of the cause) |
| AUTOMATION_FAILED | an automation has failed to complete (string argument: description of the cause) |
| AUTOMATION_COMPLETED | an automation has been completed |
app_controls ¶
app_controls(
robot_brain: RobotBrain,
automator: Automator,
bluetooth: BluetoothHardware,
)
The AppControls module enables the connection with a mobile-app-based user interface.
It uses a given RobotBrain object to communicate with Lizard running on a microcontroller and in turn being connected to a mobile app via Bluetooth Low Energy. It displays buttons to control a given automator.
Events¶
| Name | Description |
|---|---|
| APP_CONNECTED | an app connected via bluetooth (used to refresh information or similar) |
automation_controls ¶
automation_controls(automator: Automator)
This UI element contains start/stop/pause/resume buttons for controlling a given automator.
See Play-pause-stop for a simple example of the automation controls.
parallelize ¶
parallelize ¶
parallelize(
*coros: Coroutine,
return_when_first_completed: bool = False
)
Parallelize multiple coroutines.
This class allows to combine multiple coroutines into one that can be passed to the
automator <https://rosys.io/reference/rosys/automation/#rosys.automation.Automator>__
to run them in parallel.
Note that parallelize will be uninterruptible if one of its coroutines is marked with @rosys.automation.uninterruptible.