Here you can find a cheat sheet with the most commonly used commands. There are also more advanced commands that are not included in the built-in API, but the available ones cover most, if not all, of the students’ needs.
Below is an example of a function definition and how to read it:
move_for_degrees(pair: int, degrees: int, steering: int, *, velocity: int = 360, stop: int = motor.BRAKE, acceleration: int = 1000, deceleration: int = 1000) → Awaitable
...
Parameters
pair: int
The motor pair to be used.
degrees: int
The number of degrees the motors should rotate.
steering: int
The steering value (from -100 to 100).
Optional keyword arguments:
velocity: int
The speed of the motor in degrees per second.
...
stop: int
Defines how the motor behaves after it stops. Use constants from the motor module.
...
acceleration: int
The acceleration in degrees per second squared (1–10000).
deceleration: int
The deceleration in degrees per second squared (1–10000).
Let’s take a closer look at the function definition:
move_for_degrees(pair: int, degrees: int, steering: int, *, velocity: int = 360, stop: int = motor.BRAKE, acceleration: int = 1000, deceleration: int = 1000) - Awaitable
The parameters before the "*" symbol are required parameters. You must provide them in the correct order. For example, the first parameter is "pair", so the command expects the motor pair first. The same applies to "degrees" and "steering".
The parameters after the "*" symbol are optional parameters. To change them, you must use their names. This means you cannot just write a number - you need to specify which parameter you are changing. For example:
motor_pair.move_for_degrees(motor_pair.PAIR_1, 360, 0, velocity=280)
Finally, the "Awaitable" keyword means that this command can be used with "await". This allows the program to wait until the command has finished before continuing with the next one. For example:
await motor_pair.move_for_degrees(motor_pair.PAIR_1, 360, 0, velocity=280)