Python#
Esta guía proporciona información detallada sobre cómo usar los métodos de Python en VEXcode IQ (2.ª generación). Aquí aprenderá a leer y comprender cada método, con descripciones completas, parámetros y ejemplos de uso.
Comprensión de las entradas del método#
Cada entrada de método en la Referencia de API incluye los siguientes componentes:
Command Name – The official name of the command.
Description – A brief explanation of what the command does and what it may return.
Definition – The syntax of the command, showing how it should be written in code.
Parameter Table – Lists all inputs the command accepts.
Example Code – A usage example provided as a copy-and-paste code block.
Ejemplo de entrada de método#
drive#
drive
moves the drivetrain in a specified direction indefinitely.
Usage:
drivetrain.drive(direction, velocity, units)
Parámetros |
Descripción |
---|---|
|
The direction in which to drive:
|
|
Optional. The velocity at which the drivetrain will move as a float or integer. If the velocity is not specified, the default velocity is 50%. |
|
Optional. The unit that represents the velocity:
|
# Drive forward then stop
drivetrain.drive(FORWARD)
wait(2, SECONDS)
drivetrain.stop()
# Drive slowly in reverse then stop
drivetrain.drive(REVERSE, 20, PERCENT)
wait(2, SECONDS)
drivetrain.stop()