Transmisión#

Introducción#

The VEX GO Drivetrain uses a built-in Inertial Sensor to support precise forward, reverse, and turning movements. These methods allow the robot to move continuously or for set distances, rotate by a specified number of degrees or to a heading, and respond to changes in its orientation.

The Drivetrain category also includes configuration methods that let you set drive and turn speeds, define stopping behavior, apply timeouts to avoid execution stalls, and manually update the robot’s heading or rotation values.

A continuación se muestra una lista de todos los métodos:

Actions — Move and turn the 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.

Mutators — Set default movement and turn speeds.

  • 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.

Getters — Return robot state and position.

  • 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

direction

La dirección en la que se debe conducir:

  • FORWARD
  • REVERSE

# 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

direction

La dirección en la que se debe conducir:

  • FORWARD
  • REVERSE

distance

La distancia que debe recorrer el tren motriz, expresada en forma de número flotante o entero.

units

Optional. The unit that represents the distance:

  • MM (default) — Millimeters
  • INCHES

wait

Optional.

  • wait=True (default) — The project waits until drive_for is complete before executing the next line of code.
  • wait=False — The project starts the action and moves on to the next line of code right away, without waiting for drive_for to finish.

# 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

condition

The condition that stops the drivetrain:

  • CRASH — Stops when the drivetrain crashes into an object.
  • OBJECT — Stops when the Eye Sensor detects an object. An Eye Sensor must be configured for this parameter to be used.

wait

Optional.

  • wait=True (default) — The project waits until drive_until is complete before executing the next line of code.
  • wait=False — The project starts the action and moves on to the next line of code right away, without waiting for drive_until to finish.

# 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

direction

La dirección en la que girar:

  • LEFT
  • RIGHT

# 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

direction

La dirección en la que girar:

  • LEFT
  • RIGHT

angle

The number of degrees the drivetrain will turn as a float or integer.

wait

Optional.

  • wait=True (default) — The project waits until turn_for is complete before executing the next line of code.
  • wait=False — The project starts the action and moves on to the next line of code right away, without waiting for turn_for to finish.

# 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

angle

El rumbo para girar la transmisión para que quede como un flotante o un entero en grados.

wait

Optional.

  • wait=True (default) — The project waits until turn_to_heading is complete before executing the next line of code.
  • wait=False — The project starts the action and moves on to the next line of code right away, without waiting for turn_to_heading to finish.

# 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

angle

La rotación para girar la transmisión para que quede orientada como un flotador o un número entero en grados.

wait

Optional.

  • wait=True (default) — The project waits until turn_to_rotation is complete before executing the next line of code.
  • wait=False — The project starts the action and moves on to the next line of code right away, without waiting for turn_to_rotation to finish.

# 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

velocity

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

velocity

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

brake

How the drivetrain will stop:

  • BRAKE — Stops immediately.
  • COAST — Slows gradually to a stop.
  • HOLD — Stops and resists movement using motor feedback.

# 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.

Note: The drivetrain’s time limit prevents drivetrain functions that do not reach their target position from blocking the execution of the rest of the project.

Uso:
drivetrain.set_timeout(value, units)

Parámetros

Descripción

value

The maximum number of seconds a drivetrain function will run before stopping and moving to the next function as an integer or float.

units

Optional. The unit that represents the time:

  • SECONDS (default)
  • MSEC — milliseconds

# 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

value

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

value

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)