mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-09-12 01:24:17 +00:00
pybricks.common.Motor: Add done, stalled, load.
These used to be implemented as part of the Control object, but now they are available directly on the motor. This way they: - Also give useful values when control is passive, via dc(). - Can be supported on Move Hub - Give useful values for drive bases (see next commits). Fixes https://github.com/pybricks/pybricks-api/issues/115
This commit is contained in:
+30
-34
@@ -299,40 +299,6 @@ class Control:
|
||||
minimum ``speed`` before we say it is stalled.
|
||||
"""
|
||||
|
||||
def stalled(self) -> bool:
|
||||
"""stalled() -> bool
|
||||
|
||||
Checks if the controller is currently stalled.
|
||||
|
||||
A controller is stalled when it cannot reach the target speed or
|
||||
position, even with the maximum actuation signal.
|
||||
|
||||
Returns:
|
||||
``True`` if the controller is stalled, ``False`` if not.
|
||||
"""
|
||||
|
||||
def done(self) -> bool:
|
||||
"""done() -> bool
|
||||
|
||||
Checks if an ongoing command or maneuver is done.
|
||||
|
||||
Returns:
|
||||
``True`` if the command is done, ``False`` if not.
|
||||
"""
|
||||
|
||||
def load(self) -> int:
|
||||
"""load() -> int: mNm
|
||||
|
||||
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.
|
||||
|
||||
Returns:
|
||||
The load torque. It returns 0 if control is not active.
|
||||
"""
|
||||
|
||||
|
||||
class Motor(DCMotor):
|
||||
"""Generic class to control motors with built-in rotation sensors."""
|
||||
@@ -394,6 +360,27 @@ class Motor(DCMotor):
|
||||
|
||||
"""
|
||||
|
||||
def stalled(self) -> bool:
|
||||
"""stalled() -> bool
|
||||
|
||||
Checks if the motor is currently stalled.
|
||||
|
||||
It is stalled when it cannot reach the target speed or position, even
|
||||
with the maximum actuation signal.
|
||||
|
||||
Returns:
|
||||
``True`` if the motor is stalled, ``False`` if not.
|
||||
"""
|
||||
|
||||
def load(self) -> int:
|
||||
"""load() -> int: mNm
|
||||
|
||||
Estimates the load that holds back the motor when it tries to move.
|
||||
|
||||
Returns:
|
||||
The load torque.
|
||||
"""
|
||||
|
||||
def reset_angle(self, angle: Optional[Number]) -> None:
|
||||
"""
|
||||
reset_angle(angle)
|
||||
@@ -505,6 +492,15 @@ class Motor(DCMotor):
|
||||
Angle at which the motor becomes stalled.
|
||||
"""
|
||||
|
||||
def done(self) -> bool:
|
||||
"""done() -> bool
|
||||
|
||||
Checks if an ongoing command or maneuver is done.
|
||||
|
||||
Returns:
|
||||
``True`` if the command is done, ``False`` if not.
|
||||
"""
|
||||
|
||||
def track_target(self, target_angle: Number) -> None:
|
||||
"""track_target(target_angle)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user