Drivetrain#

Introduction#

The VEX 123 Robot features a two-wheel drivetrain, allowing the robot to move forward and backward, and turn to the left and right. The Drivetrain blocks allow you to precisely control the robot’s movement and modify timeout settings and heading values.

Below is a list of available blocks:

Actions — Move and turn the robot.

  • drive — Drive the robot forward or in reverse continuously.

  • drive for — Drive the robot forward or in reverse for a specific distance.

  • drive until — Drive the robot until a specified condition is met.

  • turn — Turn the robot right or left continuously.

  • turn for — Turn the robot right or left for a specified amount of degrees.

  • turn to heading — Turn the robot to a specific heading.

  • stop driving — Stops all robot movement.

Settings — Configure drivetrain timeout and heading.

Values — Return drivetrain status and heading.

  • drive is done? — Returns a Boolean indicating whether or not the robot is done driving.

  • drive heading — Returns the drivetrain’s heading in degrees.

Actions#

drive#

The drive block moves the robot in the specified direction. This is a non-waiting block, meaning it runs continuously until another Drivetrain block interrupts it or the project stops.

  drive [forward v]

Parameters

Description

direction

Drives the robot in one of the following directions:

  • forward
  • reverse

Example

  when started
  [Drive for 2 seconds.]
  drive [forward v]
  wait (2) seconds
  stop driving

drive for#

The drive for block is used to move the robot for a specified distance.

  drive [forward v] for (1) [steps v]

Parameters

Description

direction

Drives the robot in one of the following directions:

  • forward
  • reverse

distance

The distance, as an integer or decimal, that the robot will move, measured in units.

unit

The unit of measurement, which can be one of the following:

  • steps — One square on a 123 field.
  • mm (millimeters)

Example

  when started
  [Drive back and forth.]
  drive [forward v] for (3) [steps v]
  drive [reverse v] for (3) [steps v]

drive until#

The drive until block is used to move the robot until a specified condition is met.

  drive [forward v] until [object v]

Parameters

Description

direction

Drives the robot in one of the following directions:

  • forward
  • reverse

condition

The condition that stops the robot:

  • object — The Eye Sensor detects an object.
  • crash — The robot crashes into another object.
  • line — The Line Detector detects a line underneath the robot.

Example

  when started
  [Reverse after a crash.]
  drive [forward v] until [crash v]
  drive [reverse v] for (1) [steps v]

turn#

The turn block turns the drivetrain continuously left or right. This is a non-waiting block, meaning the drivetrain will keep turning until another Drivetrain block runs or the project stops.

  turn [right v]

Parameters

Description

direction

The direction the robot will turn:

  • left
  • right

Example

  when started
  [Turn for 2 seconds.]
  turn [right v]
  wait (2) seconds
  stop driving  

turn for#

The turn for block turns the drivetrain left or right for a specific number of degrees.

  turn [right v] for (90) degrees

Parameters

Description

direction

The direction the robot will turn:

  • left
  • right

angle

The angle, as an integer or decimal, at which the robot turns, ranging from -360 to 360 degrees.

Example

aria-description goes here#
  when started
  [Turn left, then turn around to the right.]
  turn [left v] for (90) degrees
  turn [right v] for (180) degrees

turn to heading#

The turn to heading block turns the drivetrain to face a specific heading.

  turn to heading (90) degrees

Parameters

Description

heading

The absolute heading the drivetrain will turn to, from -360 to 360 degrees.

Example

aria-description goes here#
  when started
  [Turn to face the cardinal directions.]
  turn to heading (90) degrees
  wait (2) seconds
  turn to heading (180) degrees
  wait (2) seconds
  turn to heading (270) degrees
  wait (2) seconds
  turn to heading (0) degrees
  wait (2) seconds

stop driving#

The stop driving block immediately stops all movement of the drivetrain.

aria-description goes here#
  stop driving

Parameters

Description

This block has no parameters.

Example

aria-description goes here#
  when started
  [Stop driving after 4 seconds.]
  drive [forward v]
  wait [4] seconds
  stop driving

Settings#

set drive timeout#

The set drive timeout block sets a time limit for how long a Drivetrain block will wait to reach its target. If the robot cannot complete the movement within the set time, it will stop automatically and continue with the next block.

Note: The Drivetrain’s time limit is used to prevent Drivetrain blocks that do not reach their target position from stopping the execution of other blocks in the stack.

aria-description goes here#
  set drive timeout to (1) seconds

Parameters

Description

time

The maximum number of seconds a Drivetrain block will run before stopping and moving to the next block.

Example

When started, limits drive time to 1 second and then turns 90 degrees.#
  when started
  [Turn right after driving for 1 second.]
  set drive timeout to (1) seconds
  drive [forward v] for (1000) [mm v]
  turn [right v] for (90) degrees

set drive heading#

The set drive heading block sets the robot’s current heading to a specified value.

aria-description goes here#
  set drive heading to (0) degrees

Parameters

Description

heading

The heading value to assign, in degrees.

Example

aria-description goes here#
  when started
  [Face the new 0 degree heading.]
  set drive heading to (90) degrees
  turn to heading (0) degrees

Values#

drive is done?#

The drive is done? block returns a Boolean indicating whether the drivetrain is not moving.

  • True - The drivetrain is not moving.

  • False - The drivetrain is moving.

Note: This block detects movement only when it is caused by the drive for, drive until, turn for, or turn to heading blocks.

    <drive is done?>

Parameters

Description

This block has no parameters.

Example

    when started
    [Glow blue after a crash.]
    drive [forward v] until [crash v]
    forever
      if <drive is done?> then
        glow [blue v]
      else
        glow [green v]

drive heading#

The drive heading block returns the drivetrain’s heading angle as a decimal number, in the range 0 to 359.99 degrees.

    (drive heading in degrees)

Parameters

Description

This block has no parameters.

Example

    when started
    [Display the heading after turning.]
    turn [right v] for (450) degrees
    print (drive heading in degrees) ▶