Robot Specific Blocks#
Introduction#
The VIQRC Virtual Skills - Mix & Match Playground features blocks exclusive to the build designed for this Playground, including two motor options, a Distance Sensor, Optical Sensor, and Touch LED.
All standard VEXcode VR Blocks are available for use in the VIQRC Virtual Skills - Mix & Match Playground.
Below is a list of all available Playground specific Blocks:
Motion – Move and track the robot’s motors.
Actions
spin – Spins the selected motor or motor group indefinitely.
spin for – Spins a motor or group for a specific distance in degrees or turns.
spin to position – Spins a motor or motor group to a set position.
stop motor – Stops a specific motor or motor group from spinning.
Settings
set motor velocity – Sets the speed of a motor or motor group as a percentage.
set motor timeout – Limits how long a motor block waits before giving up if movement is blocked.
Position
motor position – Returns the motor’s current rotational position in degrees or turns.
set motor position – Sets the encoder value of a motor or motor group.
Values
motor is done? – Returns a Boolean indicating whether the motor is no longer spinning.
motor is spinning? – Returns a Boolean indicating whether the motor is currently spinning.
motor velocity – Returns the motor’s current velocity in %.
Sensing - Utilize the robot’s various sensors.
Distance
Distance found object? – Returns whether any object is currently detected.
object distance – Returns the distance of the nearest object from the Distance Sensor.
Optical
Optical found object? – Returns whether an object is detected.
Optical detects color? – Returns whether a specific color is detected.
Optical brightness – Returns the brightness percentage detected by the sensor.
Optical hue – Returns the hue value of the detected color.
when Optical – Executes the attached stack of blocks when the Optical Sensor detects or loses an object.
Touch LED
set TouchLED color – Sets the TouchLED to a selected color.
Motion#
Actions#
spin#
The spin block spins a selected motor or motor group in a specified direction using the current motor velocity.
spin [ClawMotor v] [open v]
Parameters |
Description |
---|---|
motor |
The motor or motor group to spin:
|
direction |
The direction to spin:
|
Example
when started :: hat events
[Place a pin atop another pin.]
spin [LiftMotor v] [up v] for [600] [degrees v] ▶
drive [forward v] for (140) [mm v] ▶
spin [ClawMotor v] [open v]
spin for#
The spin for block spins a selected motor or motor group for a specific amount of rotation using the current motor velocity, measured in degrees or turns.
spin [ClawMotor v] [open v] for (90) [degrees v] ▶
Parameters |
Description |
---|---|
motor |
The motor or motor group to spin:
|
direction |
The direction to spin:
|
distance |
The rotation amount, as an integer or decimal. |
unit |
The measurement unit, which can be one of the following:
|
expanding arrow |
By default, this is a waiting block, so the drivetrain will finish moving before running the next block. To make the drivetrain start moving and immediately run the next block right away, expand the block to say and don’t wait. |
Example
when started :: hat events
[Place a pin atop another pin.]
spin [LiftMotor v] [up v] for [600] [degrees v] ▶
drive [forward v] for (140) [mm v] ▶
spin [ClawMotor v] [open v]
spin to position#
The spin to position block spins a motor or motor group to a specific absolute position using the current motor velocity and motor position.
spin [ClawMotor v] to position (90) [degrees v] ▶
Parameters |
Description |
---|---|
motor |
The motor or motor group to spin:
|
position |
The target position to spin the motor or motor group to. |
unit |
The measurement unit, which can be one of the following:
|
expanding arrow |
By default, this is a waiting block, so the drivetrain will finish moving before running the next block. To make the drivetrain start moving and immediately run the next block right away, expand the block to say and don’t wait. |
Example
when started :: hat events
[Place a pin atop another pin.]
spin [LiftMotor v] to position [-2] [turns v] ▶
drive [forward v] for (140) [mm v] ▶
spin [ClawMotor v] [open v]
stop motor#
The stop motor block immediately stops the selected motor or motor group.
stop [ClawMotor v]
Parameters |
Description |
---|---|
motor |
The motor or motor group to stop:
|
Example
when started :: hat events
[Place a pin atop another pin.]
spin [LiftMotor v] [up v]
wait [2] seconds
stop [LiftMotor v]
drive [forward v] for (140) [mm v] ▶
spin [ClawMotor v] [open v]
Settings#
set motor velocity#
The set motor velocity block sets the default spinning speed of a motor or motor group as a percentage for all subsequent Motor blocks in the project.
set [ClawMotor v] velocity to (50) [% v]
Parameters |
Description |
---|---|
motor |
The motor or motor group to set the velocity of:
|
velocity |
Sets the default movement velocity from 0 to 100 as a percent. |
unit |
The unit that represents the velocity:
|
Example
when started :: hat events
[Place a pin atop another pin.]
set [LiftMotor v] velocity to [100] [% v]
spin [LiftMotor v] [up v] for [600] [degrees v] ▶
drive [forward v] for (140) [mm v] ▶
spin [ClawMotor v] [open 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.
Note: The Motor’s time limit is used to prevent Motor blocks that do not reach their target position from stopping the execution of other blocks in the stack.
set [ClawMotor v] timeout to (1) seconds
Parameters |
Description |
---|---|
motor |
The motor or motor group to set the timeout of:
|
time |
The maximum number of seconds a Motor block will run before stopping and moving to the next block. |
Example
when started :: hat events
[Place a pin atop another pin.]
set [LiftMotor v] timeout to [2] seconds
spin [LiftMotor v] [up v] for [5] [turns v] ▶
drive [forward v] for (140) [mm v] ▶
spin [ClawMotor v] [open v]
Position#
motor position#
The motor position block returns the total distance the selected motor or motor group has rotated.
([ClawMotor v] position in [degrees v])
Parameters |
Description |
---|---|
motor |
The motor or motor group to return the position of:
|
unit |
The unit of measurement, which can be one of the following:
|
Example
when started :: hat events
[Place a pin atop another pin.]
spin [LiftMotor v] [up v]
wait until <[-600] > ([LiftMotor v] position in [degrees v])>
stop [LiftMotor v]
drive [forward v] for (140) [mm v] ▶
spin [ClawMotor v] [open v]
set motor position#
The set motor position block sets a specific position value to a motor or motor group, which updates the encoder reading.
set [ClawMotor v] position to (0) [degrees v]
Parameters |
Description |
---|---|
motor |
The motor or motor group to set the position of:
|
position |
The encoder position value to set. |
unit |
The measurement unit, which can be one of the following:
|
Example
when started :: hat events
[Place a pin atop another pin.]
set [LiftMotor v] position to [100] degrees
spin [LiftMotor v] to position [-500] [degrees v] ▶
drive [forward v] for (140) [mm v] ▶
spin [ClawMotor v] [open v]
Values#
motor is done#
The motor is done? block returns a Boolean indicating whether the motor or motor group is not spinning.
True – The motor is not spinning.
False – The motor is spinning.
<[ClawMotor v] is done?>
Parameters |
Description |
---|---|
motor |
The motor or motor group to check if it is done spinning:
|
Example
when started :: hat events
[Place a pin atop another pin.]
spin [LiftMotor v] [up v] for [600] [degrees v] ◀ and don't wait
set drive velocity to [5] %
drive [forward v] for (140) [mm v] ▶
wait until <not <[LiftMotor v] is spinning?>>
spin [ClawMotor v] [open v]
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.
<[ClawMotor v] is spinning?>
Parameters |
Description |
---|---|
motor |
The motor or motor group to check if it is currently spinning:
|
Example
when started :: hat events
[Place a pin atop another pin.]
spin [LiftMotor v] [up v] for [600] [degrees v] ◀ and don't wait
set drive velocity to [5] %
drive [forward v] for (140) [mm v] ▶
wait until <[LiftMotor v] is done?>
spin [ClawMotor v] [open v]
motor velocity#
The motor velocity block returns the current rotational speed of the motor or motor group in a range from -100% to 100%.
([ClawMotor v] velocity in [% v])
Parameters |
Description |
---|---|
motor |
The motor or motor group to return the velocity of:
|
unit |
The unit that represents the velocity:
|
Example
when started :: hat events
[Place a pin atop another pin.]
set [LiftMotor v] velocity to [100] [% v]
spin [LiftMotor v] [up v] for [600] [degrees v] ◀ and don't wait
wait [0.5] seconds
print ([LiftMotor v] velocity in [% v]) ▶
drive [forward v] for (140) [mm v] ▶
spin [ClawMotor v] [open v]
Sensing#
Distance#
Distance found object?#
The Distance found object? block returns a Boolean indicating whether the Distance Sensor has detected an object.
True – The Distance Sensor has detected an object.
False – The Distance Sensor has not detected an object.
<[Distance v] found an object?>
Parameters |
Description |
---|---|
This block has no parameters. |
Example
Example coming soon!
object distance#
The object distance returns the distance of the nearest object from the Distance Sensor in a range from 24mm to 1000mm or 1 inch to 40 inches.
([Distance v] distance in [mm v])
Parameters |
Description |
---|---|
unit |
The unit that represents the distance:
|
Example
when started :: hat events
[Place a pin atop another pin then prepare to pick up attached pins.]
spin [LiftMotor v] [up v] for [600] [degrees v] ▶
drive [forward v] for (140) [mm v] ▶
spin [ClawMotor v] [open v]
while <[35] > ([Distance v] object distance in [mm v])>
spin [LiftMotor v] [down v]
Optical#
Optical found object?#
The Optical found object? block returns a Boolean indicating whether the Optical Sensor has detected an object.
True – The Optical Sensor has detected an object.
False – The Optical Sensor has not detected an object.
<[Optical v] found an object?>
Parameters |
Description |
---|---|
This block has no parameters. |
Example
when started :: hat events
[Place a pin atop another pin.]
spin [LiftMotor v] [up v] for [600] [degrees v] ▶
drive [forward v] for (140) [mm v] ▶
spin [ClawMotor v] [open v]
wait until <not <[Optical v] found an object?>>
spin [LiftMotor v] to position [0] [degrees v] ▶
Optical detects color?#
The Optical detects color? block returns a Boolean indicating whether the Optical Sensor has detected a specific color.
True – The Optical Sensor has detected the specified color.
False – The Optical Sensor has not detected the specified color.
<[Optical v] detects [red v]?>
Parameters |
Description |
---|---|
color |
Which color to check for:
|
Example
when started :: hat events
[Place a pin atop another pin.]
spin [LiftMotor v] [up v] for [600] [degrees v] ▶
drive [forward v] for (140) [mm v] ▶
spin [ClawMotor v] [open v]
wait until <not <[Optical v] detects [red v] ?>>
spin [LiftMotor v] to position [0] [degrees v] ▶
Optical brightness#
The Optical brightness block returns the amount of light detected by the Optical Sensor in a range from 0% to 100%.
([Optical v] brightness in %)
Parameters |
Description |
---|---|
This block has no parameters. |
Example
when started :: hat events
[Place a pin atop another pin.]
spin [LiftMotor v] [up v] for [600] [degrees v] ▶
drive [forward v] for (140) [mm v] ▶
spin [ClawMotor v] [open v]
wait until <[30] > ([Optical v] brightness in %)>
spin [LiftMotor v] to position [0] [degrees v] ▶
Optical hue#
The Optical hue block returns the hue value of the color detected by the Optical Sensor.
Hue values range from 0 to 359 degrees, corresponding to positions on the color wheel shown below.
([Optical v] hue in degrees)
Parameters |
Description |
---|---|
This block has no parameters. |
Example
when started :: hat events
[Place a pin atop another pin.]
spin [LiftMotor v] [up v] for [600] [degrees v] ▶
drive [forward v] for (140) [mm v] ▶
spin [ClawMotor v] [open v]
wait until <([Optical v] hue in degrees) > [0]>
spin [LiftMotor v] to position [0] [degrees v] ▶
when Optical#
The when Optical block runs its stack when the Optical Sensor detects or loses an object. You can have multiple when Optical blocks to run multiple stacks of blocks at once.
when [Optical v] [detects v] an object :: hat events
Parameters |
Description |
---|---|
action |
Which action to trigger the hat block:
|
Example
when started :: hat events
[Place a pin atop another pin.]
spin [LiftMotor v] [up v] for [600] [degrees v] ▶
drive [forward v] for (140) [mm v] ▶
spin [ClawMotor v] [open v]
when [Optical v] [loses v] an object :: hat events
[Lower the lift when the red pin is not in the claw.]
spin [LiftMotor v] to position [0] [degrees v] ▶
Touch LED#
set TouchLED color#
The set TouchLED color block sets the color of the Touch LED.
set TouchLED color to [none v]
Parameters |
Description |
---|---|
color |
Sets the LED’s color to:
|
Example
when started :: hat events
[Place a pin atop another pin.]
set TouchLED color to [red v]
spin [LiftMotor v] [up v] for [600] [degrees v] ▶
drive [forward v] for (140) [mm v] ▶
spin [ClawMotor v] [open v]
set TouchLED color to [none v]