parameters
– Parameters and Constants¶
Constant parameters/arguments for the Pybricks API.
-
class
Port
(value)¶ Port on the programmable brick or hub.
Input/Output ports:
EV3 Sensor ports:
-
class
Direction
(value)¶ Rotational direction for positive speed or angle values.
-
CLOCKWISE
¶ A positive speed value should make the motor move clockwise.
-
COUNTERCLOCKWISE
¶ A positive speed value should make the motor move counterclockwise.
positive_direction =
Positive speed:
Negative speed:
Direction.CLOCKWISE
clockwise
counterclockwise
Direction.COUNTERCLOCKWISE
counterclockwise
clockwise
In general, clockwise is defined by looking at the motor shaft, just like looking at a clock. Some motors have two shafts. If in doubt, refer to the diagram in the
Motor
class documentation.-
-
class
Stop
(value)¶ Action after the motor stops: coast, brake, or hold.
-
COAST
¶ Let the motor move freely.
-
BRAKE
¶ Passively resist small external forces.
-
HOLD
¶ Keep controlling the motor to hold it at the commanded angle. This is only available on motors with encoders.
The following table show how each stop type adds an extra level of resistance to motion. In these examples,
m
is aMotor
and andd
is aDriveBase
. The examples also show how running at zero speed compares to these stop types.TypeFrictionBackEMFSpeedkept at 0Angle keptat targetExamplesCoast
m.stop()
m.run_target(500, 90, Stop.COAST)
Brake
m.brake()
m.run_target(500, 90, Stop.BRAKE)
m.run(0)
d.drive(0, 0)
Hold
m.hold()
m.run_target(500, 90, Stop.HOLD)
d.straight(0)
d.straight(100)
-
-
class
Color
(h, s=100, v=100, name=None)¶ Light or surface color.
Saturated colors
-
RED
= Color(0, 100, 100, 'RED')¶ - _
-
ORANGE
= Color(30, 100, 100, 'ORANGE')¶ - _
-
YELLOW
= Color(60, 100, 100, 'YELLOW')¶ - _
-
GREEN
= Color(120, 100, 100, 'GREEN')¶ - _
-
CYAN
= Color(180, 100, 100, 'CYAN')¶ - _
-
BLUE
= Color(240, 100, 100, 'BLUE')¶ - _
-
VIOLET
= Color(270, 100, 100, 'VIOLET')¶ - _
-
MAGENTA
= Color(300, 100, 100, 'MAGENTA')¶ - _
Unsaturated colors
-
BLACK
= Color(0, 0, 0, 'BLACK')¶ - _
-
GRAY
= Color(0, 0, 50, 'GRAY')¶ - _
-
WHITE
= Color(0, 0, 100, 'WHITE')¶ - _
-
-
class
Button
(value)¶ Buttons on a brick or remote
-
LEFT_DOWN
¶
-
LEFT_MINUS
¶
-
DOWN
¶
-
RIGHT_DOWN
¶
-
RIGHT_MINUS
¶
-
LEFT
¶
-
CENTER
¶
-
RIGHT
¶
-
LEFT_UP
¶
-
LEFT_PLUS
¶
-
UP
¶
-
BEACON
¶
-
RIGHT_UP
¶
-
RIGHT_PLUS
¶
-
-
class
Side
(value)¶ Side of a hub or a sensor. These devices are mostly rectangular boxes with six sides:
-
TOP
¶
-
BOTTOM
¶
-
FRONT
¶
-
BACK
¶
-
LEFT
¶
-
RIGHT
¶
Screens or light matrices have only four sides. For those,
TOP
is treated the same asFRONT
, andBOTTOM
is treated the same asBACK
. The diagrams below define the sides for relevant devices.Prime Hub
Inventor Hub
Move Hub
Technic Hub
Tilt Sensor
-