The AsyncLinkbot Class¶
The linkbot3.AsyncLinkbot class is an asynchronous handle to a remote Linkbot.
It is meant to be used in an asyncio coroutine. The class itself
contains several child classes that represent various peripherals on the
Linkbot, such as the motors, buttons, accelerometer, and LED.
Here is a small piece of sample code showing how to move a Linkbot’s motors
using the asynchronous linkbot3.AsyncLinkbot object.
import asyncio
import linkbot
async def task():
# My Linkbot's ID is DGKR.
l = await linkbot.AsyncLinkbot.create('DGKR')
# Move the Linkbot's first motor 90 degrees positive from its current
# location and third motor -90 degrees from its current location.
await l.motors.move([90,0,-90], relative=True)
# Wait for the motion to finish on all motors
fut = await l.motors.move_wait()
await fut
loop = asyncio.get_event_loop()
loop.run_until_complete(task())
loop.close()
AsyncLinkbot API Documentation¶
-
class
linkbot3.AsyncLinkbot¶ -
accelerometer¶ The Linkbot accelerometer.
-
battery¶ The Linkbot battery.
Access the Linkbot’s battery voltage. See
linkbot3.async.peripherals.Battery
Access to the Linkbot’s buttons.
-
buzzer¶ Access to the Linkbot’s buzzer.
-
classmethod
create(serial_id)¶ Create a new asynchronous Linkbot object.
Parameters: serial_id (str) – The robot to connect to Returns: AsyncLinkbot() object.
-
form_factor()¶ Get the robot’s self-identified form factor
Returns: asyncio.Future with result int Return type: asyncio.Future with result type: int
-
led¶ The Linkbot multicolor LED.
-
motors¶ The motors of the Linkbot.
See
linkbot3.async.peripherals.Motors. To access individual motors, you may do:AsyncLinkbot.motors[0].is_moving()or similar. Also see
linkbot3.async.peripherals.Motor
-
version()¶ Get the firmware version
Returns: asyncio.Future with result (major, minor, patch) Return type: asyncio.Future with result type: (int, int, int)
-