mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-07-27 19:57:02 +00:00
pybricks.robotics: Car class updates.
Match minor firmware changes.
This commit is contained in:
@@ -177,10 +177,12 @@
|
||||
|
||||
The :meth:`done` and :meth:`stalled` methods have been moved.
|
||||
|
||||
.. pybricks-requirements:: pybricks-frozen
|
||||
.. pybricks-requirements::
|
||||
|
||||
.. blockimg:: pybricks_variables_set_car
|
||||
|
||||
.. versionadded:: 3.4
|
||||
|
||||
.. autoclass:: pybricks.robotics.Car
|
||||
:no-members:
|
||||
|
||||
|
||||
@@ -20,26 +20,6 @@ def _create_snippet(class_name: str) -> str:
|
||||
|
||||
|
||||
ENUMS = [
|
||||
pytest.param(
|
||||
"Button",
|
||||
[
|
||||
"BEACON",
|
||||
"BLUETOOTH",
|
||||
"CENTER",
|
||||
"DOWN",
|
||||
"LEFT",
|
||||
"LEFT_DOWN",
|
||||
"LEFT_MINUS",
|
||||
"LEFT_PLUS",
|
||||
"LEFT_UP",
|
||||
"RIGHT",
|
||||
"RIGHT_DOWN",
|
||||
"RIGHT_MINUS",
|
||||
"RIGHT_PLUS",
|
||||
"RIGHT_UP",
|
||||
"UP",
|
||||
],
|
||||
),
|
||||
pytest.param(
|
||||
"Color",
|
||||
[
|
||||
|
||||
+17
-11
@@ -131,12 +131,10 @@ class DriveBase:
|
||||
straight_acceleration: Optional[Number] = None,
|
||||
turn_rate: Optional[Number] = None,
|
||||
turn_acceleration: Optional[Number] = None,
|
||||
) -> None:
|
||||
...
|
||||
) -> None: ...
|
||||
|
||||
@overload
|
||||
def settings(self) -> Tuple[int, int, int, int]:
|
||||
...
|
||||
def settings(self) -> Tuple[int, int, int, int]: ...
|
||||
|
||||
def settings(self, *args):
|
||||
"""
|
||||
@@ -249,14 +247,22 @@ class Car:
|
||||
steering.
|
||||
"""
|
||||
|
||||
def __init__(self, steering_motor: Motor, drive_motors: Motor | Tuple[Motor, ...]):
|
||||
"""Car(steering_motor, drive_motors)
|
||||
def __init__(
|
||||
self,
|
||||
steer_motor: Motor,
|
||||
drive_motors: Motor | Tuple[Motor, ...],
|
||||
torque_limit: Number = 100,
|
||||
):
|
||||
"""Car(steer_motor, drive_motors, torque_limit=100)
|
||||
|
||||
Arguments:
|
||||
steering_motor (Motor):
|
||||
steer_motor (Motor):
|
||||
The motor that steers the front wheels.
|
||||
drive_motors (Motor): The motor that drives the wheels. Use a tuple
|
||||
for multiple motors.
|
||||
torque_limit (Number, %): The maximum torque limit used to find the
|
||||
endpoints for the steering mechanism, as a percentage of the
|
||||
maximum torque of the steering motor.
|
||||
"""
|
||||
|
||||
def steer(self, percentage: Number) -> None:
|
||||
@@ -273,11 +279,11 @@ class Car:
|
||||
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.
|
||||
Drives the car at a given power level. Positive values drive forward,
|
||||
negative values drive backward.
|
||||
|
||||
For ``power`` values below 30%, the car will coast the wheels in order
|
||||
The ``power`` value is used to set the motor voltage as a percentage of
|
||||
the battery voltage. Below 10%, 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
|
||||
|
||||
Reference in New Issue
Block a user