diff --git a/doc/api/robotics.rst b/doc/api/robotics.rst index fbc4fbb..b939a84 100644 --- a/doc/api/robotics.rst +++ b/doc/api/robotics.rst @@ -8,8 +8,18 @@ .. autoclass:: pybricks.robotics.DriveBase :no-members: - .. automethod:: pybricks.robotics.DriveBase.drive + .. rubric:: Manual drive control - .. automethod:: pybricks.robotics.DriveBase.drive_time + .. automethod:: pybricks.robotics.DriveBase.start .. automethod:: pybricks.robotics.DriveBase.stop + + .. rubric:: Automatic drive control + + .. automethod:: pybricks.robotics.DriveBase.straight + + .. automethod:: pybricks.robotics.DriveBase.turn + + .. automethod:: pybricks.robotics.DriveBase.arc + + .. automethod:: pybricks.robotics.DriveBase.set_drive_settings diff --git a/pybricks/robotics.py b/pybricks/robotics.py index 48ed4ba..10c4a5a 100644 --- a/pybricks/robotics.py +++ b/pybricks/robotics.py @@ -21,25 +21,13 @@ class DriveBase(): """ - def drive(self, speed, steering): + def start(self, drive_speed, turn_rate): """Start driving at the specified speed and turnrate, both measured at the center point between the wheels of the robot. Arguments: - speed (:ref:`linspeed`): Forward speed of the robot. - steering (:ref:`speed`): Turn rate of the robot. - """ - pass - - def drive_time(self, speed, steering, time): - """Drive at the specified speed and turnrate for a given amount of - time, and then stop. - - Arguments: - speed (:ref:`linspeed`): Forward speed of the robot. - steering (:ref:`speed`): Turn rate of the robot. - time (:ref:`time`): Duration of the maneuver. - + drive_speed (:ref:`linspeed`): Forward speed of the robot. + turn_rate (:ref:`speed`): Turn rate of the robot. """ pass @@ -53,3 +41,50 @@ class DriveBase(): :class:`Stop.COAST <.parameters.Stop>`). """ pass + + def set_drive_settings(self, drive_speed, drive_acceleration, turn_rate, + turn_acceleration, stop_type): + """Configure the behavior of the :meth:`.straight`, :meth:`.turn`, + and :meth:`.arc` methods. + + Arguments: + drive_speed (:ref:`linspeed`): Forward speed of the robot. + drive_acceleration (:ref:`linacceleration`): Forward acceleration + of the robot. + turn_rate (:ref:`speed`): Turn rate of the robot. Applies + to :meth:`.turn` method only. + turn_acceleration (:ref:`acceleration`): Angular acceleration of + the robot. Applies to :meth:`.turn` method only. + stop_type (Stop): Whether to coast, brake, or hold after + a given command is complete. + """ + pass + + def straight(self, distance): + """Drive straight for a given distance. + + Arguments: + distance (:ref:`distance`): Distance to travel. + """ + pass + + def turn(self, angle): + """Turn in place by a given angle. + + Arguments: + angle (:ref:`angle`): Angle of the turn. + """ + pass + + def arc(self, radius, angle): + """Drive along an arc with a given radius by a given angle. An arc is + a segment of a circle. + + A positive radius value makes your robot go right. A negative radius + makes it go left. + + Arguments: + radius (:ref:`dimension`): Radius of the circle. + angle (:ref:`angle`): Angle traversed along the circle. + """ + pass