mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-09-12 17:46:19 +00:00
47 lines
1.2 KiB
ReStructuredText
47 lines
1.2 KiB
ReStructuredText
:mod:`robotics` -- Robotics module
|
|
===========================================
|
|
|
|
.. automodule:: pybricks.robotics
|
|
:no-members:
|
|
|
|
|
|
.. autoclass:: pybricks.robotics.DriveBase
|
|
:no-members:
|
|
|
|
Example::
|
|
|
|
# Initialize two motors and a drive base
|
|
left = Motor(Port.B)
|
|
right = Motor(Port.C)
|
|
robot = DriveBase(left, right, 56, 114)
|
|
|
|
.. automethod:: pybricks.robotics.DriveBase.drive
|
|
|
|
Example::
|
|
|
|
# Initialize two motors and a drive base
|
|
left = Motor(Port.B)
|
|
right = Motor(Port.C)
|
|
robot = DriveBase(left, right, 56, 114)
|
|
|
|
# Initialize a sensor
|
|
sensor = UltrasonicSensor(Port.S4)
|
|
|
|
# Drive forward until an object is detected
|
|
robot.drive(100, 0)
|
|
while sensor.distance() > 500:
|
|
wait(10)
|
|
robot.stop()
|
|
|
|
.. automethod:: pybricks.robotics.DriveBase.drive_time
|
|
|
|
Example::
|
|
|
|
# Drive forward at 100 mm/s for two seconds
|
|
robot.drive_time(100, 0, 2000)
|
|
|
|
# Turn at 45 deg/s for three seconds
|
|
robot.drive_time(0, 45, 3000)
|
|
|
|
.. automethod:: pybricks.robotics.DriveBase.stop
|