mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-09-15 02:54:52 +00:00
pybricks.robotics.DriveBase: Add curve method.
This generalizes motion to curves (arcs), which is in between straight lines and in-place turns.
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Added maximum voltage setter for `DCMotor` and `Motor`.
|
- Added maximum voltage setter for `DCMotor` and `Motor`.
|
||||||
|
- Documented `DriveBase.curve()` method.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Removed `duty` setting from `Control.limits` method.
|
- Removed `duty` setting from `Control.limits` method.
|
||||||
|
|||||||
@@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
.. automethod:: pybricks.robotics.DriveBase.turn
|
.. automethod:: pybricks.robotics.DriveBase.turn
|
||||||
|
|
||||||
|
.. automethod:: pybricks.robotics.DriveBase.curve
|
||||||
|
|
||||||
.. automethod:: pybricks.robotics.DriveBase.settings
|
.. automethod:: pybricks.robotics.DriveBase.settings
|
||||||
|
|
||||||
.. rubric:: Drive forever
|
.. rubric:: Drive forever
|
||||||
|
|||||||
+19
-11
@@ -16,7 +16,7 @@ class DriveBase:
|
|||||||
makes it easy to drive a given distance in millimeters or turn by a given
|
makes it easy to drive a given distance in millimeters or turn by a given
|
||||||
number of degrees.
|
number of degrees.
|
||||||
|
|
||||||
**Positive** distances and drive speeds mean
|
**Positive** distances, radii, or drive speeds mean
|
||||||
driving **forward**. **Negative** means **backward**.
|
driving **forward**. **Negative** means **backward**.
|
||||||
|
|
||||||
**Positive** angles and turn rates mean turning **right**.
|
**Positive** angles and turn rates mean turning **right**.
|
||||||
@@ -103,7 +103,7 @@ class DriveBase:
|
|||||||
def settings(self, straight_speed, straight_acceleration, turn_rate,
|
def settings(self, straight_speed, straight_acceleration, turn_rate,
|
||||||
turn_acceleration):
|
turn_acceleration):
|
||||||
"""Configures the speed and acceleration used
|
"""Configures the speed and acceleration used
|
||||||
by :meth:`.straight` and :meth:`.turn`.
|
by :meth:`.straight`, :meth:`.turn`, and :meth:`.curve`.
|
||||||
|
|
||||||
If you give no arguments, this returns the current values as a tuple.
|
If you give no arguments, this returns the current values as a tuple.
|
||||||
|
|
||||||
@@ -111,16 +111,12 @@ class DriveBase:
|
|||||||
either before you begin driving or after you call :meth:`.stop`.
|
either before you begin driving or after you call :meth:`.stop`.
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
straight_speed (:ref:`linspeed`): Speed of the robot during
|
straight_speed (:ref:`linspeed`): Straight-line speed of the robot.
|
||||||
:meth:`.straight`.
|
straight_acceleration (:ref:`linacceleration`): Straight-line
|
||||||
straight_acceleration (:ref:`linacceleration`): Acceleration and
|
acceleration and deceleration of the robot.
|
||||||
deceleration of the robot at the start and end
|
turn_rate (:ref:`speed`): Turn rate of the robot.
|
||||||
of :meth:`.straight`.
|
|
||||||
turn_rate (:ref:`speed`): Turn rate of the robot
|
|
||||||
during :meth:`.turn`.
|
|
||||||
turn_acceleration (:ref:`acceleration`): Angular acceleration and
|
turn_acceleration (:ref:`acceleration`): Angular acceleration and
|
||||||
deceleration of the robot at the start and end
|
deceleration of the robot.
|
||||||
of :meth:`.turn`.
|
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -145,3 +141,15 @@ class DriveBase:
|
|||||||
with the rest of the program.
|
with the rest of the program.
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def curve(self, radius, angle, then=_Stop.HOLD, wait=True):
|
||||||
|
"""Drives an arc along a circle of a given radius, by a given angle.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
radius (:ref:`dimension`): Radius of the circle.
|
||||||
|
angle (:ref:`angle`): Angle along the circle.
|
||||||
|
then (Stop): What to do after coming to a standstill.
|
||||||
|
wait (bool): Wait for the maneuver to complete before continuing
|
||||||
|
with the rest of the program.
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user