Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d1b7d0f61b | ||
|
|
8fa99928dd | ||
|
|
00318fd815 | ||
|
|
b4adb50adf | ||
|
|
1d2c0c273c | ||
|
|
04b7c745e2 | ||
|
|
1d7efe6bdc |
@@ -4,7 +4,18 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
## 3.4.0b1 - 2023-11-28
|
||||
## 3.4.0b3 - 2024-01-30
|
||||
|
||||
## Added
|
||||
|
||||
- Added `pybricks.robotics.Car` class.
|
||||
|
||||
### Changed
|
||||
|
||||
- Changed `pybricks.robotics.DriveBase` icon to two wheels instead of steering
|
||||
wheel, which will be used for the new car class.
|
||||
|
||||
## 3.4.0b2 - 2023-11-28
|
||||
|
||||
### Changed
|
||||
- Include first batch of block coding images.
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import os
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
from docutils.parsers.rst import directives
|
||||
|
||||
@@ -14,6 +14,7 @@ FEATURES_MEDIUM = FEATURES_SMALL | {
|
||||
"pybricks-iodevices",
|
||||
"stm32-extra",
|
||||
"stm32-float",
|
||||
"pybricks-frozen",
|
||||
}
|
||||
|
||||
# Large feature set.
|
||||
@@ -31,12 +32,10 @@ HUB_FEATURES = {
|
||||
|
||||
|
||||
class PybricksRequirementsStaticDirective(Directive):
|
||||
|
||||
required_arguments = 0
|
||||
optional_arguments = 10
|
||||
|
||||
def run(self):
|
||||
|
||||
# Copy required resources to static
|
||||
# CC BY-SA 4.0 via https://stackoverflow.com/a/63728208
|
||||
env = self.state.document.settings.env
|
||||
|
||||
@@ -1 +1 @@
|
||||
Copyright (c) 2023 The Pybricks Authors - All rights reserved
|
||||
Copyright (c) 2024 The Pybricks Authors - All rights reserved
|
||||
|
||||
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 27 KiB |
|
After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 28 KiB |
|
After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 34 KiB |
@@ -85,6 +85,8 @@
|
||||
|
||||
.. automethod:: pybricks.robotics.DriveBase.stalled
|
||||
|
||||
.. pybricks-requirements:: gyro
|
||||
|
||||
.. rubric:: Driving with the gyro
|
||||
|
||||
.. blockimg:: pybricks_blockDriveBaseUseGyro
|
||||
@@ -175,16 +177,47 @@
|
||||
|
||||
The :meth:`done` and :meth:`stalled` methods have been moved.
|
||||
|
||||
.. pybricks-requirements:: pybricks-frozen
|
||||
|
||||
.. pybricks-requirements:: gyro
|
||||
.. blockimg:: pybricks_variables_set_car
|
||||
|
||||
.. autoclass:: pybricks.robotics.Car
|
||||
:no-members:
|
||||
|
||||
.. blockimg:: pybricks_blockCarSteer
|
||||
|
||||
.. automethod:: pybricks.robotics.Car.steer
|
||||
|
||||
.. blockimg:: pybricks_blockCarDrive_car_drive_at_power
|
||||
|
||||
.. automethod:: pybricks.robotics.Car.drive_power
|
||||
|
||||
.. blockimg:: pybricks_blockCarDrive_car_drive_at_speed
|
||||
|
||||
.. automethod:: pybricks.robotics.Car.drive_speed
|
||||
|
||||
Examples
|
||||
-------------------
|
||||
|
||||
Driving straight and turning in place
|
||||
**********************************************
|
||||
Driving straight and turning in place with a drive base
|
||||
********************************************************
|
||||
|
||||
The following program shows the basics of driving and turning.
|
||||
This program shows the basics of driving and turning.
|
||||
|
||||
.. literalinclude::
|
||||
../../examples/pup/robotics/drivebase_basics.py
|
||||
|
||||
Remote controlling a car with front wheel steering
|
||||
**************************************************
|
||||
|
||||
This program shows how you can drive a car with front wheel steering
|
||||
using the :class:`remote control <pybricks.pupdevices.Remote>`.
|
||||
|
||||
In this program, the ports match those of the `LEGO Technic 42099 Off-Roader
|
||||
<https://pybricks.com/projects/sets/technic/42099-off-roader/>`_, but you can
|
||||
use any other car with front wheel steering. If your vehicle has only one
|
||||
drive motor, you can use a single motor instead of a tuple of the motors used
|
||||
below.
|
||||
|
||||
.. literalinclude::
|
||||
../../examples/pup/robotics/car_remote.py
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
from pybricks.parameters import Direction, Port, Button
|
||||
from pybricks.pupdevices import Motor, Remote
|
||||
from pybricks.robotics import Car
|
||||
from pybricks.tools import wait
|
||||
|
||||
# Set up motors.
|
||||
front = Motor(Port.A, Direction.COUNTERCLOCKWISE)
|
||||
rear = Motor(Port.B, Direction.COUNTERCLOCKWISE)
|
||||
steer = Motor(Port.C, Direction.CLOCKWISE)
|
||||
|
||||
# Connect to the remote.
|
||||
remote = Remote()
|
||||
|
||||
# Set up the car.
|
||||
car = Car(steer, [front, rear])
|
||||
|
||||
# The main program starts here.
|
||||
while True:
|
||||
# Read remote state.
|
||||
pressed = remote.buttons.pressed()
|
||||
|
||||
# Steer using the left pad. Steering is the percentage
|
||||
# of the angle determined while initializing.
|
||||
steering = 0
|
||||
if Button.LEFT_PLUS in pressed:
|
||||
steering += 100
|
||||
elif Button.LEFT_MINUS in pressed:
|
||||
steering -= 100
|
||||
car.steer(steering)
|
||||
|
||||
# Drive using the right pad.
|
||||
power = 0
|
||||
if Button.RIGHT_PLUS in pressed:
|
||||
power += 100
|
||||
elif Button.RIGHT_MINUS in pressed:
|
||||
power -= 100
|
||||
car.drive_power(power)
|
||||
|
||||
# Wait briefly.
|
||||
wait(10)
|
||||
@@ -4,6 +4,11 @@
|
||||
|
||||
## Unreleased
|
||||
|
||||
## 1.13.0 - 2024-01-30
|
||||
|
||||
### Changed
|
||||
- Updated `pybricks` package to v3.4.0b3.
|
||||
|
||||
## 1.12.0 - 2023-11-24
|
||||
|
||||
### Changed
|
||||
|
||||
@@ -76,14 +76,14 @@ files = [
|
||||
|
||||
[[package]]
|
||||
name = "exceptiongroup"
|
||||
version = "1.1.3"
|
||||
version = "1.2.0"
|
||||
description = "Backport of PEP 654 (exception groups)"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "exceptiongroup-1.1.3-py3-none-any.whl", hash = "sha256:343280667a4585d195ca1cf9cef84a4e178c4b6cf2274caef9859782b567d5e3"},
|
||||
{file = "exceptiongroup-1.1.3.tar.gz", hash = "sha256:097acd85d473d75af5bb98e41b61ff7fe35efe6675e4f9370ec6ec5126d160e9"},
|
||||
{file = "exceptiongroup-1.2.0-py3-none-any.whl", hash = "sha256:4bfd3996ac73b41e9b9628b04e079f193850720ea5945fc96a08633c66912f14"},
|
||||
{file = "exceptiongroup-1.2.0.tar.gz", hash = "sha256:91f5c769735f051a4290d52edd0858999b57e5876e9f85937691bd4c9fa3ed68"},
|
||||
]
|
||||
|
||||
[package.extras]
|
||||
@@ -191,26 +191,26 @@ testing = ["docopt", "pytest (<6.0.0)"]
|
||||
|
||||
[[package]]
|
||||
name = "pathspec"
|
||||
version = "0.11.2"
|
||||
version = "0.12.1"
|
||||
description = "Utility library for gitignore style pattern matching of file paths."
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "pathspec-0.11.2-py3-none-any.whl", hash = "sha256:1d6ed233af05e679efb96b1851550ea95bbb64b7c490b0f5aa52996c11e92a20"},
|
||||
{file = "pathspec-0.11.2.tar.gz", hash = "sha256:e0d8d0ac2f12da61956eb2306b69f9469b42f4deb0f3cb6ed47b9cce9996ced3"},
|
||||
{file = "pathspec-0.12.1-py3-none-any.whl", hash = "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08"},
|
||||
{file = "pathspec-0.12.1.tar.gz", hash = "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "platformdirs"
|
||||
version = "4.0.0"
|
||||
version = "4.1.0"
|
||||
description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"."
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "platformdirs-4.0.0-py3-none-any.whl", hash = "sha256:118c954d7e949b35437270383a3f2531e99dd93cf7ce4dc8340d3356d30f173b"},
|
||||
{file = "platformdirs-4.0.0.tar.gz", hash = "sha256:cb633b2bcf10c51af60beb0ab06d2f1d69064b43abf4c185ca6b28865f3f9731"},
|
||||
{file = "platformdirs-4.1.0-py3-none-any.whl", hash = "sha256:11c8f37bcca40db96d8144522d925583bdb7a31f7b0e37e3ed4318400a8e2380"},
|
||||
{file = "platformdirs-4.1.0.tar.gz", hash = "sha256:906d548203468492d432bcb294d4bc2fff751bf84971fbb2c10918cc206ee420"},
|
||||
]
|
||||
|
||||
[package.extras]
|
||||
@@ -219,14 +219,14 @@ test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4)", "pytest-co
|
||||
|
||||
[[package]]
|
||||
name = "pluggy"
|
||||
version = "1.3.0"
|
||||
version = "1.4.0"
|
||||
description = "plugin and hook calling mechanisms for python"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "pluggy-1.3.0-py3-none-any.whl", hash = "sha256:d89c696a773f8bd377d18e5ecda92b7a3793cbe66c87060a6fb58c7b6e1061f7"},
|
||||
{file = "pluggy-1.3.0.tar.gz", hash = "sha256:cf61ae8f126ac6f7c451172cf30e3e43d3ca77615509771b3a984a0730651e12"},
|
||||
{file = "pluggy-1.4.0-py3-none-any.whl", hash = "sha256:7db9f7b503d67d1c5b95f59773ebb58a8c1c288129a88665838012cfb07b8981"},
|
||||
{file = "pluggy-1.4.0.tar.gz", hash = "sha256:8c85c2876142a764e5b7548e7d9a0e0ddb46f5185161049a79b7e974454223be"},
|
||||
]
|
||||
|
||||
[package.extras]
|
||||
@@ -235,7 +235,7 @@ testing = ["pytest", "pytest-benchmark"]
|
||||
|
||||
[[package]]
|
||||
name = "pybricks"
|
||||
version = "3.3.0"
|
||||
version = "3.4.0b3"
|
||||
description = "Documentation and user-API stubs for Pybricks MicroPython"
|
||||
category = "main"
|
||||
optional = false
|
||||
@@ -273,14 +273,14 @@ files = [
|
||||
|
||||
[[package]]
|
||||
name = "pytest"
|
||||
version = "7.4.3"
|
||||
version = "7.4.4"
|
||||
description = "pytest: simple powerful testing with Python"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "pytest-7.4.3-py3-none-any.whl", hash = "sha256:0d009c083ea859a71b76adf7c1d502e4bc170b80a8ef002da5806527b9591fac"},
|
||||
{file = "pytest-7.4.3.tar.gz", hash = "sha256:d989d136982de4e3b29dabcc838ad581c64e8ed52c11fbe86ddebd9da0818cd5"},
|
||||
{file = "pytest-7.4.4-py3-none-any.whl", hash = "sha256:b090cdf5ed60bf4c45261be03239c2c1c22df034fbffe691abe93cd80cea01d8"},
|
||||
{file = "pytest-7.4.4.tar.gz", hash = "sha256:2cf0005922c6ace4a3e2ec8b4080eb0d9753fdc93107415332f50ce9e7994280"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
@@ -321,4 +321,4 @@ files = [
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = ">= 3.10, < 3.12"
|
||||
content-hash = "56ea771a615b1cb92977bb62681ddf4152cb651161169d933a64f4724ceff487"
|
||||
content-hash = "05194aa3524719ff95478d577a1e90ca33051921e2688cb2c45bfa1d3d84541c"
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
[tool.poetry]
|
||||
name = "pybricks_jedi"
|
||||
version = "1.12.0"
|
||||
version = "1.13.0"
|
||||
description = "Code completion for Pybricks."
|
||||
authors = ["The Pybricks Authors <team@pybricks.com>"]
|
||||
license = "MIT"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">= 3.10, < 3.12"
|
||||
pybricks = "3.3.0"
|
||||
pybricks = "3.4.0b3"
|
||||
jedi = "0.18.1"
|
||||
typing-extensions = "4.2.0"
|
||||
docstring-parser = "0.14.1"
|
||||
|
||||
@@ -148,7 +148,7 @@ def test_from_pybricks_pupdevices_import():
|
||||
def test_from_pybricks_robotics_import():
|
||||
code = "from pybricks.robotics import "
|
||||
completions: list[CompletionItem] = json.loads(complete(code, 1, len(code) + 1))
|
||||
assert [c["insertText"] for c in completions] == ["DriveBase"]
|
||||
assert [c["insertText"] for c in completions] == ["Car", "DriveBase"]
|
||||
|
||||
|
||||
def test_from_pybricks_tools_import():
|
||||
|
||||
@@ -2,6 +2,16 @@
|
||||
|
||||
<!-- refer to https://keepachangelog.com/en/1.0.0/ for guidance -->
|
||||
|
||||
## 2.14.0 - 2024-01-30
|
||||
|
||||
### Changed
|
||||
- Updated docs to v3.4.0b3.
|
||||
|
||||
## 2.13.0 - 2023-11-24
|
||||
|
||||
### Changed
|
||||
- Updated docs to v3.4.0b1.
|
||||
|
||||
## 2.12.0 - 2023-11-24
|
||||
|
||||
### Changed
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pybricks/ide-docs",
|
||||
"version": "2.12.0",
|
||||
"version": "2.14.0",
|
||||
"description": "Special build of Pybricks API docs for embedding in an IDE.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "pybricks"
|
||||
version = "3.4.0b1"
|
||||
version = "3.4.0b3"
|
||||
description = "Documentation and user-API stubs for Pybricks MicroPython"
|
||||
authors = ["The Pybricks Authors <team@pybricks.com>"]
|
||||
maintainers = ["Laurens Valk <laurens@pybricks.com>", "David Lechner <david@pybricks.com>" ]
|
||||
|
||||
@@ -241,6 +241,67 @@ class DriveBase:
|
||||
"""
|
||||
|
||||
|
||||
class Car:
|
||||
"""A vehicle with one steering motor, and one or more motors for driving.
|
||||
|
||||
When you use this class, the steering motor will automatically find the
|
||||
center position. This also determines which angle corresponds to 100%
|
||||
steering.
|
||||
"""
|
||||
|
||||
def __init__(self, steering_motor: Motor, drive_motors: Motor | Tuple[Motor, ...]):
|
||||
"""Car(steering_motor, drive_motors)
|
||||
|
||||
Arguments:
|
||||
steering_motor (Motor):
|
||||
The motor that steers the front wheels.
|
||||
drive_motors (Motor): The motor that drives the wheels. Use a tuple
|
||||
for multiple motors.
|
||||
"""
|
||||
|
||||
def steer(self, percentage: Number) -> None:
|
||||
"""steer(percentage)
|
||||
|
||||
Steers the front wheels by a given amount. For 100% steering, it
|
||||
steers right by the angle that was determined on initialization.
|
||||
For -100% steering, it steers left and 0% means straight.
|
||||
|
||||
Arguments:
|
||||
steering (Number, %): Amount to steer the front wheels.
|
||||
"""
|
||||
|
||||
def drive_power(self, power: Number) -> None:
|
||||
"""drive_power(power)
|
||||
|
||||
Drives the car at a given "power" level, as a percentage of the
|
||||
battery voltage. Positive values drive forward, negative values drive
|
||||
backward.
|
||||
|
||||
For ``power`` values below 30%, the car will coast the wheels in order
|
||||
to roll out smoothly instead of braking abruptly.
|
||||
|
||||
This command is useful for remote control applications where you want
|
||||
instant response to button presses or joystick movements.
|
||||
|
||||
Arguments:
|
||||
speed (Number, %): Speed of the car.
|
||||
"""
|
||||
|
||||
def drive_speed(self, speed: Number) -> None:
|
||||
"""drive_speed(speed)
|
||||
|
||||
Drives the car at a given motor speed. Positive values drive forward,
|
||||
negative values drive backward.
|
||||
|
||||
This command is useful for more precise driving with gentle
|
||||
acceleration and deceleration. This automatically increases the power
|
||||
to maintain speed as you drive across obstacles.
|
||||
|
||||
Arguments:
|
||||
speed (Number, deg/s): Angular velocity of the drive motors.
|
||||
"""
|
||||
|
||||
|
||||
# HACK: hide from jedi
|
||||
if TYPE_CHECKING:
|
||||
del Motor
|
||||
|
||||