Robot-Specific Blocks#
Introduction#
The VR Rover Robot includes a Drivetrain, Distance Sensor and actions unique to the Rover Rescue Playground.
All standard VEXcode VR blocks are available for use in the Rover Rescue Playground.
Below is a list of all available Robot-specific Blocks:
Drivetrain - Move and turn the VR Rover.
Actions
drive - Moves the VR Rover forward or reverse forever.
drive for - Moves the VR Rover forward or reverse for a specific distance.
turn - Turns the VR Rover left or right forever.
turn for - Turns the VR Rover left or right for a specific number of degrees.
turn to heading - Turns the VR Rover to face a specific heading.
go to object - Turns and drives the VR Rover to the selected object.
stop driving - Stops the VR Rover’s movement.
Settings
set drive velocity - Tells the VR Rover how fast to drive.
set turn velocity - Tells the VR Rover how fast to turn.
set drive heading - Changes the VR Rover’s current heading to a new heading.
set drive timeout – Sets how many seconds the VR Rover will try to finish a movement.
Values
drive is done - Reports whether the VR Rover is finished moving.
drive is moving - Reports whether the VR Rover is moving.
drive heading - Reports the VR Rover’s current heading from 0 to 359.99 degrees.
Actions - Interact with the rover’s resources, enemies, and built-in AI systems.
Actions
minerals action - Picks up, drops, or uses minerals.
absorb enemy radiation - Absorbs radiation from an enemy.
standby - Puts the VR Rover into standby mode until a battery threshold is reached.
Values
rover sees - Returns whether the VR Rover sees an object in its vision range.
rover detects - Returns whether the VR Rover detects minerals or enemies in its detect radius.
minerals in storage - Returns how many minerals the VR Rover is carrying.
storage capacity - Returns the VR Rover’s current carrying capacity.
rover direction - Returns the direction to an object in degrees.
rover distance - Returns the distance to an object in millimeters or inches.
rover location - Returns the X or Y coordinate of an object in millimeters or inches.
under attack - Returns whether the VR Rover is currently under attack.
enemy level - Returns the level of the closest detected enemy.
enemy radiation - Returns the radiation of the closest detected enemy.
battery level - Returns the VR Rover’s current battery level in %.
level - Returns the VR Rover’s current level.
XP - Returns the VR Rover’s current experience points.
when under attack - Runs attached blocks when the VR Rover is attacked.
when level up - Runs attached blocks when the VR Rover levels up.
Sensing - Detect nearby objects with the rover’s Distance Sensor.
Distance found an object - Returns whether the Distance Sensor detects an object.
object distance - Returns the distance to the nearest detected object.
The examples on this page use the default Playground start position.
Drivetrain#
The drivetrain controls how the VR Rover drives and turns. The drivetrain can move forward or reverse, turn left or right, turn to headings, and report its heading.
Actions#
drive#
The drive stack block moves the robot forward or reverse forever. The robot will continue to move until it is given another action, like turning or stopping.
drive [forward v]
Parameters |
Description |
|---|---|
direction |
The direction the robot moves: forward or reverse. |
Example
when started
[Drive forward, then stop.]
drive [forward v]
wait (2) seconds
stop driving
drive for#
The drive for stack block moves the robot forward or reverse for a specific distance. The project will wait until the robot is done moving before the next block in the stack runs.
drive [forward v] for (200) [mm v] ▶
Parameters |
Description |
|---|---|
direction |
The direction the robot moves: forward or reverse. |
distance |
The distance the robot drives. This can be an integer or a decimal. |
unit |
The distance unit: mm (millimeters) or inches. |
and don’t wait |
Select the arrow ( ▶ ) to expand the block to say and don’t wait, so the next block in the stack will run right away. |
Example
when started
[Drive forward for 500 mm.]
drive [forward v] for (500) [mm v] ▶
turn#
The turn stack block turns the robot left or right forever. The robot will continue to turn until it is given another action, like driving or stopping.
turn [right v]
Parameters |
Description |
|---|---|
direction |
The direction the robot turns: left or right. |
Example
when started
[Turn right, then stop.]
turn [right v]
wait (2) seconds
stop driving
turn for#
The turn for stack block turns the robot left or right for a specific number of degrees. The turn is relative to the current position of the robot. The project will wait until the robot is done turning before the next block in the stack runs.
turn [right v] for (90) degrees ▶
Parameters |
Description |
|---|---|
direction |
The direction the robot turns: left or right. |
angle |
The number of degrees the robot turns. This can be an integer or a decimal. |
and don’t wait |
Select the arrow ( ▶ ) to expand the block to say and don’t wait, so the next block in the stack will run right away. |
Example
when started
[Turn left, then turn right.]
turn [left v] for (90) degrees ▶
turn [right v] for (180) degrees ▶
turn to heading#
A heading is the direction the robot is facing, measured in degrees. The turn to heading stack block turns the robot to face a specific heading from -359 to 359 degrees. The robot will turn the shortest direction to reach the target heading.
The starting heading is 0 degrees.
The project will wait until the robot is done turning before the next block in the stack runs.
turn to heading (90) degrees ▶
Parameters |
Description |
|---|---|
heading |
The heading the robot should face, from -359 to 359 degrees. |
and don’t wait |
Select the arrow ( ▶ ) to expand the block to say and don’t wait, so the next block in the stack will run right away. |
Example
when started
[Turn to face east.]
turn to heading (90) degrees ▶
go to object#
The go to object stack block turns and drives the VR Rover to the selected object.
go to [minerals v] ▶
Parameters |
Description |
|---|---|
object |
Which object the VR Rover will go to:
|
and don’t wait |
Select the arrow ( ▶ ) to expand the block to say and don’t wait, so the next block in the stack will run right away. |
If the VR Rover detects multiple minerals or multiple enemies, it will move to the closer option.
If minerals or an enemy are not detected in the rover’s visual range when the block runs, the robot will not drive. The base can always be targeted.
Example
when started
[Drive to the closest mineral.]
go to [minerals v] ▶
stop driving#
The stop driving stack block stops the robot’s movement.
stop driving
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
when started
[Drive forward, then stop.]
drive [forward v]
wait (4) seconds
stop driving
Settings#
set drive velocity#
The set drive velocity stack block tells the robot how fast to drive. A higher percentage makes the robot drive faster and a lower percentage makes the robot drive slower.
Every project begins with the robot driving at 50% velocity by default.
Note: A higher velocity makes the robot drive faster, but it may be less precise. A lower velocity makes the robot drive slower, but it can be more precise.
set drive velocity to (50) [% v]
Parameters |
Description |
|---|---|
velocity |
The velocity to drive with from 0% to 100%. |
unit |
The velocity unit: % |
Example
when started
[Move faster.]
set drive velocity to (100) [% v]
drive [forward v] for (100) [mm v] ▶
set turn velocity#
The set turn velocity stack block tells the robot how fast to turn. A higher percentage makes the robot turn faster and a lower percentage makes the robot turn slower.
Every project begins with the robot turning at 50% velocity by default.
Note: A higher velocity makes the robot turn faster, but it may be less precise. A lower velocity makes the robot turn slower, but it can be more precise.
set turn velocity to (50) [% v]
Parameters |
Description |
|---|---|
velocity |
The velocity to turn with from 0% to 100%. |
unit |
The velocity unit: % |
Example
when started
[Turn faster.]
set turn velocity to (100) [% v]
turn [right v] for (90) degrees ▶
set drive heading#
A heading is the direction the robot is facing, measured in degrees. The set drive heading stack block changes the robot’s current heading to a new heading value.
For example, if the robot has turned to face right, setting the heading to 0 degrees makes that right-facing position the new 0 degrees. Then the robot can turn to other positions based on that new heading.
set drive heading to (0) degrees
Parameters |
Description |
|---|---|
heading |
The heading value, in degrees, to set for the robot. |
Example
when started
[Set the heading, then turn to 0 degrees.]
set drive heading to (90) degrees
turn to heading (0) degrees ▶
set drive timeout#
The set drive timeout stack block sets how many seconds the robot will try to finish a movement. If the robot cannot finish in that time it will stop trying and move on to the next block in the stack. This keeps the robot from getting stuck on a movement.
set drive timeout to (1) seconds
Parameters |
Description |
|---|---|
time |
The number of seconds the robot can try to finish a movement. This can be a whole number or a decimal. |
Example
when started
[Drive for at most 1 second.]
set drive timeout to (1) seconds
drive [forward v] for (25) [inches v] ▶
Values#
drive is done#
The drive is done Boolean block reports whether the robot is finished moving. This can be used to control the timing of other behaviors based on the robot’s movement.
True - The robot is finished moving.
False - The robot is still moving.
This block works together with drivetrain blocks that have the and don’t wait parameter.
<drive is done?>
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
when started
[Start turning when the drive is complete.]
drive [forward v] for (200) [mm v] ◀ and don't wait
wait until <drive is done?>
turn [right v] for (360) degrees ▶
drive is moving#
The drive is moving Boolean block reports whether the robot is moving. This can be used to control the timing of other behaviors based on the robot’s movement.
True - The robot is moving.
False - The robot is not moving.
This block works together with drivetrain blocks that have the and don’t wait parameter.
<drive is moving?>
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
when started
[Print while the rover is moving.]
drive [forward v] for (200) [mm v] ◀ and don't wait
while <drive is moving?>
print [Still Moving...] ▶
wait (0.1) seconds
clear all rows
end
print [Done!] ▶
drive heading#
A heading is the direction the robot is facing, measured in degrees. The drive heading reporter block reports that heading from 0 to 359.99 degrees.
The robot’s starting heading is 0 degrees.
(drive heading in degrees)
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
when started
[Display the heading after turning.]
turn [right v] for (90) degrees ▶
print (drive heading in degrees) ▶
set cursor to next row
Actions#
Actions#
minerals action#
minerals [pick up v]
Parameters |
Description |
|---|---|
action |
What to do with minerals:
|
Picking up minerals stores them in the VR Rover until they are dropped or used.
Using minerals replenishes some of the VR Rover’s energy. Minerals can only be used if they are on the ground.
The VR Rover gains Experience Points (XP) by using minerals or dropping them at the base.
Example
when started
[Drive to the closest mineral and pick it up.]
go to [minerals v] ▶
minerals [pick up v]
absorb enemy radiation#
The absorb enemy radiation block absorbs radiation from an enemy in the Rover Rescue Playground.
absorb radiation
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
when started
[Drive to the closest enemy and absorb radiation.]
go to [enemy v] ▶
absorb radiation
standby#
The standby block puts the VR Rover into standby mode until the specified battery threshold is reached.
standby until [50] % battery
Parameters |
Description |
|---|---|
percent |
The battery threshold that causes the VR Rover to exit standby mode, from 0 to 100. |
While in standby, the VR Rover uses its battery more slowly, but the Number of Days Survived counter increases at a higher rate.
When the battery reaches the selected threshold, the VR Rover exits standby mode and returns to normal battery usage and day progression.
If the selected threshold is equal to or above the current battery level, the VR Rover will not enter standby mode.
Example
when started
[Wait in standby until battery reaches 35%.]
standby until [35] % battery
go to [minerals v] ▶
Values#
rover sees#
The rover sees block returns a Boolean indicating whether the VR Rover sees the selected object using its built-in AI technology.
True - The selected object is within 1000 millimeters of the VR Rover and within its field of view.
False - The selected object is farther than 1000 millimeters away and/or outside the field of view.
<sees [minerals v]?>
Parameters |
Description |
|---|---|
object |
Which object to check for:
|
The VR Rover’s field of view is 40 degrees, shown in the mini-map as the gray translucent cone extending from the front of the rover.
Example
when started
forever
if <sees [minerals v]?> then
go to [minerals v] ▶
end
end
rover detects#
The rover detects block returns a Boolean indicating whether the VR Rover detects minerals or enemies using its built-in AI technology.
True - The selected object is within the rover’s detect radius.
False - The selected object is not within the rover’s detect radius.
<detects [minerals v]?>
Parameters |
Description |
|---|---|
object |
Which object to detect:
|
The VR Rover’s detect radius is 800 millimeters, shown in the mini-map as the yellow circle around the rover.
Example
when started
forever
if <detects [minerals v]?> then
go to [minerals v] ▶
end
end
minerals in storage#
The minerals in storage block returns the current amount of minerals the VR Rover has in its storage.
(minerals in storage)
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
when started
print (minerals in storage) ▶
set cursor to next row
storage capacity#
The storage capacity block returns the carrying capacity of the VR Rover’s storage.
(storage capacity)
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
when started
print (storage capacity) ▶
set cursor to next row
rover direction#
The rover direction block returns the direction from the VR Rover to the selected object in degrees.
([minerals v] direction in degrees)
Parameters |
Description |
|---|---|
object |
Which object’s direction to report:
|
For minerals and enemies, this block only reports values when the selected object is within 1000 millimeters and inside the rover’s 40 degree field of view.
If base is selected, the direction is reported even when the base is not in the field of view. For the base, this block reports a value from -180 to 180 degrees.
Example
when started
print ([minerals v] direction in degrees) ▶
set cursor to next row
rover distance#
The rover distance block returns the distance from the VR Rover to the selected object.
([minerals v] distance in [mm v] :: custom-actions)
Parameters |
Description |
|---|---|
object |
Which object’s distance to report:
|
unit |
The unit used to report the distance: mm or inches |
For minerals and enemies, this block only reports values when the selected object is within 1000 millimeters and inside the rover’s 40 degree field of view.
If base is selected, the distance is reported even when the base is not in the field of view.
Example
when started
print ([minerals v] distance in [mm v] :: custom-actions) ▶
set cursor to next row
rover location#
The rover location block returns the X or Y coordinate of the selected object using the rover’s built-in AI technology.
([minerals v] location [X v] in [mm v])
Parameters |
Description |
|---|---|
object |
Which object’s location to report:
|
axis |
Which coordinate to return:
|
unit |
The unit used to report the coordinate: mm or inches |
For minerals and enemies, this block only reports values when the selected object is within 1000 millimeters and inside the rover’s 40 degree field of view.
If base is selected, the location is reported even when the base is not in the field of view.
Example
when started
print ([base v] location [X v] in [mm v]) ▶
set cursor to next row
print ([base v] location [Y v] in [mm v]) ▶
set cursor to next row
under attack#
The under attack block returns a Boolean indicating whether the VR Rover is currently under attack from an enemy.
True - The VR Rover is under attack.
False - The VR Rover is not under attack.
<under attack?>
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
when started
forever
if <under attack?> then
drive [reverse v] for [500] [mm v] ▶
end
end
enemy level#
The enemy level block returns the level of the closest enemy detected by the VR Rover.
(enemy level)
Parameters |
Description |
|---|---|
This block has no parameters. |
When no enemies are detected in the VR Rover’s detect radius, this block returns 0.
Example
when started
forever
if <(enemy level) [math_equal v] [1]> then
go to [enemy v] ▶
else
drive [reverse v] for [500] [mm v] ▶
end
end
enemy radiation#
The enemy radiation block returns the radiation of the closest enemy detected by the VR Rover.
(enemy radiation)
Parameters |
Description |
|---|---|
This block has no parameters. |
When no enemies are detected in the VR Rover’s detect radius, this block returns 0.
Example
when started
print (enemy radiation) ▶
set cursor to next row
battery level#
The battery level block returns the current battery level of the VR Rover as a percent.
(battery level in % :: custom-actions)
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
when started
print (battery level in % :: custom-actions) ▶
set cursor to next row
level#
The level block returns the current level of the VR Rover.
(level)
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
when started
print (level) ▶
set cursor to next row
XP#
The XP block returns the current number of Experience Points the VR Rover has.
(XP)
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
when started
print (XP) ▶
set cursor to next row
when under attack#
The when under attack block runs its attached stack each time the VR Rover is attacked by an enemy.
when under attack
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
when under attack
absorb radiation
when level up#
The when level up block runs its attached stack each time the VR Rover moves from one level to the next.
when level up
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
when level up
print [The VR Rover has leveled up!] ▶
set cursor to next row
Sensing#
Distance#
Distance found an object#
The Distance found an object block returns a Boolean indicating whether the Distance Sensor has detected an object within 2000 mm.
True - The Distance Sensor has detected an object.
False - The Distance Sensor has not detected an object.
<[distance v] found an object?>
Parameters |
Description |
|---|---|
distance sensor |
Which Distance Sensor to use. In this Playground, the available sensor is |
Example
when started
[Turn until the Distance Sensor detects an object.]
turn [right v]
wait until <[distance v] found an object?>
stop driving
object distance#
The object distance block returns the distance of the nearest object from the Distance Sensor.
([distance v] in [mm v])
Parameters |
Description |
|---|---|
distance sensor |
Which Distance Sensor to use. In this Playground, the available sensor is |
unit |
The distance unit: mm or inches |
Example
when started
[Wait until the Distance Sensor detects an object, then print the distance.]
turn [right v]
wait until <[distance v] found an object?>
stop driving
print ([distance v] in [mm v]) ▶