Skip to content

Commit

Permalink
pybricks.parameters.Stop: Document NONE.
Browse files Browse the repository at this point in the history
Fixes #104
  • Loading branch information
laurensvalk committed Nov 28, 2022
1 parent 1d5956a commit 1ae0a90
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@

## Unreleased

### Added
- Documented ``Stop.NONE`` and ``Stop.COAST_SMART``.

### Changed
- Changed `PrimeHub.display.image()` to `PrimeHub.display.icon()` and renamed
its kwarg from `image` to `icon`.
- Improved presentation and docstrings of the ``ubuiltins`` module.

## 3.2.0b5 - 2022-11-11

Expand Down
7 changes: 5 additions & 2 deletions doc/main/parameters/stop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ Stop
.. autoattribute:: pybricks.parameters.Stop.HOLD
:annotation:

The following table shows how each stop type adds an extra level of
resistance to motion. In these examples, ``m`` is a
.. autoattribute:: pybricks.parameters.Stop.NONE
:annotation:

The following table shows how each of the basic stop types add an extra
level of resistance to motion. In these examples, ``m`` is a
:class:`Motor <pybricks.pupdevices.Motor>` and
and ``d`` is a :class:`DriveBase <pybricks.robotics.DriveBase>`. The
examples also show how running at zero speed compares to these stop types.
Expand Down
2 changes: 1 addition & 1 deletion jedi/tests/test_complete_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def _create_snippet(class_name: str) -> str:
),
pytest.param("Port", ["A", "B", "C", "D", "E", "F", "S1", "S2", "S3", "S4"]),
pytest.param("Side", ["BACK", "BOTTOM", "FRONT", "LEFT", "RIGHT", "TOP"]),
pytest.param("Stop", ["BRAKE", "COAST", "HOLD"]),
pytest.param("Stop", ["BRAKE", "COAST", "COAST_SMART", "HOLD", "NONE"]),
]


Expand Down
19 changes: 14 additions & 5 deletions src/pybricks/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,23 +152,32 @@ class Port(_PybricksEnum):


class Stop(_PybricksEnum):
"""Action after the motor stops."""
"""Action after the motor stops or reaches its target."""

COAST: Stop = 0
"""Let the motor move freely."""

COAST_SMART: Stop = 4
"""Let the motor move freely. For the next relative angle maneuver,
"""
Let the motor move freely. For the next relative angle maneuver,
take the last target angle (instead of the current angle) as the new
starting point. This reduces cumulative errors. This will apply only if the
current angle is less than twice the configured position tolerance."""
current angle is less than twice the configured position tolerance.
"""

BRAKE: Stop = 1
"""Passively resist small external forces."""

HOLD: Stop = 2
"""Keep controlling the motor to hold it at the commanded angle. This is
only available on motors with encoders."""
"""Keep controlling the motor to hold it at the commanded angle."""

NONE: Stop = 3
"""
Do not decelerate when approaching the target position. This can be used
to concatenate multiple motor or drive base maneuvers without stopping. If
no further commands are given, the motor will proceed to run indefinitely
at the given speed.
"""


class Direction(_PybricksEnum):
Expand Down

0 comments on commit 1ae0a90

Please sign in to comment.