Motion#

Introduction#

The VEX AIM Coding Robot features a holonomic drivetrain, allowing it to move in any direction and rotate independently. Motion provides blocks for movement, turning, speed adjustments, and position tracking.

Circular compass dial from 0-315 degrees surrounding a dark gray display with navy blue screen. The front of the robot faces 0 degrees on the compass dial.

Below is a list of available blocks:

Actions – Move and turn the robot.

  • move – Moves the robot forward, reverse, left, or right.

  • move at angle – Moves the robot in a specified direction using an angle.

  • move for – Moves the robot in a specific direction for a set distance.

  • move at angle for – Moves the robot at a specific angle for a set distance.

  • turn – Rotates the robot left or right.

  • turn for – Rotates the robot for a specified number of degrees.

  • turn to heading – Rotates the robot to face a specific heading.

  • move with controller – Allows the robot to be driven using the controller.

  • stop all movement – Stops all movement of the robot.

Settings – Adjust movement and turn speeds.

Position – Track and modify the robot’s position.

  • position – Returns the robot’s current x or y coordinate.

  • set robot position – Manually sets the robot’s x and y position.

Values – Check movement status.

  • move active? – Returns whether the robot is currently moving.

  • turn active? – Returns whether the robot is currently turning.

  • stopped? – Returns whether the robot is neither moving nor turning.

Actions#

move#

The move block moves the robot in four specific directions using the current move velocity.

move forward stack block#
    move [forward v]

Parameters

Description

direction

Move the robot in one of the following directions:

  • forward
  • reverse
  • left
  • right

Example

When started, move forward#
    when started :: hat events
    [Move forward]
    move [forward v]

move at angle#

The move at angle block moves the robot at a specified angle using the current move velocity.

move at 90 degrees stack block#
    move at (90) degrees

Parameters

Description

angle

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

Examples

When started, moves right at 90 degrees, waits 1 second, then moves forward at 0 degrees, waits 1 second, and stops all movement.#
    when started :: hat events
    [Move right, then move forward and stop.]
    move at (90) degrees
    wait (1) seconds
    move at (0) degrees
    wait (1) seconds
    stop all movement

When started, moves diagonally to the right at 45.33 degrees, waits 1 second, and then stops all movement.#
    when started :: hat events
    [Move diagonally to the right and stop.]
    move at (45.33) degrees
    wait (1) seconds
    stop all movement

move for#

The move for block moves the robot in four specific directions for a specific distance using the current move velocity.

move forward for 200 mm stack block#
    move [forward v] for (200) [mm v] ▶

Parameters

Description

direction

Move the robot in one of the following directions:

  • forward
  • reverse
  • left
  • right

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:

  • mm (millimeters)
  • inches

expanding arrow

By default, this is a waiting block, so the robot will finish moving before running the next block. To make the robot start moving and immediately run the next block right away, expand the block to say and don’t wait.

Example

when started, move forward for 200 mm stack block#
    when started :: hat events
    [Move forward for 200 mm]
    move [forward v] for (200) [mm v] ▶

move at angle for#

The move at angle for block moves the robot at a specific angle for a specified distance using the current move velocity.

move at angle for stack block#
    move at (45) degrees for (200) [mm v] ▶

Parameters

Description

angle

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

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:

  • mm (millimeters)
  • inches

expanding arrow

By default, this is a waiting block, so the robot will finish moving before running the next block. To make the robot start moving and immediately run the next block right away, expand the block to say and don’t wait.

Examples

When started, moves right at 90 degrees for 50 mm, then moves forward at 0 degrees for 100 mm.#
    when started :: hat events
    [Move right, then move forward.]
    move at (90) degrees for (50) [mm v] ▶
    move at (0) degrees for (100) [mm v] ▶

When started, drives forward at 0 degrees for 100 mm while blinking all LEDs red.#
    when started :: hat events
    [Drive forward and blink all LEDs red.]
    move at (0) degrees for (100) [mm v] ◀ and don't wait
    set [lightall v] LED color to [red v]
    wait (0.5) seconds
    set [lightall v] LED color to [off v]
    wait (0.5) seconds
    set [lightall v] LED color to [red v]
    wait (0.5) seconds
    set [lightall v] LED color to [off v]
    wait (0.5) seconds

turn#

The turn block turns the robot in a specific direction using the current turn velocity.

turn right stack block#
    turn [right v] 

Parameters

Description

direction

The direction in which the robot turns:

  • left
  • right

Example

When started, turns left, waits 1 second, and then stops all movement.#
    when started :: hat events
    [Turn left, then stop.]
    turn [left v] 
    wait (1) seconds
    stop all movement

turn for#

The turn for block turns the robot in a specified direction for a set distance relative to its current facing direction using the current turn velocity.

turn right for 90 degrees stack block#
    turn [right v] for (90) degrees ▶

Parameters

Description

direction

The direction in which the robot turns:

  • left
  • right

angle

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

expanding arrow

By default, this is a waiting block, so the robot will finish turning before running the next block. To make the robot start turning and immediately run the next block right away, expand the block to say and don’t wait.

Examples

When started, turns left for 90 degrees, then turns right for 180 degrees.#
    when started :: hat events
    [Turn left, then turn around to the right.]
    turn [left v] for (90) degrees ▶
    turn [right v] for (180) degrees ▶

When started, turns right for 180 degrees while blinking all LEDs blue.#
    when started :: hat events
    [Turn right and blink all LEDs blue.]
    turn [right v] for (180) degrees ◀ and don't wait
    set [lightall v] LED color to [blue v]
    wait (0.5) seconds
    set [lightall v] LED color to [off v]
    wait (0.5) seconds
    set [lightall v] LED color to [blue v]
    wait (0.5) seconds
    set [lightall v] LED color to [off v]
    wait (0.5) seconds

turn to heading#

The turn to heading block turns the robot to face a specific heading using the current turn velocity.

turn to heading 90 degrees stack block#
    turn to heading (270) degrees ▶

Parameters

Description

heading

The heading that the robot will turn to face from –360 to 360 degrees.

expanding arrow

By default, this is a waiting block, so the robot will finish turning before running the next block. To make the robot start turning and immediately run the next block right away, expand the block to say and don’t wait.

Examples

    when started :: hat events
    [Turn to face each cardinal direction.]
    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

When started, quickly turns to face 180 degrees while blinking all LEDs green.#
    when started :: hat events
    [Turn around quickly and blink all LEDs green.]
    turn to heading (180) degrees ◀ and don't wait
    set [lightall v] LED color to [green v]
    wait (0.5) seconds
    set [lightall v] LED color to [off v]
    wait (0.5) seconds
    set [lightall v] LED color to [green v]
    wait (0.5) seconds
    set [lightall v] LED color to [off v]
    wait (0.5) seconds

move with controller#

The move with controller block lets you drive the robot using the One Stick Controller. To use the controller, you need to put the block inside a loop - such as a “forever” loop. If the loop stops and there are no other blocks telling the robot to move, the robot will keep going in the last direction you pushed the joystick.

    move with controller

Parameters

Description

This block has no parameters.

Example

    when started :: hat events
    [Drive with the controller for five seconds.]
    reset timer :: custom-orientation
    while <(timer in seconds) [math_less_than v] [5]>
    move with controller
    end
    stop all movement

stop all movement#

The stop all movement block stops all movement of the robot.

stop all movement stack block#
    stop all movement

Parameters

Description

This block has no parameters.

Example

When started, turns right, waits 1 second, and then stops all movement.#
    when started :: hat events
    [Turn right, then stop.]
    turn [right v] 
    wait (1) seconds
    stop all movement

Settings#

set move velocity#

The set move velocity block sets the default movement speed as a percentage for all subsequent movement blocks in the project. A move velocity of 100% is equivalent to 200 millimeters per second (mmps).

set move melocity to 50% stack block#
    set move velocity to (50) %

Parameters

Description

velocity

Sets the default movement velocity as a percent.

Example

    when started :: hat events
    [Move forward at the default velocity.]
    set move velocity to (50) %
    move at (0) degrees for (100) [mm v] ▶
    wait (1) seconds
    [Move slower.]
    set move velocity to (20) %
    move at (0) degrees for (100) [mm v] ▶
    wait (1) seconds
    [Move faster.]
    set move velocity to (100) %
    move at (0) degrees for (100) [mm v] ▶
    wait (1) seconds

set turn velocity#

The set turn velocity block sets the default velocity as a percent for all subsequent turn blocks in the project. A turn velocity of 100% is equivalent to 150 degrees per second (dps).

set turn velocity to 50% stack block#
    set turn velocity to (50) %

Parameters

Description

velocity

Sets the default turn velocity as a percent.

Example

    when started :: hat events
    [Turn around at default velocity.]
    set turn velocity to (50) %
    turn [right v] for (180) degrees ▶
    wait (1) seconds
    [Turn around slower.]
    set turn velocity to (20) %
    turn [right v] for (180) degrees ▶
    wait (1) seconds
    [Turn around faster.]
    set turn velocity to (20) %
    turn [right v] for (180) degrees ▶
    wait (1) seconds

Position#

position#

The position block returns the robot’s current x or y-coordinate as an integer, measured in millimeters.

x position in mm reporter block#
    [x v] position in [mm v]

Parameters

Description

coordinate

The coordinate axis, which can be one of the following:

  • x
  • y

unit

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

  • mm (millimeters)
  • inches

Example

When started, moves forward 200 mm, resets position, moves diagonally at 45 degrees for 200 mm, and prints the updated X and Y coordinates on the screen.#
    when started :: hat events
    move at (0) degrees for (200) [mm v] ▶
    [Move forward and print the new coordinate and heading.]
    set robot position x: [0] y: [0]
    move at (45) degrees for (200) [mm v] ▶
    print ([x v] position in [mm v]) on screen ▶
    set cursor to next row on screen
    print ([y v] position in [mm v]) on screen ▶

set robot position#

The set robot position block sets the robot’s current position to specified values in millimeters (mm).

set position stack block#
    set robot position x: [0] y: [0]

Parameters

Description

x

The x-position to set for the robot, in mm.

y

The y-position to set for the robot, in mm.

Example

  when started :: hat events
  [Reset the robot's position after moving.]
  move [forward v] for [60] [mm v] ▶
  set robot position x: [0] y: [0]
  print ([y v] position in [mm v]) on screen ▶

Values#

move active?#

The move active? block returns a Boolean indicating whether the robot is currently moving.

  • True - The robot is moving.

  • False` - The robot is not moving.

is move active reporter block#
    <move active?>

Parameters

Description

This block has no parameters.

Example

When started, moves forward 200 mm while blinking all LEDs red. The LEDs turn on and off every 0.5 seconds while the robot is moving, then remain off after the movement stops.#
    when started :: hat events
    [Blink all of the LEDs when the robot is moving.]
    move at (0) degrees for (200) [mm v] ◀ and don't wait
    while <move active?>
        set [lightall v] LED color to [red v]
        wait (0.5) seconds
        set [lightall v] LED color to [off v]
        wait (0.5) seconds
    end
    set [lightall v] LED color to [off v]

turn active?#

The turn active? block returns a Boolean indicating whether the robot is currently turning.

  • True - The robot is turning.

  • False - The robot is not turning.

turn active reporter block#
    <turn active?>

Parameters

Description

This block has no parameters.

Example

When started, turns right for 180 degrees while blinking all LEDs red. The LEDs flash every 0.5 seconds while turning and turn off when the turn is complete.#
    when started :: hat events
    [Blink all of the LEDs while the robot is turning.]
    turn [right v] for (180) degrees ◀ and don't wait
    while <turn active?> 
        set [lightall v] LED color to [red v]
        wait (0.5) seconds
        set [lightall v] LED color to [off v]
        wait (0.5) seconds
    end
    set [lightall v] LED color to [off v]

stopped?#

The stopped? block returns a Boolean indicating whether the robot is neither moving nor turning.

  • True - The robot is not moving or turning.

  • False - The robot is moving or turning.

is stopped reporter block#
    <stopped?>

Parameters

Description

This block has no parameters.

Example

When started, the robot moves forward 200 mm while performing a light show, then turns right for 180 degrees while continuing the light show. The LEDs alternate between green and purple every 0.5 seconds while the robot is moving or turning. Once the robot stops, the light show ends, and the LEDs turn off.#
    define light show
        [Flash LEDs while the robot is moving or turning.]
        repeat until <stopped?>
            set [lightall v] LED color to [green v]
            wait (0.5) seconds
            set [lightall v] LED color to [purple v]
            wait (0.5) seconds
        end
    

    when started :: hat events
    [Blink all the LEDs while the robot is moving or turning.]
    move at (0) degrees for (200) [mm v] ◀ and don't wait
    light show
    turn [right v] for (180) degrees ◀ and don't wait
    light show