diff --git a/.vscode/spellright.dict b/.vscode/spellright.dict index 1d71b4b..cef27de 100644 --- a/.vscode/spellright.dict +++ b/.vscode/spellright.dict @@ -69,7 +69,6 @@ robotframe rtype sep signaltypes -simplemotor startinstall str thermistor diff --git a/doc/api/ev3devices.rst b/doc/api/ev3devices.rst index 9efde00..3ecfa54 100644 --- a/doc/api/ev3devices.rst +++ b/doc/api/ev3devices.rst @@ -7,33 +7,41 @@ Motor ^^^^^^^^^^^^ -.. autoclass:: pybricks._simplemotor.Motor - :noindex: +.. autoclass:: pybricks.ev3devices.Motor :no-members: - .. automethod:: pybricks._simplemotor.Motor.angle - :noindex: + .. rubric:: Measuring - .. automethod:: pybricks._simplemotor.Motor.reset_angle - :noindex: + .. automethod:: pybricks.ev3devices.Motor.speed - .. automethod:: pybricks._simplemotor.Motor.speed - :noindex: + .. automethod:: pybricks.ev3devices.Motor.angle - .. automethod:: pybricks._simplemotor.Motor.stop - :noindex: + .. automethod:: pybricks.ev3devices.Motor.reset_angle - .. automethod:: pybricks._simplemotor.Motor.run - :noindex: + .. automethod:: pybricks.ev3devices.Motor.stalled - .. automethod:: pybricks._simplemotor.Motor.run_time - :noindex: + .. rubric:: Action - .. automethod:: pybricks._simplemotor.Motor.run_angle - :noindex: + .. automethod:: pybricks.ev3devices.Motor.stop - .. automethod:: pybricks._simplemotor.Motor.run_target - :noindex: + .. automethod:: pybricks.ev3devices.Motor.run + + .. automethod:: pybricks.ev3devices.Motor.run_time + + .. automethod:: pybricks.ev3devices.Motor.run_angle + + .. automethod:: pybricks.ev3devices.Motor.run_target + + .. automethod:: pybricks.ev3devices.Motor.run_until_stalled + + .. automethod:: pybricks.ev3devices.Motor.dc + + .. rubric:: Advanced motion control + + .. automethod:: pybricks.ev3devices.Motor.track_target + + .. autoattribute:: pybricks.ev3devices.Motor.control + :annotation: Touch Sensor diff --git a/doc/api/motors.rst b/doc/api/motors.rst index 813c8db..54def81 100644 --- a/doc/api/motors.rst +++ b/doc/api/motors.rst @@ -1,44 +1,6 @@ More about Motors =========================================== -The Motor Class -^^^^^^^^^^^^^^^ - -.. autoclass:: pybricks.builtins.Motor - :no-members: - - .. rubric:: Measuring - - .. automethod:: pybricks.builtins.Motor.speed - - .. automethod:: pybricks.builtins.Motor.angle - - .. automethod:: pybricks.builtins.Motor.reset_angle - - .. automethod:: pybricks.builtins.Motor.stalled - - .. rubric:: Action - - .. automethod:: pybricks.builtins.Motor.stop - - .. automethod:: pybricks.builtins.Motor.run - - .. automethod:: pybricks.builtins.Motor.run_time - - .. automethod:: pybricks.builtins.Motor.run_angle - - .. automethod:: pybricks.builtins.Motor.run_target - - .. automethod:: pybricks.builtins.Motor.run_until_stalled - - .. automethod:: pybricks.builtins.Motor.dc - - .. rubric:: Advanced motion control - - .. automethod:: pybricks.builtins.Motor.track_target - - .. autoattribute:: control - :annotation: Motor Tips & Tricks ^^^^^^^^^^^^^^^^^^^ @@ -88,7 +50,7 @@ rotate by 270 degrees. To turn at 200 degrees per second, the motor has to turn at 600 degrees per second, and so on. To avoid using this factor 3 everywhere in your program, you can use the -`gears` setting of the :class:`.Motor` object, as shown in this example:: +`gears` setting of the ``Motor`` object, as shown in this example:: # This example uses the EV3 brick, but the same # technique applies to other programmable hubs. diff --git a/doc/api/pupdevices.rst b/doc/api/pupdevices.rst index c255977..8991977 100644 --- a/doc/api/pupdevices.rst +++ b/doc/api/pupdevices.rst @@ -17,38 +17,43 @@ Motors without Rotation Sensors Motors with Rotation Sensors ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -.. autoclass:: pybricks._simplemotor.Motor +.. autoclass:: pybricks.pupdevices.Motor :noindex: :no-members: - .. automethod:: pybricks._simplemotor.Motor.angle - :noindex: + .. rubric:: Measuring - .. automethod:: pybricks._simplemotor.Motor.reset_angle - :noindex: + .. automethod:: pybricks.pupdevices.Motor.speed - .. automethod:: pybricks._simplemotor.Motor.speed - :noindex: + .. automethod:: pybricks.pupdevices.Motor.angle - .. automethod:: pybricks._simplemotor.Motor.stop - :noindex: + .. automethod:: pybricks.pupdevices.Motor.reset_angle - .. automethod:: pybricks._simplemotor.Motor.run - :noindex: + .. automethod:: pybricks.pupdevices.Motor.stalled - .. automethod:: pybricks._simplemotor.Motor.run_time - :noindex: + .. rubric:: Action - .. automethod:: pybricks._simplemotor.Motor.run_angle - :noindex: + .. automethod:: pybricks.pupdevices.Motor.stop - .. automethod:: pybricks._simplemotor.Motor.run_target - :noindex: + .. automethod:: pybricks.pupdevices.Motor.run - .. automethod:: pybricks.builtins.Motor.dc - :noindex: + .. automethod:: pybricks.pupdevices.Motor.run_time + + .. automethod:: pybricks.pupdevices.Motor.run_angle + + .. automethod:: pybricks.pupdevices.Motor.run_target + + .. automethod:: pybricks.pupdevices.Motor.run_until_stalled + + .. automethod:: pybricks.pupdevices.Motor.dc + + .. rubric:: Advanced motion control + + .. automethod:: pybricks.pupdevices.Motor.track_target + + .. autoattribute:: pybricks.pupdevices.Motor.control + :annotation: - This method lets you use a motor as if it is a simple DC motor. Color and Distance Sensor ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/doc/api/signaltypes.rst b/doc/api/signaltypes.rst index c12a7c2..ec6908c 100644 --- a/doc/api/signaltypes.rst +++ b/doc/api/signaltypes.rst @@ -13,9 +13,8 @@ time: ms --------- All time and duration values are measured in milliseconds (ms). -For example, the duration of motion with :meth:`run_time -<.builtins.Motor.run_time>`, the duration of :func:`wait <.tools.wait>`, or -the time values returned by the :class:`StopWatch <.tools.StopWatch>` are +For example, the duration of motion with ``run_time``, and the duration +of :func:`wait <.tools.wait>` are specified in milliseconds. Angles and angular motion @@ -29,7 +28,7 @@ angle: deg All angles are measured in degrees (deg). One full rotation corresponds to 360 degrees. -For example, the angle values of a :meth:`Motor <.builtins.Motor.angle>` or +For example, the angle values of a ``Motor`` or the :meth:`GyroSensor <.ev3devices.GyroSensor.angle>` are expressed in degrees. .. _speed: @@ -40,8 +39,7 @@ rotational speed: deg/s Rotational speed, or *angular velocity* describes how fast something rotates, expressed as the number of degrees per second (deg/s). -For example, the rotational speed values of a :meth:`Motor -<.builtins.Motor.speed>` or the :meth:`GyroSensor +For example, the rotational speed values of a ``Motor`` or the :meth:`GyroSensor <.ev3devices.GyroSensor.speed>` are expressed in degrees per second. While we recommend working with degrees per second in your programs, you can @@ -63,8 +61,8 @@ rotational speed changes. This is expressed as the change of the number of degrees per second, during one second (deg/s/s). This is also commonly written as :math:`deg/s^2`. -For example, you can adjust the rotational acceleration setting of a -:class:`Motor <.builtins.Motor>` to change how smoothly or +For example, you can adjust the rotational acceleration setting of a ``Motor`` +to change how smoothly or how quickly it reaches the constant speed set point. diff --git a/pybricks/_simplemotor.py b/pybricks/_simplemotor.py deleted file mode 100644 index 7b5f814..0000000 --- a/pybricks/_simplemotor.py +++ /dev/null @@ -1,104 +0,0 @@ -"""Shortened and simplified motor docs, by hiding optional -methods and arguments.""" - -from .builtins import Motor -from .parameters import Direction, Stop - - -class Motor(Motor): - """Generic class to control motors with built-in rotation sensors.""" - - def __init__(self, port, positive_direction=Direction.CLOCKWISE): - """Motor(port, positive_direction=Direction.CLOCKWISE) - - Arguments: - port (Port): - Port to which the motor is connected. - positive_direction (Direction): Which direction the motor should - turn when you give a positive speed value or - angle (*Default*: ``Direction.CLOCKWISE``). - """ - pass - - def angle(self): - """Get the rotation angle of the motor. - - Returns: - :ref:`angle`: Motor angle. - - """ - pass - - def reset_angle(self, angle): - """Reset the accumulated rotation angle of the motor. - - Arguments: - angle (:ref:`angle`): Value to which the angle should be reset. - """ - pass - - def speed(self): - """Get the speed of the motor. - - Returns: - :ref:`speed`: Motor speed. - - """ - pass - - def stop(self, stop_type=Stop.COAST): - """stop() - - Stop the motor. - """ - pass - - def run(self, speed): - """Keep the motor running at a constant speed. - - Arguments: - speed (:ref:`speed`): Speed of the motor. - """ - pass - - def run_time(self, speed, time, stop_type=Stop.COAST, wait=True): - """run_time(speed, time) - - Run the motor at a constant speed for a given amount of time. - - Arguments: - speed (:ref:`speed`): Speed of the motor. - time (:ref:`time`): Duration of the maneuver. - """ - pass - - def run_angle(self, speed, rotation_angle, - stop_type=Stop.COAST, wait=True): - """run_angle(speed, rotation_angle) - - Rotate the motor at a constant speed by a given angle. - - Arguments: - speed (:ref:`speed`): Speed of the motor. - rotation_angle (:ref:`angle`): Angle by which the motor should - rotate. - """ - pass - - def run_target(self, speed, target_angle, stop_type=Stop.COAST, wait=True): - """run_target(speed, target_angle) - - Run the motor at a constant speed towards a given target angle. The - direction of rotation is automatically selected based on the target - angle. - - Arguments: - speed (:ref:`speed`): Absolute speed of the motor. The direction - will be automatically selected based on the - target angle: it makes no difference if you - specify a positive or negative speed. - target_angle (:ref:`angle`): Target angle that the motor should - rotate to, regardless of its current - angle. - """ - pass