Transmisión#
Introducción#
El sistema de propulsión VEX GO utiliza un sensor inercial integrado para permitir movimientos precisos hacia adelante, hacia atrás y giros. Estos métodos permiten que el robot se desplace de forma continua o a distancias predefinidas, gire un número específico de grados o hacia una dirección determinada y responda a los cambios en su orientación.
La categoría de Tren de Transmisión también incluye métodos de configuración que permiten establecer las velocidades de avance y giro, definir el comportamiento de parada, aplicar tiempos de espera para evitar bloqueos en la ejecución y actualizar manualmente los valores de rumbo o rotación del robot.
A continuación se muestra una lista de todos los métodos:
Acciones: Mover y girar el robot.
drive— Moves the drivetrain in a specified direction indefinitely.drive_for— Moves the drivetrain for a set distance.drive_until— Moves the drivetrain until a condition is met.turn— Turns the drivetrain left or right indefinitely.turn_for— Turns the drivetrain for a set distance.turn_to_heading— Turns the drivetrain to a specified heading.turn_to_rotation— Turns the drivetrain to a specified rotation.stop— Stops the drivetrain using the currently configured stopping behavior.
Motadores: Establece las velocidades de movimiento y giro predeterminadas.
set_drive_velocity— Sets the default drive velocity for the drivetrain.set_turn_velocity— Sets the turning velocity for the drivetrain.set_stopping— Sets the stop behavior.set_timeout— Limits how long a drivetrain function waits before giving up if movement is blocked.set_heading— Sets a drivetrain’s heading to a specific value.set_rotation— Sets a drivetrain’s rotation to a specific value.
Funciones de obtención: devuelven el estado y la posición del robot.
get_heading— Returns a drivetrain’s current heading.get_rotation— Returns a drivetrain’s current rotation.get_velocity— Returns a drivetrain’s current velocity.get_yaw— Returns the yaw of the robot.get_roll— Returns the roll of the robot.get_pitch— Returns the pitch of the robot.get_crashed— Returns whether the robot has crashed.is_stopped— Returns whether a drivetrain is currently not moving.
Comportamiento#
drive#
drive mueve el tren motriz en una dirección específica indefinidamente.
Uso:
drivetrain.drive(direction)
Parámetros |
Descripción |
|---|---|
|
La dirección en la que se debe conducir:
|
# Build Used: Super Code Base 2.0
def main():
# Drive forward then stop
drivetrain.drive(FORWARD)
wait(2, SECONDS)
drivetrain.stop()
# Start threads — Do not delete
start_thread(main)
drive_for#
drive_for mueve el sistema de transmisión en una dirección específica durante una distancia establecida.
Usage:
drivetrain.drive_for(direction, distance, units, wait)
Parámetros |
Descripción |
|---|---|
|
La dirección en la que se debe conducir:
|
|
La distancia que debe recorrer el tren motriz, expresada en forma de número flotante o entero. |
|
Optional. The unit that represents the distance:
|
|
Optional.
|
# Build Used: Super Code Base 2.0
def main():
# Drive back and forth
drivetrain.drive_for(FORWARD, 100, MM)
drivetrain.drive_for(REVERSE, 4, INCHES)
# Start threads — Do not delete
start_thread(main)
drive_until#
drive_until mueve la transmisión hacia adelante hasta que se cumpla una determinada condición.
Uso:
drivetrain.drive_until(condition, wait)
Parámetros |
Descripción |
|---|---|
|
The condition that stops the drivetrain:
|
|
Optional.
|
# Build Used: Super Code Base 2.0
def main():
# Turn right after a crash
drivetrain.drive_until(CRASH)
drivetrain.turn_for(RIGHT, 90)
# Start threads — Do not delete
start_thread(main)
turn#
turn gira la transmisión hacia la izquierda o hacia la derecha indefinidamente.
Uso:
drivetrain.turn(direction)
Parámetros |
Descripción |
|---|---|
|
La dirección en la que girar:
|
# Build Used: Super Code Base 2.0
def main():
# Turn right and left, then stop
drivetrain.turn(RIGHT)
wait(2, SECONDS)
drivetrain.turn(LEFT)
wait(2, SECONDS)
drivetrain.stop()
# Start threads — Do not delete
start_thread(main)
turn_for#
turn_for turns the drivetrain left or right for a specified angle in degrees.
Uso:
drivetrain.turn_for(direction, angle, wait)
Parámetros |
Descripción |
|---|---|
|
La dirección en la que girar:
|
|
El número de grados que girará la transmisión, expresado como un número decimal o entero. |
|
Optional.
|
# Build Used: Super Code Base 2.0
def main():
# Turn right then left
drivetrain.turn_for(RIGHT, 90)
drivetrain.turn_for(LEFT, 90)
# Start threads — Do not delete
start_thread(main)
turn_to_heading#
turn_to_heading gira una transmisión hacia un rumbo específico.
Uso:
drivetrain.turn_to_heading(angle, wait)
Parámetros |
Descripción |
|---|---|
|
El rumbo para girar la transmisión para que quede como un flotante o un entero en grados. |
|
Optional.
|
# Build Used: Super Code Base 2.0
def main():
# Turn to face the cardinal directions
drivetrain.turn_to_heading(90)
wait(1, SECONDS)
drivetrain.turn_to_heading(180)
wait(1, SECONDS)
drivetrain.turn_to_heading(270)
wait(1, SECONDS)
drivetrain.turn_to_heading(0)
# Start threads — Do not delete
start_thread(main)
turn_to_rotation#
turn_to_rotation gira una transmisión a una rotación especificada.
Uso:
drivetrain.turn_to_rotation(angle, wait)
Parámetros |
Descripción |
|---|---|
|
La rotación para girar la transmisión para que quede orientada como un flotador o un número entero en grados. |
|
Optional.
|
# Build Used: Super Code Base 2.0
def main():
# Spin around twice
drivetrain.turn_to_rotation(720)
# Start threads — Do not delete
start_thread(main)
stop#
stop stops the drivetrain using the currently configured stopping behavior.
Uso:
drivetrain.stop()
Parámetros |
Descripción |
|---|---|
Este método no tiene parámetros. |
# Build Used: Super Code Base 2.0
def main():
# Drive forward then stop
drivetrain.drive(FORWARD)
wait(2, SECONDS)
drivetrain.stop()
# Start threads — Do not delete
start_thread(main)
Mutadores#
set_drive_velocity#
set_drive_velocity establece la velocidad de movimiento predeterminada para un tren de transmisión. Este ajuste de velocidad se utilizará en las llamadas posteriores a cualquier función de tren de transmisión.
Uso:
drivetrain.set_drive_velocity(velocity)
Parámetros |
Descripción |
|---|---|
|
La velocidad a la que se moverá la transmisión como un valor flotante o entero del 0 % al 100 %. |
# Build Used: Super Code Base 2.0
def main():
# Drive at different velocities
drivetrain.drive_for(FORWARD, 150, MM)
wait(1, SECONDS)
# Drive slow
drivetrain.set_drive_velocity(20)
drivetrain.drive_for(REVERSE, 50, MM)
wait(1, SECONDS)
# Drive fast
drivetrain.set_drive_velocity(100)
drivetrain.drive_for(FORWARD, 150, MM)
# Start threads — Do not delete
start_thread(main)
set_turn_velocity#
set_turn_velocity establece la velocidad de giro predeterminada de una transmisión. Esta configuración de velocidad se utilizará en las llamadas posteriores a cualquier función de transmisión.
Uso:
drivetrain.set_turn_velocity(velocity)
Parámetros |
Descripción |
|---|---|
|
La velocidad a la que girará la transmisión como un valor flotante o entero del 0 % al 100 %. |
# Build Used: Super Code Base 2.0
def main():
# Turn at different velocities
drivetrain.turn_for(RIGHT, 180)
wait(1, SECONDS)
# Turn fast
drivetrain.set_turn_velocity(100)
drivetrain.turn_for(RIGHT, 180)
# Start threads — Do not delete
start_thread(main)
set_stopping#
set_stopping establece el modo de detención de un tren motriz.
Uso:
drivetrain.set_stopping(brake)
Parámetros |
Descripción |
|---|---|
|
How the drivetrain will stop:
|
# Build Used: Super Code Base 2.0
def main():
drivetrain.set_drive_velocity(100)
# Drive, then coast to a stop
drivetrain.set_stopping(COAST)
drivetrain.drive(FORWARD)
wait(2, SECONDS)
drivetrain.stop()
# Start threads — Do not delete
start_thread(main)
set_timeout#
set_timeout establece un límite de tiempo que una función de transmisión esperará para alcanzar su objetivo. Si la transmisión no puede completar el movimiento dentro del tiempo establecido, se detendrá automáticamente y continuará con la siguiente función.
Nota: El límite de tiempo del sistema de transmisión impide que las funciones del sistema de transmisión que no alcanzan su posición objetivo bloqueen la ejecución del resto del proyecto.
Uso:
drivetrain.set_timeout(value, units)
Parámetros |
Descripción |
|---|---|
|
El número máximo de segundos que una función del sistema de transmisión se ejecutará antes de detenerse y pasar a la siguiente función, expresado como un número entero o decimal. |
|
Optional. The unit that represents the time:
|
# Build Used: Super Code Base 2.0
def main():
# Turn right after driving forward
drivetrain.set_timeout(1, SECONDS)
drivetrain.drive_for(FORWARD, 25, INCHES)
drivetrain.turn_for(RIGHT, 90)
# Start threads — Do not delete
start_thread(main)
set_heading#
set_heading establece el rumbo del tren motriz a un valor especificado.
Uso:
drivetrain.set_heading(value)
Parámetros |
Descripción |
|---|---|
|
El valor a utilizar para el nuevo rumbo en grados. |
# Build Used: Super Code Base 2.0
def main():
# Face the new 0 degree heading
drivetrain.set_heading(90)
drivetrain.turn_to_heading(0)
# Start threads — Do not delete
start_thread(main)
set_rotation#
set_rotation establece la rotación de la transmisión en un valor especificado.
Uso:
drivetrain.set_rotation(value)
Parámetros |
Descripción |
|---|---|
|
El valor a utilizar para la nueva rotación en grados. |
# Build Used: Super Code Base 2.0
def main():
# Spin counterclockwise two times
drivetrain.set_rotation(720)
drivetrain.turn_to_rotation(0)
# Start threads — Do not delete
start_thread(main)
Captadores#
get_heading#
get_heading devuelve el rumbo actual del tren motriz como un punto flotante en grados.
Uso:
drivetrain.get_heading()
Parámetros |
Descripción |
|---|---|
Este método no tiene parámetros. |
# Build Used: Super Code Base 2.0
def main():
# Monitor the heading while turning
monitor_sensor("drivetrain.get_heading")
drivetrain.turn_for(RIGHT, 450)
# Start threads — Do not delete
start_thread(main)
get_rotation#
get_rotation returns the current rotation of the drivetrain as a float in degrees.
Uso:
drivetrain.get_rotation()
Parámetros |
Descripción |
|---|---|
Este método no tiene parámetros. |
# Build Used: Super Code Base 2.0
def main():
# Monitor the rotation while turning
monitor_sensor("drivetrain.get_rotation")
drivetrain.turn_for(RIGHT, 450)
# Start threads — Do not delete
start_thread(main)
get_velocity#
get_velocity devuelve la velocidad actual del sistema de transmisión como un valor flotante en porcentaje.
Uso:
drivetrain.get_velocity()
Parámetros |
Descripción |
|---|---|
Este método no tiene parámetros. |
# Build Used: Super Code Base 2.0
def main():
# Display the velocity of the robot before and while moving
console.print("Start: ")
console.print(drivetrain.get_velocity())
console.new_line()
drivetrain.drive(FORWARD)
wait(1, SECONDS)
console.print("Moving: ")
console.print(drivetrain.get_velocity())
drivetrain.stop()
# Start threads — Do not delete
start_thread(main)
get_yaw#
get_yaw devuelve la guiñada actual del robot como un punto flotante en grados.
Uso:
drivetrain.get_yaw()
Parámetros |
Descripción |
|---|---|
Este método no tiene parámetros. |
# Build Used: Super Code Base 2.0
def main():
# Change the LED color based on the yaw while
# moving the robot by hand
monitor_sensor("drivetrain.get_yaw")
while True:
if drivetrain.get_yaw() > 0:
bumper.set_color(GREEN)
elif drivetrain.get_yaw() < 0:
bumper.set_color(RED)
else:
bumper.set_color(NONE)
# Start threads — Do not delete
start_thread(main)
get_roll#
get_roll devuelve el balanceo actual del robot como un flotante en grados.
Uso:
drivetrain.get_roll()
Parámetros |
Descripción |
|---|---|
Este método no tiene parámetros. |
# Build Used: Super Code Base 2.0
def main():
# Change the LED color based on the roll while
# moving the robot by hand
monitor_sensor("drivetrain.get_roll")
while True:
if drivetrain.get_roll() > 0:
bumper.set_color(GREEN)
elif drivetrain.get_roll() < 0:
bumper.set_color(RED)
else:
bumper.set_color(NONE)
# Start threads — Do not delete
start_thread(main)
get_pitch#
get_pitch devuelve el paso actual del robot como un flotante en grados.
Uso:
drivetrain.get_pitch()
Parámetros |
Descripción |
|---|---|
Este método no tiene parámetros. |
# Build Used: Super Code Base 2.0
def main():
# Change the LED color based on the pitch while
# moving the robot by hand
monitor_sensor("drivetrain.get_pitch")
while True:
if drivetrain.get_pitch() > 0:
bumper.set_color(GREEN)
elif drivetrain.get_pitch() < 0:
bumper.set_color(RED)
else:
bumper.set_color(NONE)
# Start threads — Do not delete
start_thread(main)
get_crashed#
get_crashed devuelve un valor booleano que indica si el robot se ha bloqueado o no.
True— The robot has crashed.False— The robot has not crashed.
Uso:
drivetrain.get_crashed()
Parámetros |
Descripción |
|---|---|
Este método no tiene parámetros. |
# Build Used: Super Code Base 2.0
def main():
# Drive until a crash
drivetrain.drive(FORWARD)
while not drivetrain.get_crashed():
wait(50, MSEC)
drivetrain.stop()
drivetrain.turn_for(RIGHT, 90)
# Start threads — Do not delete
start_thread(main)
is_stopped#
is_stopped devuelve un valor booleano que indica si un tren motriz no se está moviendo actualmente.
True— The drivetrain is stopped.False— The drivetrain is moving.
Note: is_stopped only detects movement from drivetrain methods that include a wait parameter.
Uso:
drivetrain.is_stopped()
Parámetros |
Descripción |
|---|---|
Este método no tiene parámetros. |
# Build Used: Super Code Base 2.0
def main():
# Turn when the drivetrain is done moving forward
drivetrain.drive_for(FORWARD, 200, MM, wait=False)
wait(0.25, SECONDS)
while True:
if drivetrain.is_stopped():
drivetrain.turn_for(RIGHT, 180)
break
else:
console.print("Still moving...")
wait(0.1, SECONDS)
console.clear()
# Start threads — Do not delete
start_thread(main)