Drivetrain#

Drive#

The Drive block is used to move the Drivetrain in the specified direction forever, until a new Drivetrain block is used, or the project is stopped.

This is a non-waiting block and allows any subsequent blocks to execute without delay.

aria-description goes here#
  drive [forward v]

The Drive block has one parameter than can be modified:

Parameter Options Description
Direction forward Makes the Drivetrain drive forward.
reverse Makes the Drivetrain drive in reverse.

In this example, the robot will drive forward for 2 seconds, then stop.

aria-description goes here#
  when started :: hat events
  drive [forward v]    
  wait (2) seconds    
  stop driving

Drive For#

The Drive For block is used to move the Drivetrain for a given distance.

This is can be a non-waiting or waiting block depending on if the and don’t wait option is used.

aria-description goes here#
  drive [forward v] for (200) [mm v] ▶

The Drive For block has three parameters than can be modified:

Parameter Options Description
Direction forward Makes the Drivetrain drive forward.
reverse Makes the Drivetrain drive in reverse.
Drive Distance A circular input field that can accept text or reporter blocks. The distance that the Drivetrain will drive for, based on selected Units parameter.
Units mm Changes the distance to be measured in millimeters.
inches Changes the distance to be measured in inches.

By default, the Drive For block will block any subsequent blocks from executing until it’s finished. By expanding the Drive for block to show and don’t wait, blocks will continue to execute while the Drivetrain is moving.

aria-description goes here#
  drive [forward v] for (200) [mm v] ◀ and don't wait

In this example, the robot will drive in reverse for 500 mm.

aria-description goes here#
  when started :: hat events
  drive [reverse v] for (500) [mm v] ▶

Turn#

The Turn block is used to rotate the Drivetrain forever, until a new Drivetrain block is used, or the program is stopped.

This is a non-waiting block and allows any subsequent blocks to execute without delay.

aria-description goes here#
  turn [right v]

The Turn block has one parameter than can be modified:

Parameter Options Description
Direction left Makes the Drivetrain turn towards the left.
right Makes the Drivetrain turn towards the right.

In this example, the robot will turn towards the left for 2 seconds, then stop.

aria-description goes here#
  when started :: hat events
  turn [right v]
  wait (2) seconds    
  stop driving

Turn For#

The Turn For block is used to rotate the Drivetrain for a given number of degrees.

This is can be a non-waiting or waiting block depending on if the and don’t wait option is used.

aria-description goes here#
  turn [right v] for (90) degrees ▶

The Turn For block has two parameters than can be modified:

Parameter Options Description
Direction left Makes the Drivetrain turn towards the left.
right Makes the Drivetrain turn towards the right.
Drive Distance A text field that can accept reporter blocks. The distance that the Drivetrain will turn for, based on selected Units parameter.

Select which direction the Drivetrain will turn.

By default, the Turn For block will block any subsequent blocks from executing until it’s finished. By expanding the Turn For block to show and don’t wait, blocks will continue to execute while the Drivetrain is moving.

aria-description goes here#
  turn [right v] for (90) degrees ◀ and don't wait

In this example, the robot turn left for 45 degrees.

aria-description goes here#
  when started :: hat events
  turn [left v] for (45) degrees ▶

Turn to Heading#

The Turn to Heading block is used to turn a Drivetrain to a specific heading using the built-in Gyro sensor.

This is can be a non-waiting or waiting block depending on if the and don’t wait option is used.

aria-description goes here#
  turn to heading (90) degrees ▶

The Turn to Heading block turns to an absolute degree measure. This means:

  • When the robot turns clockwise past 360 degrees, the degree measure will start increasing again from 0 degrees.

  • When the robot turns counterclockwise past 0 degrees, the degree measure start decreasing again from 360 degrees.

A top-down view of a VEX IQ robot within a blue circular diagram showing cardinal directions. The robot is facing upward (0°). The diagram indicates 90° to the right, 180° at the bottom, and 270° to the left. The robot has orange and gray components, with "VEX3" visible on its front panel. Wheels are visible on both sides of the robot.

By default, the Turn to Heading block will block any subsequent blocks from executing until it’s finished. By expanding the Turn to Heading block to show and don’t wait, blocks will continue to execute while the Drivetrain is moving.

aria-description goes here#
  turn to heading (90) degrees ◀ and don't wait

In this example, the robot will turn to face 270 degrees.

aria-description goes here#
  when started :: hat events
  turn to heading (270) degrees ▶

Turn to Rotation#

The Turn to Rotation block is used to turn a Drivetrain to a specific angle of rotation using the built-in Gyro sensor.

This is can be a non-waiting or waiting block depending on if the and don’t wait option is used.

aria-description goes here#
  turn to rotation (90) degrees ▶

The Turn to rotation block turns a cumulative degree measure. This means:

  • When the robot turns clockwise past the 360 degrees, the degree measure continues to increase.

  • When the robot turns counterclockwise past 0 degrees, the degree measure continues to decrease.

A top-down view of a VEX IQ robot within a blue circular diagram showing rotational degrees. The robot is facing right (90°). The diagram indicates 0° at the top, 90° to the right, 180° at the bottom, 270° to the left, 360° at the top again, and 450° to the right with a blue arrow. The robot has gray and orange components, with "VEXIQ" visible on its side panel. Wheels are visible on both sides of the robot. A red arrow points from the robot towards the 90° mark.

By default, the Turn to Rotation block will block any subsequent blocks from executing until it’s finished. By expanding the Turn to Rotation block to show and don’t wait, blocks will continue to execute while the Drivetrain is moving.

aria-description goes here#
  turn to rotation (90) degrees ◀ and don't wait

In this example, the robot will turn to 480 degrees.

aria-description goes here#
  when started :: hat events
  turn to rotation (480) degrees ▶

Stop Driving#

The Stop Driving block is used to stop the drivetrain.

This is a non-waiting block and allows any subsequent blocks to execute without delay.

aria-description goes here#
  stop driving

In this example, the robot will stop driving after 4 seconds.

aria-description goes here#
  when started :: hat events
  drive [forward v]
  wait (4) seconds
  stop driving

Set Drive Velocity#

The Set Drive Velocity block is used to set the speed of the Drivetrain.

This is a non-waiting block and allows any subsequent blocks to execute without delay.

aria-description goes here#
  set drive velocity to (50) %

The Set Drive Velocity block accepts a range from 1% to 100%. The default drive velocity is 50%.

In this example, the drive velocity is set to 100% before the robot drives forward for 600 MM.

aria-description goes here#
  when started :: hat events
  set drive velocity to (100) %
  drive [forward v] for (600) [mm v] ▶

Set Turn Velocity#

The Set Turn Velocity block is used to set the speed of the Drivetrain’s turns.

This is a non-waiting block and allows any subsequent blocks to execute without delay.

aria-description goes here#
  set turn velocity to (50) %

The Set turn velocity block accepts a range from 1% to 100%. The default turn velocity is 50%.

In this example, the turn velocity is set to 100% before the robot turns to the left for 180 degrees.

aria-description goes here#
  when started :: hat events
  set turn velocity to (100) %
  turn [left v] for (180) degrees ▶

Set Drive Stopping#

The Set Drive Stopping block is used to set the behavior of the Drivetrain when the robot stops moving.

This is a non-waiting block and allows any subsequent blocks to execute without delay.

aria-description goes here#
  set drive stopping to [brake v]

The Set Drive Stopping block has one parameter than can be modified:

Parameter Options Description
Drive Stopping Behavior brake The Drivetrain will come to an immediate stop.
coast The Drivetrain will spin gradually to a stop.
hold The Drivetrain will come to an immediate stop. If the Drivetrain is rotated by an outside force, the built-in encoder will move the Drivetrain back to its initial stopped position.

In this example, the Drivetrain moves for 2 seconds before coasting to a stop.

aria-description goes here#
  when started :: hat events
  [Set Drivetrain stopping behaviour to coast and start driving forward.]
  set drive stopping to [coast v]
  drive [forward v]
  [Drive forward for 2 seconds before stopping.]
  wait (2) seconds
  stop driving

Set Drive Timeout#

The Set Drive Timeout block is used to set a time limit for Drivetrain movement commands.

This is a non-waiting block and allows any subsequent blocks to execute without delay.

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

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

For instance, if a robot is unable to reach its target position because it encounters an obstacle like a wall, the drive block will continue running indefinitely. This would prevent any subsequent blocks in the stack from executing. By setting a time limit, the drive block will automatically stop after the specified duration, allowing the program to proceed to the next block even if the target position is not reached.

In this example, the Drivetrain is set to move forward for 25 inches with a timeout of 1 second. The robot won’t reach the target position within 1 second, so the Drive block will automatically stop, and the robot will turn right by 90 degrees.

aria-description goes here#
  when started :: hat events
  [Set drive timeout to 1 second.]
  set drive timeout to (1) seconds
  drive [forward v] for (25) [inches v] ▶
  turn [right v] for (90) degrees ▶

Set Drive Heading#

The Set Drive Heading block is used to set the Drivetrain’s Gyro heading value.

This is a non-waiting block and allows any subsequent blocks to execute without delay.

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

The Set Drive Heading block can be used to set the Drivetrain’s position to any given heading. This block can be used to reset the orientation of the Drivetrain’s gyro when the heading is set to a value of 0.

In this example, the Drivetrain’s Gyro heading will be set to 90 degrees.

aria-description goes here#
  when started :: hat events
  set drive heading to (90) degrees

Set Drive Rotation#

The Set Drive Rotation block is used to set the Drivetrain’s angle of rotation.

This is a non-waiting block and allows any subsequent blocks to execute without delay.

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

The Set Drive Rotation block can be used to set the Drivetrain’s angle of rotation to any given positive or negative value.

aria-description goes here#
  when started :: hat events
  set drive rotation to (115) degrees