Skip to main content

asyncio interface for iRobot Root

Project description

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.

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.

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.

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.

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

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

aiorobot-0.3.0.tar.gz (10.9 kB view hashes)

Uploaded Source

Built Distribution

aiorobot-0.3.0-py3-none-any.whl (13.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page