The Linkbot Class¶
The linkbot3.Linkbot class is a handle to a remote Linkbot.
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.Linkbot object.
import linkbot3 as linkbot
# My Linkbot's ID is 'ZRG6'
l = linkbot.Linkbot('ZRG6')
# move forward by rotating wheels 90 degrees
l.motors.move([90, 0, -90])
# Now move back the same distance
l.motors.move([-90, 0, 90])
# Now set the motion controll to a smooth controller
for motor in l.motors:
motor.set_controller(linkbot.Motor.Controller.SMOOTH)
motor.set_accel(30)
motor.set_decel(30)
# move forward by rotating wheels 90 degrees
l.motors.move([90, 0, -90])
# Now move back the same distance
l.motors.move([-90, 0, 90])
Linkbot API Documentation¶
-
class
linkbot3.Linkbot(serial_id='LOCL')¶ -
accelerometer¶ The robot accelerometer.
-
battery¶ The robot battery.
Access to the robot’s buttons.
-
buzzer¶ Control the Linkbot’s buzzer.
-
disconnect()¶ Disconnect from the Linkbot.
-
form_factor()¶ Get the form factor of the Linkbot. See
linkbot3.FormFactor.
-
led¶ Access to the robot’s multi-color LED.
-
motors¶ The motors of the Linkbot.
See
linkbot3.peripherals.Motors. To access individual motors, you may do:Linkbot.motors[0].is_moving()
or similar. Also see
linkbot3.peripherals.Motor
-
version()¶ Get the firmware version
Return type: (int, int, int)
-