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 |
---|---|
dirección |
Un DirectionType válido. |
velocidad |
Optional. Spin the motor using this velocity. The default velocity set by |
unidades |
Optional. A valid VelocityUnit or |
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 |
---|---|
rotación |
La posición a la que debe girar el motor. |
unidades |
Optional. A valid RotationUnits. The default is |
velocidad |
Optional. The velocity with which the motor will spin. The default velocity set by |
unidades_v |
Optional. A valid VelocityUnits. The default is |
esperar |
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 |
---|---|
dirección |
Un DirectionType válido. |
valor |
El valor al que debe girar el motor. |
unidades |
Optional. A valid RotationUnits. The default is |
velocidad |
Optional. The velocity with which the motor will spin. The default velocity set by |
unidades_v |
Optional. A valid VelocityUnits. The default is |
esperar |
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 |
---|---|
valor |
La nueva velocidad. |
unidades |
Optional. A valid VelocityUnits. The default is |
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 |
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 |
---|---|
modo |
A valid BrakeType. The default is |
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 |
---|---|
valor |
La nueva posición. |
unidades |
Optional. A valid RotationUnit. The default is |
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 |
---|---|
valor |
El nuevo tiempo de espera. |
unidades |
Optional. A valid TimeUnit. The default is |
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 |
---|---|
valor |
El nuevo par máximo a utilizar. |
unidades |
A valid TorqueUnit, |
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.
Devuelve: El DirectionType actual en el que está girando el motor.
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 |
---|---|
unidades |
Optional. A valid RotationUnit. The default is |
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 |
---|---|
unidades |
Optional. A valid VelocityUnit. The default is |
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 |
---|---|
unidades |
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 |
---|---|
unidades |
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 |
---|---|
unidades |
Optional. A valid TorqueUnit. The default is |
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 |
---|---|
unidades |
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 |
---|---|
unidades |
Optional. A valid TemperatureUnits. The default is |
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 |
---|---|
unidades |
Optional. A valid VelocityUnit. The default is |
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()