Ozobot actor API package providing an alternative way for controling multiple bots
Project description
ozobot-actors
Library that enables to control multiple Ozobot device using a globally defined functions. It mirrors the interface of libraries implementing object oriented control of the individual robots. The library is primarily intended to be used by the Python code generated from Blockly programs, as its semantics follows the actor based use by the Ozobot Editor, but can be used even in projects written from scratch.
See the monorepo for more details.
Installation
The library requires you to list all the robots to be supported, so for example to install Evo support, run
pip install ozobot-actors[evo], to install both Ari and Evo support, run pip install ozobot-actors[ari,evo].
The library currently supports:
Usage
The library defines global functions that can control any robot supporting that specific functionality. Targeting a specific robot can be done by using a context manager. When an API function is called, the context is searched for available robot and the function is executed with the first matching robot. The robot selection follows a few simple rules:
- Actors need to be registered in the dispatcher with
dispatcher.add() - Actors are put onto the stack as they are registered
- Selecting an actor with
dispatcher.actor()puts it on top of the current stack - Masking an actor with
dispatcher.mask()removes it from the current stack - Stack is searched from the top
- First robot having the required functionality is used, leaving the stack untouched
import asyncio
from ozobot import actors
from ozobot.actors.linefollower import move
from ozobot.actors.userio import user_io_alert
from ozobot.ari import AriHandle
from ozobot.evo import EvoHandle
dispatcher = actors.new_actor_dispatcher()
async def main() -> None:
async with EvoHandle(name="OzoEvo-1234abcd") as e1, EvoHandle(name="Ari-ABCD") as a1:
dispatcher.add("Evo_1", e1)
dispatcher.add("Ari_1", a1)
with dispatcher.actor("Ari_1"): # this puts Ari onto the default stack
await move(100, 50) # moves Ari
await user_io_alert("Hello from Ari!") # displays message on Ari
with dispatcher.actor("Evo_1"): # this puts Evo on top of Ari
await move(100, 50) # moves Evo
await user_io_alert("Hello again from Ari!") # Ari shows the message, because Evo does not support `user_io_alert`
# stepping out of the context manager block removes Evo from the top of the stack
await move(-100, 50) # moves Ari again
if __name__ == "__main__":
asyncio.run(main())
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ozobot_actors-0.3.2.tar.gz.
File metadata
- Download URL: ozobot_actors-0.3.2.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5eabb62bd9ab393463c149de055f0bd4e716e8c98a3c575d8c9283375a1553de
|
|
| MD5 |
3c3c1dcfdc4f4267e3a7969a23a0627d
|
|
| BLAKE2b-256 |
51ce8349ee6971993b8d45980e6192cbf61aae792beb8658f088f4d05179cd6e
|
Provenance
The following attestation bundles were made for ozobot_actors-0.3.2.tar.gz:
Publisher:
publish.yml on ozobot/python-libraries
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ozobot_actors-0.3.2.tar.gz -
Subject digest:
5eabb62bd9ab393463c149de055f0bd4e716e8c98a3c575d8c9283375a1553de - Sigstore transparency entry: 1400825408
- Sigstore integration time:
-
Permalink:
ozobot/python-libraries@b164fef72fe306687ea2677b7fb3a10f848e80c6 -
Branch / Tag:
refs/tags/ozobot-actors-v0.3.2 - Owner: https://github.com/ozobot
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b164fef72fe306687ea2677b7fb3a10f848e80c6 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ozobot_actors-0.3.2-py3-none-any.whl.
File metadata
- Download URL: ozobot_actors-0.3.2-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83d66213b259a94154766300c491189738265beb23a9069028adc3115bbbbba5
|
|
| MD5 |
bf3a3d44230a26f1a66fd7c904d36910
|
|
| BLAKE2b-256 |
f7bf0219e19e0a296732f718cfb624146fa5f7ddf2fcedd8b0bf7c9f1880389d
|
Provenance
The following attestation bundles were made for ozobot_actors-0.3.2-py3-none-any.whl:
Publisher:
publish.yml on ozobot/python-libraries
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ozobot_actors-0.3.2-py3-none-any.whl -
Subject digest:
83d66213b259a94154766300c491189738265beb23a9069028adc3115bbbbba5 - Sigstore transparency entry: 1400825507
- Sigstore integration time:
-
Permalink:
ozobot/python-libraries@b164fef72fe306687ea2677b7fb3a10f848e80c6 -
Branch / Tag:
refs/tags/ozobot-actors-v0.3.2 - Owner: https://github.com/ozobot
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b164fef72fe306687ea2677b7fb3a10f848e80c6 -
Trigger Event:
push
-
Statement type: