pybricks.pupdevices.Motor: Document control here.

Based on user feedback, we learned that the control attribute is used more frequently than anticipated. Therefore it makes sense to document it here, just like we do with instances of pybricks.common classes in hubs.

This makes it a bit easier to find and see how it is used, along with some of the existing examples.
This commit is contained in:
Laurens Valk
2021-07-23 15:33:18 +02:00
parent 0edddbb0c2
commit 24bba6d24c
7 changed files with 42 additions and 62 deletions
+2 -4
View File
@@ -190,10 +190,8 @@ class Control:
pass
def load(self):
"""Gets the load acting on the ``Motor`` or ``DriveBase``.
This value is determined from the feedback torque that is
needed to track the speed or position command given by the user.
"""Estimates the load based on the torque required to maintain the
specified speed or angle.
When coasting, braking, or controlling the duty cycle manually, the
load cannot be estimated in this way. Then this method returns zero.
+9 -2
View File
@@ -26,12 +26,19 @@ class DriveBase:
distance_control = _Control()
"""The traveled distance and drive speed are controlled by a PID
controller. You can use this attribute to change its settings.
See :ref:`control` for an overview of available methods."""
See the :ref:`motor control <settings>` attribute for an overview of
available methods. The ``distance_control`` attribute has the same
functionality, but the settings apply to every millimeter driven by the
drive base, instead of degrees turned by one motor."""
heading_control = _Control()
"""The robot turn angle and turn rate are controlled by a PID
controller. You can use this attribute to change its settings.
See :ref:`control` for an overview of available methods."""
See the :ref:`motor control <settings>` attribute for an overview of
available methods. The ``heading_control`` attribute has the same
functionality, but the settings apply to every degree of rotation of the
whole drive base (viewed from the top) instead of degrees turned by one
motor."""
def __init__(self, left_motor, right_motor, wheel_diameter, axle_track):
"""DriveBase(left_motor, right_motor, wheel_diameter, axle_track)