Metadata-Version: 2.1
Name: aiorobot
Version: 0.3.0
Summary: asyncio interface for iRobot Root
Home-page: https://github.com/entwanne/aiorobot
Author: entwanne
Author-email: antoine.rozo@gmail.com
License: MIT
Platform: UNKNOWN
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Description-Content-Type: text/markdown
Requires-Dist: bleak
Requires-Dist: crc8
Provides-Extra: build
Requires-Dist: setuptools ; extra == 'build'
Requires-Dist: wheel ; extra == 'build'
Requires-Dist: twine ; extra == 'build'

# Root robot

Python async API for iRobot Root (coding robot) over bluetooth-low-energy protocol.

Protocol specifications from <https://github.com/RootRobotics/root-robot-ble-protocol>.

## Installation

Install the `aiorobot` package from PyPI with `pip`.

```sh
pip install aiorobot
```

## Quickstart

To simply run the robot, use the `run` function of `aiorobot` module.
It takes coroutine callbacks for different root robot events.

```python
from aiorobot import run

async def main(robot):
    for i in range(4):
        await robot.led.on((0, i * 80, 100))
        await robot.motor.drive(150)
        await robot.motor.rotate(900)
    await robot.disconnect()

run(started=main)
```

This will search for a root robot in bluetooth devices, connect to it and call the `main` coroutine when the root is ready.
So make sure you have bluetooth enabled and working on your computer.

Accepted keyword-arguments of `run` function are event names listed in [aiorobot/events.py](https://github.com/entwanne/aiorobot/blob/master/aiorobot/events.py).

You can also directly get a robot and interact with it with `get_robot` function that you can use as an async context-manager to start the connection.

```python
import asyncio
from aiorobot import get_robot

async def main():
    async with get_robot() as robot:
        await robot.motor.drive(150)

asyncio.run(main())
```

Then you will need to handle events yourself (iterate over `robot.events` or call `robots.events.process()`) to get updates from the robot.

See more code examples in [aiorobot/examples](https://github.com/entwanne/aiorobot/tree/master/aiorobot/examples) directory.


