From d198c45845014cda23c27887f368831f8440e030 Mon Sep 17 00:00:00 2001 From: Laurens Valk Date: Tue, 2 Jul 2019 14:07:36 +0200 Subject: [PATCH] api: add heading for devices with a gyro --- pybricks/_common.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/pybricks/_common.py b/pybricks/_common.py index d8ce1fe..82f212f 100644 --- a/pybricks/_common.py +++ b/pybricks/_common.py @@ -655,7 +655,7 @@ class Accelerometer(): along the y-axis. Returns: - (:ref:`angle`, :ref:`angle`). Pitch and roll angles. + (:ref:`angle`, :ref:`angle`): Pitch and roll angles. """ pass @@ -685,6 +685,31 @@ class Accelerometer(): pass +class IMU(Accelerometer): + + def heading(self): + """Get the heading angle relative to the starting orientation. It is a + a positive rotation around the :ref:`z-axis in the robot + frame `, prior to applying any tilt rotation. + + For a vehicle viewed from the top, this means that + a positive heading value corresponds to a counterclockwise rotation. + + Returns: + :ref:`angle`: Heading angle relative to starting orientation. + + """ + pass + + def reset_heading(self, angle): + """Reset the accumulated heading angle of the robot. + + Arguments: + angle (:ref:`angle`): Value to which the heading should be reset. + """ + pass + + # Workaround for documenting instance attributes such as of the # the ColorDistanceSensor. Autodoc does not pick those up, so instantiate them # here. Modules can just import them as needed.