From 09d453480b69349dc9d38c72290eda43664430fa Mon Sep 17 00:00:00 2001 From: Laurens Valk Date: Thu, 2 Jan 2020 16:51:50 +0100 Subject: [PATCH] api/robotics: add DriveBase state getters --- doc/api/robotics.rst | 20 ++++++++++++++------ pybricks/robotics.py | 20 ++++++++++++++++++++ 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/doc/api/robotics.rst b/doc/api/robotics.rst index b939a84..c82953c 100644 --- a/doc/api/robotics.rst +++ b/doc/api/robotics.rst @@ -8,12 +8,6 @@ .. autoclass:: pybricks.robotics.DriveBase :no-members: - .. rubric:: Manual drive control - - .. automethod:: pybricks.robotics.DriveBase.start - - .. automethod:: pybricks.robotics.DriveBase.stop - .. rubric:: Automatic drive control .. automethod:: pybricks.robotics.DriveBase.straight @@ -23,3 +17,17 @@ .. automethod:: pybricks.robotics.DriveBase.arc .. automethod:: pybricks.robotics.DriveBase.set_drive_settings + + .. rubric:: Manual drive control + + .. automethod:: pybricks.robotics.DriveBase.start + + .. automethod:: pybricks.robotics.DriveBase.stop + + .. rubric:: Measuring + + .. automethod:: pybricks.robotics.DriveBase.distance + + .. automethod:: pybricks.robotics.DriveBase.angle + + .. automethod:: pybricks.robotics.DriveBase.reset diff --git a/pybricks/robotics.py b/pybricks/robotics.py index 10c4a5a..671a71b 100644 --- a/pybricks/robotics.py +++ b/pybricks/robotics.py @@ -42,6 +42,26 @@ class DriveBase(): """ pass + def distance(self): + """Get the estimated accumulated driven distance. + + Returns: + :ref:`distance`: Driven distance since last reset. + """ + pass + + def angle(self): + """Get the estimated accumulated rotation angle of the drivebase. + + Returns: + :ref:`angle`: Accumulated angle since last reset. + """ + pass + + def reset(self): + """Reset the accumulated driven distance and angle to 0.""" + 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`,