Robot-Specific Blocks#

Introduction#

The VIQRC 21-22 Pitching In Playground features blocks exclusive to this Playground, including three motor options and the Color Sensor.

All standard VEXcode VR Blocks are available for use in the VIQRC 21-22 Pitching In Playground.

Below is a list of all available Playground-specific Blocks:

Motion - Move and track the robot’s motors.

Sensing - Utilize the robot’s various sensors.

  • Color

The examples on this page use the default Playground start position.

Motion#

Actions#

spin motor#

The spin motor block spins a selected motor in a specified direction using the current motor velocity.

    spin [IntakeMotor v] [intake v]

Parameters

Description

motor

The motor to spin:

  • IntakeMotor
  • CatapultMotor
  • CatapultTensionMotor

direction

The direction to spin depends on the selected motor. Intake Motor uses intake and outtake. Catapult Motor and Catapult Tension Motor use motor-specific forward and reverse directions.

Example

    when started
    [Spin the Intake Motor before stopping.]
    spin [IntakeMotor v] [intake v]
    wait (1) seconds
    stop [IntakeMotor v]

spin motor for#

The spin motor for block spins a selected motor for a specific amount of rotation using the current motor velocity, measured in degrees or turns.

    spin [IntakeMotor v] [intake v] for [90] [degrees v] ▶

Parameters

Description

motor

The motor to spin:

  • IntakeMotor
  • CatapultMotor
  • CatapultTensionMotor

direction

The direction to spin depends on the selected motor.

distance

The rotation amount, as an integer or decimal.

unit

The unit of measurement representing the distance:

  • degrees
  • turns

expanding arrow

By default, this is a waiting block, so the motor will finish moving before running the next block. Expand the block to say and don’t wait to make it non-waiting.

Example

    when started
    [Collect a Ball with the Intake Motor.]
    spin [IntakeMotor v] [intake v] for [1] [turns v] ▶

spin motor to position#

The spin motor to position block spins a motor to a specific absolute position using the current motor velocity and motor position.

    spin [CatapultMotor v] to position [90] [degrees v] ▶

Parameters

Description

motor

The motor to spin:

  • IntakeMotor
  • CatapultMotor
  • CatapultTensionMotor

position

The target position to spin the motor to.

unit

The unit of measurement:

  • degrees
  • turns

expanding arrow

By default, this is a waiting block, so the motor will finish moving before running the next block. Expand the block to say and don’t wait to make it non-waiting.

Example

    when started
    [Move the Catapult Motor to a launch position.]
    spin [CatapultMotor v] to position [2600] [degrees v] ▶

stop motor#

The stop motor block immediately stops the selected motor.

    stop [IntakeMotor v]

Parameters

Description

motor

The motor to stop:

  • IntakeMotor
  • CatapultMotor
  • CatapultTensionMotor

Example

    when started
    [Spin the Intake Motor, then stop it.]
    spin [IntakeMotor v] [intake v]
    wait (1) seconds
    stop [IntakeMotor v]

Settings#

set motor velocity#

The set motor velocity block sets the default spinning speed of a motor as a percentage for all subsequent Motor blocks in the project.

    set [CatapultMotor v] velocity to [50] [% v]

Parameters

Description

motor

The motor to set the velocity of:

  • IntakeMotor
  • CatapultMotor
  • CatapultTensionMotor

velocity

Sets the default movement velocity from 0 to 100 as a percent.

unit

The unit that represents the velocity:

  • %

Example

    when started
    [Set the Catapult Motor velocity before moving it.]
    set [CatapultMotor v] velocity to [75] [% v]
    spin [CatapultMotor v] to position [2600] [degrees v] ▶

set motor timeout#

The set motor timeout block sets a time limit for how long a Motor 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.

    set [CatapultMotor v] timeout to [1] seconds

Parameters

Description

motor

The motor to set the timeout of:

  • IntakeMotor
  • CatapultMotor
  • CatapultTensionMotor

time

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

Example

    when started
    [Limit how long the Catapult Motor will wait to move.]
    set [CatapultMotor v] timeout to [2] seconds
    spin [CatapultMotor v] to position [5000] [degrees v] ▶

Position#

motor position#

The motor position block returns the total distance the selected motor has rotated.

    ([CatapultMotor v] position in [degrees v])

Parameters

Description

motor

The motor to return the position of:

  • IntakeMotor
  • CatapultMotor
  • CatapultTensionMotor

unit

The unit of measurement:

  • degrees
  • turns

set motor position#

The set motor position block sets a specific position value to a motor, which updates the encoder reading.

    set [CatapultMotor v] position to [0] [degrees v]

Parameters

Description

motor

The motor to set the position of:

  • IntakeMotor
  • CatapultMotor
  • CatapultTensionMotor

position

The encoder position value to set.

unit

The unit of measurement:

  • degrees
  • turns

Example

    when started
    [Set the Catapult Motor position, then return to 0 degrees.]
    set [CatapultMotor v] position to [2600] [degrees v]
    spin [CatapultMotor v] to position [0] [degrees v] ▶

Values#

motor is done#

The motor is done? block returns a Boolean indicating whether the motor is not spinning.

  • True - The motor is not spinning.

  • False - The motor is spinning.

    <[IntakeMotor v] is done?>

Parameters

Description

motor

The motor to check if it is done spinning:

  • IntakeMotor
  • CatapultMotor
  • CatapultTensionMotor

motor is spinning?#

The motor is spinning? block returns a Boolean indicating whether the motor is spinning.

  • True - The motor is spinning.

  • False - The motor is not spinning.

    <[IntakeMotor v] is spinning?>

Parameters

Description

motor

The motor to check if it is currently spinning:

  • IntakeMotor
  • CatapultMotor
  • CatapultTensionMotor

motor velocity#

The motor velocity block returns the current rotational speed of the motor in a range from -100% to 100%.

    ([IntakeMotor v] velocity in [% v] :: custom-motion)

Parameters

Description

motor

The motor to return the velocity of:

  • IntakeMotor
  • CatapultMotor
  • CatapultTensionMotor

unit

The unit that represents the velocity:

  • %

Sensing#

Color#

Color found an object?#

The Color found an object? block returns a Boolean indicating whether the Color Sensor has detected an object near the sensor.

  • True - The Color Sensor has detected an object nearby.

  • False - The Color Sensor has not detected an object nearby.

    <[Color v] found an object?>

Parameters

Description

This block has no parameters.

Color detects color#

The Color detects color? block returns a Boolean indicating whether the Color Sensor has detected a specific color.

  • True - The Color Sensor has detected the specified color.

  • False - The Color Sensor has not detected the specified color.

    <[Color v] detects [red v]?>

Parameters

Description

color

Which color to check for:

  • red
  • green
  • blue
  • white
  • yellow
  • orange
  • purple
  • red violet
  • violet
  • blue violet
  • blue green
  • yellow green
  • yellow orange
  • red orange

color name#

The color name block returns the name of the color currently detected by the Color Sensor.

    ([Color v] color name)

Parameters

Description

This block has no parameters.

brightness#

The brightness block returns the amount of light detected by the Color Sensor in a range from 0% to 100%.

    ([Color v] brightness in %)

Parameters

Description

This block has no parameters.

hue#

The hue block returns the hue value of the color detected by the Color Sensor.

Hue values range from 0 to 359 degrees, corresponding to positions on the color wheel shown below.

A circular color wheel displaying a full spectrum of hues labeled with degree values around the perimeter, increasing in 30-degree increments from 0 degrees at the top to 360 degrees.

    ([Color v] hue in degrees)

Parameters

Description

This block has no parameters.