Motor#
Para que los comandos de motor aparezcan en VEXcode V5, se debe configurar un motor en la ventana Dispositivos.
Para obtener más información, consulte estos artículos:
motor.spin()#
The motor.spin(direction, velocity, units) command spins the motor using the provided arguments.
Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.
Parámetros |
Descripción |
|---|---|
|
A valid |
|
Optional. Spin the motor using this velocity. The default velocity set by |
|
Optional. A valid |
Devoluciones: Ninguna.
# Spin motor forward for 2 seconds.
motor1.spin(FORWARD)
wait(2, SECOND)
# Stop spinning.
motor1.stop()
motor.giro_a_posición()#
The motor.spin_to_position(rotation, units, velocity, units_v, wait) command is used to spin a motor to an absolute position using the provided arguments.
This function can be a waiting or non-waiting command depending on if the wait parameter is used.
Parámetros |
Descripción |
|---|---|
|
La posición a la que debe girar el motor. |
|
Optional. A valid |
|
Optional. The velocity with which the motor will spin. The default velocity set by |
|
Optional. A valid |
|
Optional. Determines whether the command will block subsequent commands ( |
Devoluciones: Ninguna.
# Spin motor to 180 degrees
motor1.spin_to_position(180)
motor.spin_for()#
The motor.spin_for(direction, value, units, velocity, units_v, wait) command spins the motor to a relative position using the provided arguments.
This can be a waiting or non-waiting command depending on if the wait parameter is used.
Parámetros |
Descripción |
|---|---|
|
A valid |
|
El valor al que debe girar el motor. |
|
Optional. A valid |
|
Optional. The velocity with which the motor will spin. The default velocity set by |
|
Optional. A valid |
|
Optional. Determines whether the command will block subsequent commands ( |
Devoluciones: Ninguna.
motor.stop()#
The motor.stop(mode) command is used to stop a motor.
Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.
Devoluciones: Ninguna.
# Spin motor forward for 2 seconds.
motor1.spin(FORWARD)
wait(2, SECOND)
# Stop spinning.
motor1.stop()
motor.set_velocity()#
The motor.set_velocity(value, units) command sets the default velocity for the motor.
Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.
Parámetros |
Descripción |
|---|---|
|
La nueva velocidad. |
|
Optional. A valid |
Devoluciones: Ninguna.
motor.set_reversed()#
The motor.set_reversed(value) command sets the motor direction to be reversed.
Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.
Parámetros |
Descripción |
|---|---|
|
Valor booleano para establecer la dirección invertida o no. |
Devoluciones: Ninguna.
motor.set_stopping()#
The motor.set_stopping(mode) command sets the stopping mode of the motor.
Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.
Parámetros |
Descripción |
|---|---|
|
A valid |
Devoluciones: Ninguna.
# Set the motor to stop with a brake.
motor_1.set_stopping(BRAKE)
motor.reset_position()#
The motor.reset_position() command resets the motor position to 0.
Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.
Devoluciones: Ninguna.
motor.set_position()#
The motor.set_position(value, units) command sets the current position of the motor.
Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.
Parámetros |
Descripción |
|---|---|
|
La nueva posición. |
|
Optional. A valid |
Devoluciones: Ninguna.
motor.set_timeout()#
The motor.set_timeout(value, units) command sets the timeout value used by the motor.
Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.
Parámetros |
Descripción |
|---|---|
|
El nuevo tiempo de espera. |
|
Optional. A valid |
Devoluciones: Ninguna.
# Set the motor timeout to 5 seconds.
motor_1.set_timeout(5000, MSEC)
motor.get_timeout()#
The motor.get_timeout() command returns the current value of motor timeout.
Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.
Devuelve: El valor de tiempo de espera actual.
motor.está_girando()#
The motor.is_spinning() command returns if the motor is currently spinning.
Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.
Returns: True if the motor is currently spinning. False if it is not.
motor.is_done()#
The motor.is_done() command returns if the motor has completed its movement.
Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.
Returns: True if the motor has completed its movement. False if it has not.
motor.establecer_par_máximo()#
The motor.set_max_torque(value, units) command sets the maximum torque the motor will use.
Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.
Parámetros |
Descripción |
|---|---|
|
El nuevo par máximo a utilizar. |
|
A valid |
Devoluciones: Ninguna.
# set maximum torque to 2 Newton Meters
motor1.set_max_torque(2, TorqueUnits.NM)
motor.dirección()#
The motor.direction() command returns the current direction the motor is spinning in.
Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.
Returns: The current DirectionType the motor is spinning in.
motor.posición()#
The motor.position(units) command returns the position of the motor.
Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.
Parámetros |
Descripción |
|---|---|
|
Optional. A valid |
Devuelve: La posición actual del motor en las unidades especificadas.
motor.velocidad()#
The motor.velocity(units) command returns the velocity of the motor.
Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.
Parámetros |
Descripción |
|---|---|
|
Optional. A valid |
Devuelve: La velocidad actual del motor en las unidades especificadas.
motor.corriente()#
The motor.current(units) command returns the current the motor is using.
Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.
Parámetros |
Descripción |
|---|---|
|
Optional. The only valid unit for current is |
Devuelve: La corriente que consume el motor en las unidades especificadas.
motor.potencia()#
The motor.power(units) command returns the power the motor is providing.
Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.
Parámetros |
Descripción |
|---|---|
|
Optional. The only valid unit for power is |
Devuelve: La potencia consumida por el motor en las unidades especificadas.
motor.torque()#
The motor.torque(units) command returns the torque the motor is providing.
Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.
Parámetros |
Descripción |
|---|---|
|
Optional. A valid |
Devuelve: El torque generado por el motor en las unidades especificadas.
eficiencia del motor()#
The motor.efficiency(units) command returns the efficiency of the motor.
Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.
Parámetros |
Descripción |
|---|---|
|
Optional. The only valid unit for efficiency is |
Devuelve: La eficiencia del motor como porcentaje.
motor.temperatura()#
The motor.temperature(units) command returns the temperature of the motor.
Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.
Parámetros |
Descripción |
|---|---|
|
Optional. A valid |
Devuelve: La temperatura del motor en las unidades especificadas.
motor.comando()#
The motor.command(units) command returns the last velocity sent to the motor.
Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.
Parámetros |
Descripción |
|---|---|
|
Optional. A valid |
Devuelve: La velocidad del comando del motor en las unidades especificadas.
motor.instalado()#
The motor.installed() command checks for device connection.
Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.
Devuelve: Verdadero o Falso.
# Check if the motor is installed.
is_installed = motor_1.installed()
motor.timestamp()#
The motor.timestamp() command requests the timestamp of the last received status packet.
Este es un comando sin espera y permite que el siguiente comando se ejecute sin demora.
Devuelve: Marca de tiempo del último paquete de estado en milisegundos.
# Get the timestamp of the last received status packet from the motor.
timestamp = motor_1.timestamp()