Skip to content

Commit 72f25cb

Browse files
committed
pybricks.robotics: Car class updates.
Match minor firmware changes.
1 parent 079b108 commit 72f25cb

File tree

3 files changed

+20
-32
lines changed

3 files changed

+20
-32
lines changed

doc/main/robotics.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,12 @@
177177

178178
The :meth:`done` and :meth:`stalled` methods have been moved.
179179

180-
.. pybricks-requirements:: pybricks-frozen
180+
.. pybricks-requirements::
181181

182182
.. blockimg:: pybricks_variables_set_car
183183

184+
.. versionadded:: 3.4
185+
184186
.. autoclass:: pybricks.robotics.Car
185187
:no-members:
186188

jedi/tests/test_complete_parameters.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,6 @@ def _create_snippet(class_name: str) -> str:
2020

2121

2222
ENUMS = [
23-
pytest.param(
24-
"Button",
25-
[
26-
"BEACON",
27-
"BLUETOOTH",
28-
"CENTER",
29-
"DOWN",
30-
"LEFT",
31-
"LEFT_DOWN",
32-
"LEFT_MINUS",
33-
"LEFT_PLUS",
34-
"LEFT_UP",
35-
"RIGHT",
36-
"RIGHT_DOWN",
37-
"RIGHT_MINUS",
38-
"RIGHT_PLUS",
39-
"RIGHT_UP",
40-
"UP",
41-
],
42-
),
4323
pytest.param(
4424
"Color",
4525
[

src/pybricks/robotics.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,10 @@ def settings(
131131
straight_acceleration: Optional[Number] = None,
132132
turn_rate: Optional[Number] = None,
133133
turn_acceleration: Optional[Number] = None,
134-
) -> None:
135-
...
134+
) -> None: ...
136135

137136
@overload
138-
def settings(self) -> Tuple[int, int, int, int]:
139-
...
137+
def settings(self) -> Tuple[int, int, int, int]: ...
140138

141139
def settings(self, *args):
142140
"""
@@ -249,14 +247,22 @@ class Car:
249247
steering.
250248
"""
251249

252-
def __init__(self, steering_motor: Motor, drive_motors: Motor | Tuple[Motor, ...]):
253-
"""Car(steering_motor, drive_motors)
250+
def __init__(
251+
self,
252+
steer_motor: Motor,
253+
drive_motors: Motor | Tuple[Motor, ...],
254+
torque_limit: Number = 100,
255+
):
256+
"""Car(steer_motor, drive_motors, torque_limit=100)
254257
255258
Arguments:
256-
steering_motor (Motor):
259+
steer_motor (Motor):
257260
The motor that steers the front wheels.
258261
drive_motors (Motor): The motor that drives the wheels. Use a tuple
259262
for multiple motors.
263+
torque_limit (Number, %): The maximum torque limit used to find the
264+
endpoints for the steering mechanism, as a percentage of the
265+
maximum torque of the steering motor.
260266
"""
261267

262268
def steer(self, percentage: Number) -> None:
@@ -273,11 +279,11 @@ def steer(self, percentage: Number) -> None:
273279
def drive_power(self, power: Number) -> None:
274280
"""drive_power(power)
275281
276-
Drives the car at a given "power" level, as a percentage of the
277-
battery voltage. Positive values drive forward, negative values drive
278-
backward.
282+
Drives the car at a given power level. Positive values drive forward,
283+
negative values drive backward.
279284
280-
For ``power`` values below 30%, the car will coast the wheels in order
285+
The ``power`` value is used to set the motor voltage as a percentage of
286+
the battery voltage. Below 10%, the car will coast the wheels in order
281287
to roll out smoothly instead of braking abruptly.
282288
283289
This command is useful for remote control applications where you want

0 commit comments

Comments
 (0)