Robot-Specific Blocks#
Introduction#
The GO Competition - Mars Math Expedition Playground features blocks exclusive to the virtual GO Hero Robot, including Arm Motor controls and robot-specific sensing blocks.
All standard VEXcode VR Blocks are available for use in the GO Competition - Mars Math Expedition Playground.
Below is a list of all available Playground-specific Blocks:
Motion - Move and track the robot’s Arm Motor.
Actions
spin motor - Spins the Arm Motor indefinitely.
spin motor for - Spins the Arm Motor for a specific distance in degrees or turns.
spin motor to position - Spins the Arm Motor to a set position.
stop motor - Stops the Arm Motor.
Settings
set motor velocity - Sets the speed of the Arm Motor 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 Arm Motor’s current rotational position in degrees or turns.
set motor position - Sets the encoder value of the Arm Motor.
Values
motor is done? - Returns whether the Arm Motor is no longer spinning.
motor is spinning? - Returns whether the Arm Motor is currently spinning.
motor velocity - Returns the Arm Motor’s current velocity in %.
Sensing - Utilize the robot’s sensors.
Eye Sensor
Eye found an object? - Returns whether the Front Eye Sensor detects an object.
Eye detects color? - Returns whether the Front Eye Sensor detects a selected color.
Eye brightness - Returns the brightness detected by the Front Eye Sensor.
Eye hue - Returns the hue detected by the Front Eye Sensor.
Gyro Sensing
detected crash? - Returns whether the robot has crashed into a wall or object.
The examples on this page use the default Playground start position.
Motion#
Actions#
spin motor#
The spin motor block spins the Arm Motor in a specified direction using the current motor velocity.
spin [ArmMotor v] [up v]
Parameters |
Description |
|---|---|
direction |
The direction to spin the motor:
|
Example
when started
[Raise the Arm Motor, then stop.]
spin [ArmMotor v] [up v]
wait (1) seconds
stop [ArmMotor v]
spin motor for#
The spin motor for block spins the Arm Motor for a specific amount of rotation using the current motor velocity.
spin [ArmMotor v] [up v] for [90] [degrees v] ▶
Parameters |
Description |
|---|---|
direction |
The direction to spin the motor:
|
distance |
The rotation amount, as an integer or decimal. |
unit |
The unit of measurement representing the distance:
|
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
[Raise the Arm Motor by 200 degrees.]
spin [ArmMotor v] [up v] for [200] [degrees v] ▶
spin motor to position#
The spin motor to position block spins the Arm Motor to a specific absolute position using the current motor velocity and motor position.
spin [ArmMotor v] to position [90] [degrees v] ▶
Parameters |
Description |
|---|---|
position |
The target position to spin the motor to. |
unit |
The unit of measurement:
|
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 Arm Motor to 180 degrees.]
spin [ArmMotor v] to position [180] [degrees v] ▶
stop motor#
The stop motor block immediately stops the Arm Motor.
stop [ArmMotor v]
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
when started
[Raise the Arm Motor, then stop.]
spin [ArmMotor v] [up v]
wait (1) seconds
stop [ArmMotor v]
Settings#
set motor velocity#
The set motor velocity block sets the default spinning speed of the Arm Motor as a percentage for all subsequent Motion blocks in the project.
set [ArmMotor v] velocity to [50] %
Parameters |
Description |
|---|---|
velocity |
Sets the default movement velocity from 0% to 100%. |
Example
when started
[Set the Arm Motor velocity to 100%.]
set [ArmMotor v] velocity to [100] %
spin [ArmMotor v] [up v] for [1] [turns 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 [ArmMotor v] timeout to [1] seconds
Parameters |
Description |
|---|---|
time |
The maximum number of seconds a Motor block will run before stopping and moving to the next block. |
Example
when started
[Limit Arm Motor movement to 1 second.]
set [ArmMotor v] timeout to [1] seconds
spin [ArmMotor v] [up v] for [3] [turns v] ▶
Position#
motor position#
The motor position block returns the total distance the Arm Motor has rotated.
([ArmMotor v] position in [degrees v] :: custom-motion)
Parameters |
Description |
|---|---|
unit |
The unit of measurement:
|
Example
when started
[Print the Arm Motor position.]
print ([ArmMotor v] position in [degrees v] :: custom-motion) ▶
set motor position#
The set motor position block sets a specific position value to the Arm Motor, which updates the encoder reading.
set [ArmMotor v] position to [0] [degrees v]
Parameters |
Description |
|---|---|
position |
The encoder position value to set. |
unit |
The unit of measurement:
|
Example
when started
[Set the Arm Motor to 90 degrees, then return to 0 degrees.]
set [ArmMotor v] position to [90] [degrees v]
spin [ArmMotor v] to position [0] [degrees v] ▶
Values#
motor is done?#
The motor is done? block returns a Boolean indicating whether the Arm Motor is not spinning.
True - The motor is not spinning.
False - The motor is spinning.
Note: This block only detects movement from blocks that can expand to show the and don’t wait option.
<[ArmMotor v] is done?>
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
when started
[Check when the Arm Motor has finished moving.]
spin [ArmMotor v] [up v] for [180] [degrees v] ◀ and don't wait
wait (0.1) seconds
if <[ArmMotor v] is done?> then
print [Arm Motor is done.] ▶
end
motor is spinning?#
The motor is spinning? block returns a Boolean indicating whether the Arm Motor is spinning.
True - The motor is spinning.
False - The motor is not spinning.
Note: This block only detects movement from blocks that can expand to show the and don’t wait option.
<[ArmMotor v] is spinning?>
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
when started
[Check whether the Arm Motor is moving.]
spin [ArmMotor v] [up v] for [180] [degrees v] ◀ and don't wait
wait (0.1) seconds
if <[ArmMotor v] is spinning?> then
print [Arm Motor is spinning.] ▶
end
motor velocity#
The motor velocity block returns the current rotational speed of the Arm Motor in a range from -100% to 100%.
([ArmMotor v] velocity in [% v] :: custom-motion)
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
when started
[Print the Arm Motor velocity.]
print ([ArmMotor v] velocity in [% v] :: custom-motion) ▶
Sensing#
The virtual Hero Robot also has access to the standard Brain and Drivetrain Sensing Blocks.
Eye#
Eye found an object?#
The Eye found an object? block returns a Boolean indicating whether the Front Eye Sensor detects an object within range.
True - The sensor has detected an object.
False - The sensor has not detected an object.
<[FrontEye v] found an object?>
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
when started
[Check whether the Front Eye Sensor detects an object.]
if <[FrontEye v] found an object?> then
print [Object detected!] ▶
else
print [No object detected.] ▶
end
Eye detects color?#
The Eye detects color? block returns a Boolean indicating whether the Front Eye Sensor detects a specified color.
True - The sensor detects the specified color.
False - The sensor does not detect the specified color.
<[FrontEye v] detects [red v]?>
Parameters |
Description |
|---|---|
color |
The color to detect:
|
Example
when started
[Check whether the Front Eye Sensor detects blue.]
if <[FrontEye v] detects [blue v]?> then
print [Blue object detected.] ▶
end
Eye brightness#
The Eye brightness block returns the brightness detected by the Front Eye Sensor from 0% to 100%.
([FrontEye v] brightness in %)
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
when started
[Print the brightness detected by the Front Eye Sensor.]
print ([FrontEye v] brightness in %) ▶
Eye hue#
The Eye hue block returns the hue detected by the Front Eye Sensor in degrees from 0 to 359.
([FrontEye v] hue in degrees)
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
when started
[Print the hue detected by the Front Eye Sensor.]
print ([FrontEye v] hue in degrees) ▶
Gyro#
detected crash?#
The detected crash? block returns a Boolean indicating whether or not the robot crashed.
True - A crash was detected.
False - A crash was not detected.
<detected crash?>
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
when started
[Drive until the robot crashes, then stop.]
drive [forward v]
wait until <detected crash?>
stop driving