Skip to content

automation

app_controls

app_controls(robot_brain: RobotBrain, automator: Automator)

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.

notify async

notify(msg: str) -> None

show notification as Snackbar message on mobile device

set_info async

set_info(msg: str) -> None

replace constantly shown info text on mobile device

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.

Automator

Automator(
    steerer: Steerer | None,
    *,
    default_automation: Callable | None = None,
    on_interrupt: Callable | None = None
)

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

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. You need to provide a cause which will be used as notification message.

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.

You need to provide a cause which will be used as notification message.

resume

resume() -> None

Resumes the current automation.

set_default_automation

set_default_automation(
    default_automation: Callable | None,
) -> None

Sets the default automation.

You can pass a function that returns a new coroutine on every call.

start

start(
    coro: Coroutine | None = None, *, paused: bool = False
) -> None

Starts a new automation.

You can pass any coroutine. The automator will make sure it can be paused, resumed and stopped.

stop

stop(because: str) -> None

Stops the current automation.

You need to provide a cause which will be used as notification message.

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

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.