Robot-Specific Blocks#
Introduction#
The Hero Bot, Flex, includes a ClawMotor, an ArmMotor, an AI Vision Sensor, a Distance Sensor, and a Game Positioning System (GPS) Sensor.
All standard VEXcode VR Blocks are available for use in the V5 26-27 Override Playground.
Below is a list of all available Robot-specific Blocks:
Drivetrain – Move and turn the robot.
Actions
drive — Moves the robot forward or reverse forever.
drive for — Moves the robot forward or reverse for a specific distance.
turn — Turns the robot left or right forever.
turn for — Turns the robot left or right for a specific number of degrees.
turn to heading — Turns the robot to face a specific heading.
turn to rotation — Turns the robot to a specific rotation.
stop driving — Stops the robot’s movement.
Settings
set drive velocity — Tells the robot how fast to drive.
set turn velocity — Tells the robot how fast to turn.
set drive heading — Changes the robot’s current heading to a new heading.
set drive rotation — Changes the robot’s current rotation to a new rotation.
set drive timeout — Sets how many seconds the robot will try to finish a movement.
Values
drive is done — Reports whether the robot is finished moving.
drive is moving — Reports whether the robot is moving.
drive heading — Reports the robot’s current heading from 0 to 359.99 degrees.
drive rotation — Reports the robot’s current rotation.
drive velocity — Reports how fast the robot is driving.
Motion – Move and track the robot’s motors.
Actions
spin motor – Spins a motor forward or reverse forever.
spin motor for – Spins a motor for a specific distance in degrees or turns.
spin motor to position – Spins a motor to a specific position.
stop motor – Stops a motor from spinning.
Settings
set motor velocity – Tells a motor how fast to spin.
set motor timeout – Sets how much time a motor will try to finish a movement.
set motor position – Changes the motor’s current position to a new value.
Values
motor is done – Reports whether the motor is finished moving.
motor is spinning – Reports whether the motor is spinning.
motor position – Reports the motor’s current position.
motor velocity – Reports how fast the motor is spinning, as a percentage from -100% to 100%.
AI Vision – Capture and analyze objects using the AI Vision Sensor.
Actions
get object data – Captures data for a specific signature, such as a detected AI Classification.
Settings
set object item – Selects a specific object from the list.
Values
object exists – Returns whether any classification was detected.
object is – Returns if a classification is detected.
object is AprilTag – Returns whether the detected object is an AprilTag matching a specific ID.
object count – Returns how many objects were detected.
object property – Returns details such as:
Sensing – Utilize the robot’s various sensors.
Distance
Distance found an object – Reports whether the Distance Sensor detects an object within range.
object distance – Reports the distance between the Distance Sensor and the nearest detected object.
GPS
GPS position – Returns the X or Y position from the GPS Sensor.
GPS heading – Returns the heading the robot is currently facing.
The examples on this page use Starting Location C from the Playground’s Pre-Match checklist.
Drivetrain#
The drivetrain controls how the VR Robot drives and turns. The drivetrain can move forward or reverse, turn left or right, turn to headings, and track its rotation.
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.
unidad [adelante v]
Parameters |
Description |
|---|---|
direction |
The direction the robot moves: forward or reverse. |
Example
cuando empezó :: hat events
[Raise the Arm, drive to the Goal, release the Pin.]
spin [ArmMotor v] [up v] for (300) [degrees v] ▶
unidad [adelante v]
esperar (0.5) segundos
deja de conducir
spin [ClawMotor v] [open v] for (180) [degrees v] ▶
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.
unidad [adelante v] para (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
cuando empezó :: hat events
[Raise the Arm, drive to the Goal, release the Pin.]
spin [ArmMotor v] [up v] for (300) [degrees v] ▶
drive [forward v] for (10) [inches v] ▶
spin [ClawMotor v] [open v] for (180) [degrees 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.
turno [derecha v]
Parameters |
Description |
|---|---|
direction |
The direction the robot turns: left or right. |
Example
cuando empezó :: hat events
[Score a Pin in a Neutral Goal.]
turno [izquierda v]
wait (0.78) seconds
deja de conducir
spin [ArmMotor v] [up v] for (800) [degrees v] ▶
unidad [adelante v] para (25) [pulgadas v] ▶
spin [ClawMotor v] [open v] for (180) [degrees v] ▶
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.
girar [derecha v] por (90) grado ▶
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
cuando empezó :: hat events
[Score a Pin in a Neutral Goal.]
turn [left v] for (110) degrees ▶
spin [ArmMotor v] [up v] for (800) [degrees v] ▶
unidad [adelante v] para (25) [pulgadas v] ▶
spin [ClawMotor v] [open v] for (180) [degrees v] ▶
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.
girar hacia el rumbo (90) grados ▶
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
cuando empezó :: hat events
[Score a Pin in a Neutral Goal.]
turn to heading (-110) degrees ▶
spin [ArmMotor v] [up v] for (800) [degrees v] ▶
unidad [adelante v] para (25) [pulgadas v] ▶
spin [ClawMotor v] [open v] for (180) [degrees v] ▶
turn to rotation#
The turn to rotation stack block turns the robot to a specific rotation.
Rotation is how much the robot has turned, measured in degrees. At the beginning of a project, the rotation value is set to 0 degrees. Rotation can also be set using the set drive rotation block.
Rotation values are absolute. This means the direction of the turn depends on the robot’s current rotation. Turning right increases the rotation, and turning left decreases the rotation.
For example, if the robot starts at 0 degrees and you turn to a rotation of 720 degrees, it will turn right twice. If you then turn to a rotation of 360 degrees, it will turn left once, because 360 is less than 720.
The project will wait until the robot is done turning before the next block in the stack runs.
girar a rotación (90) grados ▶
Parameters |
Description |
|---|---|
rotation |
The rotation value, in degrees, that the robot will turn to. 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
cuando empezó :: hat events
[Score a Pin in a Neutral Goal.]
turn to rotation (-110) degrees ▶
spin [ArmMotor v] [up v] for (800) [degrees v] ▶
unidad [adelante v] para (25) [pulgadas v] ▶
spin [ClawMotor v] [open v] for (180) [degrees v] ▶
stop driving#
The stop driving stack block stops the robot’s movement.
deja de conducir
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
cuando empezó :: hat events
[Score a Pin in a Neutral Goal.]
spin [ArmMotor v] [up v] for (300) [degrees v] ▶
unidad [adelante v]
esperar (0.5) segundos
deja de conducir
spin [ClawMotor v] [open v] for (180) [degrees v] ▶
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.
Establezca la velocidad de la unidad en (50) [% v]
Parameters |
Description |
|---|---|
velocity |
The velocity to drive with from 0% to 100%. |
unit |
The velocity unit: % |
Example
cuando empezó :: hat events
[Score a Pin in a Neutral Goal.]
turn [left v] for (110) degrees ▶
spin [ArmMotor v] [up v] for (800) [degrees v] ▶
Establezca la velocidad de la unidad en (100) [% v]
unidad [adelante v] para (25) [pulgadas v] ▶
spin [ClawMotor v] [open v] for (180) [degrees 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.
establecer la velocidad de giro a (50) [% v]
Parameters |
Description |
|---|---|
velocity |
The velocity to turn with from 0% to 100%. |
unit |
The velocity unit: % |
Example
cuando empezó :: hat events
[Turn to face the Neutral Goal faster.]
establecer la velocidad de giro a (100) [% v]
turn [left v] for (110) 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.
establecer el rumbo de la unidad a (0) grados
Parameters |
Description |
|---|---|
heading |
The heading value, in degrees, to set for the robot. |
Example
cuando empezó :: hat events
[Make facing the Neutral Goal the new heading.]
set drive heading to (110) degrees
girar hacia el rumbo (0) grados ▶
set drive rotation#
Rotation is how much the robot has turned, measured in degrees. At the beginning of a project, the rotation value is set to 0 degrees. The set drive rotation stack block changes the robot’s current rotation to a new value.
For example, if the robot has made two full turns to the right, its rotation value will be 720 degrees. Setting the rotation to 0 degrees will reset that rotation from 720 to 0 degrees. Then the robot can turn to rotations based on that new value.
establecer la rotación de la unidad a (0) grados
Parameters |
Description |
|---|---|
rotation |
The rotation value, in degrees, to set for the robot. This can be an integer or a decimal. |
Example
cuando empezó :: hat events
[Make facing the Neutral Goal the new rotation.]
set drive rotation to (110) degrees
girar a rotación (0) grados ▶
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.
Establezca el tiempo de espera de la unidad en (1) segundos
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
cuando empezó :: hat events
[Turn to face the Neutral Goal.]
set drive timeout to (0.8) seconds
turn [left v] for (180) degrees ▶
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.
<¿La unidad está lista?>
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
cuando empezó :: hat events
[Score a Pin in a Neutral Goal.]
turn [left v] for (110) degrees ▶
spin [ArmMotor v] [up v] for (800) [degrees v] ▶
drive [forward v] for (25) [inches v] ◀ and don't wait
esperar hasta <¿La unidad está lista?>
spin [ClawMotor v] [open v] for (180) [degrees v] ▶
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.
<¿La unidad se está moviendo?>
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
cuando empezó :: hat events
[Raise the Arm once stopped near the Goal.]
turn [left v] for (110) degrees ▶
drive [forward v] for (25) [inches v] ◀ and don't wait
mientras <¿La unidad se está moviendo?>
wait (0.005) seconds
fin
spin [ArmMotor v] [up v] for (800) [degrees v] ▶
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.
(rumbo de la unidad en grados)
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
cuando empezó :: hat events
[Turn to the Goal, then show heading.]
girar [derecha v] por (450) grado ▶
imprimir (rumbo de la unidad en grados) en la pantalla ◀ y coloque el cursor en la siguiente fila
drive rotation#
Rotation is how much the robot has turned, measured in degrees. At the beginning of a project, the rotation value is set to 0 degrees. The drive rotation reporter block reports the robot’s current rotation.
Turning right increases the rotation, and turning left decreases the rotation. For example, making two full turns to the right will report a rotation of 720 degrees.
(rotación de la unidad en grados)
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
cuando empezó :: hat events
[Spin to find a Pin, then show rotation.]
girar [derecha v] por (450) grado ▶
imprimir (rotación de la unidad en grados) en la pantalla ◀ y coloque el cursor en la siguiente fila
drive velocity#
The drive velocity reporter block reports how fast the robot is driving.
(velocidad de accionamiento en [% v])
Parameters |
Description |
|---|---|
unit |
The velocity unit: % |
Example
cuando empezó :: hat events
[Show speed while driving to the Goal.]
drive [forward v] for (150) [mm v] ▶
imprimir (velocidad de accionamiento en [% v]) en la pantalla ◀ y coloque el cursor en la siguiente fila
Motion#
Flex uses the ArmMotor to lift and lower the arm, and the ClawMotor to open and close the claw.
Each motor has its own direction options. The direction names describe how that motor moves on Flex.
Actions#
spin motor#
The spin motor stack block spins a motor in one of two directions forever. The motor will continue to spin until it is given another action, like spinning in a different direction or stopping.
girar [ArmMotor v] [arriba v]
Parameters |
Description |
|---|---|
motor |
The motor to spin: ArmMotor or ClawMotor. |
direction |
The direction the motor spins:
|
Example
cuando empezó
[Raise the Arm before driving toward a Pin.]
girar [ArmMotor v] [arriba v]
esperar (1) segundos
parada [ArmMotor v]
spin motor for#
The spin motor for stack block spins a motor for a specific distance. The spin is relative to the current position of the motor. The project will wait until the motor is done spinning before the next block in the stack runs.
spin [ArmMotor v] [up v] for (90) [degrees v] ▶
Parameters |
Description |
|---|---|
motor |
The motor to spin: ArmMotor or ClawMotor. |
direction |
The direction the motor spins:
|
distance |
The distance the motor spins. Degrees use integers. Turns can use integers or decimals. |
unit |
The distance unit: degrees or turns. |
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
cuando empezó
[Raise the Arm to carry the Pin to the Goal.]
spin [ArmMotor v] [up v] for (800) [degrees v] ▶
spin motor to position#
The spin motor to position stack block spins a motor to a specific position.
A motor’s position is how far it has spun, measured in degrees or turns. One turn is equal to 360 degrees. At the beginning of a project, the ArmMotor’s position is set to 0 degrees. The ClawMotor is the exception — it starts at 467 degrees (fully closed). The motor position can also be set using the set motor position block.
Position values are absolute. This means the direction of the spin depends on the motor’s current position.
For example, if the motor starts at 0 degrees and spins to a position of 720 degrees, it will spin forward two turns. If it then spins to a position of 360 degrees, it will spin reverse one turn, because 360 is less than 720.
girar [ArmMotor v] a la posición (90) [grados v] ▶
Parameters |
Description |
|---|---|
motor |
The motor to spin: ArmMotor or ClawMotor. |
position |
The position value the motor will spin to. Degrees use integers. Turns can use integers or decimals. |
unit |
The position unit: degrees or turns. |
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
cuando empezó
[Raise the Arm, then release the Pin.]
spin [ArmMotor v] to position (800) [degrees v] ▶
spin [ClawMotor v] [open v] for (180) [degrees v] ▶
stop motor#
The stop motor stack block stops the selected motor.
parada [ArmMotor v]
Parameters |
Description |
|---|---|
motor |
The motor to stop: ArmMotor or ClawMotor. |
Example
cuando empezó
[Raise the Arm partway to hold the Pin.]
girar [ArmMotor v] [arriba v]
esperar (1) segundos
parada [ArmMotor v]
Settings#
set motor velocity#
The set motor velocity stack block tells a motor how fast to spin. A higher percentage makes the motor spin faster and a lower percentage makes the motor spin slower.
Every project begins with each motor spinning at 50% velocity by default.
Note: A higher velocity makes the motor spin faster, but it may be less precise. A lower velocity makes the motor spin slower, but it can be more precise.
set [ArmMotor v] velocity to [50] [% v]
Parameters |
Description |
|---|---|
motor |
The motor to set the velocity of: ArmMotor or ClawMotor. |
velocity |
The speed the motor will spin at. Percent uses whole numbers from 0% to 100%. |
unit |
The velocity unit: %. |
Example
cuando empezó
[Raise the Arm fast to release the Pin.]
set [ArmMotor v] velocity to [100] [% v]
spin [ArmMotor v] [up v] for (800) [degrees v] ▶
spin [ClawMotor v] [open v] for (180) [degrees v] ▶
set motor timeout#
The set motor timeout stack block sets how much time a motor will try to finish a movement. If the motor cannot finish in that time, it will stop trying and move on to the next block in the stack. This keeps the motor from getting stuck on a movement.
Establezca el tiempo de espera [ArmMotor v] en [1] segundo
Parameters |
Description |
|---|---|
motor |
The motor to set the timeout of: ArmMotor or ClawMotor. |
time |
The number of seconds the motor can try to finish a movement. This can be a whole number or decimal. |
Example
cuando empezó
[Score a Pin in a Neutral Goal.]
turn [left v] for (110) degrees ▶
Establezca el tiempo de espera [ArmMotor v] en [1] segundo
spin [ArmMotor v] [up v] for (1800) [degrees v] ▶
unidad [adelante v] para (25) [pulgadas v] ▶
spin [ClawMotor v] [open v] for (180) [degrees v] ▶
Position#
motor position#
A motor’s position is how far it has spun, measured in degrees or turns. One turn is equal to 360 degrees. The motor position reporter block reports the motor’s current position.
At the beginning of a project, the ArmMotor’s position is set to 0 degrees. The ClawMotor is the exception — it starts at 467 degrees (fully closed). If the motor spins one full turn forward, the position increases. If the motor spins the other direction, the position decreases.
([ArmMotor v] position in [degrees v])
Parameters |
Description |
|---|---|
motor |
The motor to report the position of: ArmMotor or ClawMotor. |
unit |
The unit to report the motor position in: degrees or turns. |
Example
cuando empezó
[Raise the Arm, then release the Pin.]
while <([ArmMotor v] position in [degrees v]) < (800)>
girar [ArmMotor v] [arriba v]
wait (0.002) seconds
fin
parada [ArmMotor v]
spin [ClawMotor v] [open v] for (180) [degrees v] ▶
set motor position#
A motor’s position is how far it has spun, measured in degrees or turns. One turn is equal to 360 degrees. The set motor position stack block changes the motor’s current position to a new value.
For example, if a motor has spun to 180 degrees, setting the position to 0 degrees will reset that position from 180 to 0 degrees. Then the motor can spin to positions based on that new value.
Establezca la posición [ArmMotor v] en (0) [grados v]
Parameters |
Description |
|---|---|
motor |
The motor to set the position of: ArmMotor or ClawMotor. |
position |
The position value to set for the motor. Degrees use integers. Turns can use integers or decimals. |
unit |
The position unit: degrees or turns. |
Example
cuando empezó
[Reset encoder, raise Arm, place Pin.]
Establezca la posición [ArmMotor v] en (0) [grados v]
spin [ArmMotor v] to position (800) [degrees v] ▶
spin [ClawMotor v] [open v] for (180) [degrees v] ▶
Values#
motor is done#
The motor is done Boolean block reports whether the motor is finished moving. This can be used to control the timing of other behaviors based on the motor’s movement.
True — The motor is finished moving.
False — The motor is still moving.
This block works together with the following Motion blocks that have the and don’t wait parameter: spin motor for and spin motor to position.
<[ArmMotor v] ¿está hecho?>
Parameters |
Description |
|---|---|
motor |
The motor to report whether it is finished moving: ArmMotor or ClawMotor. |
Example
cuando empezó
[Raise the Arm while driving to the Goal.]
spin [ArmMotor v] to position (800) [degrees v] ◀ and don't wait
esperar (0.1) segundos
while <not <[ArmMotor v] is done?>>
unidad [adelante v]
wait (0.005) seconds
fin
deja de conducir
motor is spinning#
The motor is spinning Boolean block reports whether the motor is spinning. This can be used to control the timing of other behaviors based on the motor’s movement.
True — The motor is spinning.
False — The motor is not spinning.
This block works together with the following Motion blocks that have the and don’t wait parameter: spin motor for and spin motor to position.
<[ArmMotor v] esta girando?>
Parameters |
Description |
|---|---|
motor |
The motor to report whether it is spinning: ArmMotor or ClawMotor. |
Example
cuando empezó
[Raise the Arm while driving to the Goal, then release the Pin.]
spin [ArmMotor v] to position (800) [degrees v] ◀ and don't wait
esperar (0.1) segundos
while <[ArmMotor v] is spinning?>
drive [forward v] for (20) [mm v] ▶
fin
spin [ClawMotor v] [open v] for (180) [degrees v] ▶
motor velocity#
The motor velocity reporter block reports how fast the motor is spinning, as a percentage from -100% to 100%.
([ArmMotor v] velocity in [% v] :: custom-motion)
Parameters |
Description |
|---|---|
motor |
The motor to report the velocity of: ArmMotor or ClawMotor. |
unit |
The unit to report the motor velocity in: %. |
Example
cuando empezó
[Show Arm Motor velocity while raising.]
set [ArmMotor v] velocity to [100] [% v]
spin [ArmMotor v] to position (800) [degrees v] ◀ and don't wait
wait (0.2) seconds
print ([ArmMotor v] velocity in [% v] :: custom-motion) on screen ◀ and set cursor to next row
AI Vision#
Actions#
get object data#
The get object data block filters data from the AI Vision Sensor frame to a single signature — a saved description of something the sensor can recognize, such as a game element on the field.
The dataset stores objects ordered from largest to smallest by width, starting at index 0. Each object’s properties can be accessed using the AI Vision object property block. An empty dataset is returned if no matching objects are detected.
get [AI Classifications v] data from [AIVision v]
Parameter |
Description |
|---|---|
signature |
Filters the dataset to only include data of the given signature. Available signatures are:
|
Example
cuando empezó
[Raise the Arm, drive to the Goal, release the Pin.]
spin [ArmMotor v] [up v] for (300) [degrees v] ▶
drive [forward v] for (10) [inches v] ▶
spin [ClawMotor v] [open v] for (180) [degrees v] ▶
turn [left v] for (70) degrees ▶
[Turn to face the Pin.]
set turn velocity to (30) [% v]
para siempre
get [AI Classifications v] data from [AIVision v]
if <[AIVision v] object exists?> then
if <([AIVision v] object [centerX v]) < (140)> then
turno [izquierda v]
else if <([AIVision v] object [centerX v]) > (180)> then
turno [derecha v]
demás
deja de conducir
romper
fin
fin
fin
Settings#
set object item#
The set object item block sets which item in the dataset to use.
set [AIVision v] object item to [1]
Parameters |
Description |
|---|---|
item |
The number of the item in the dataset to use. |
Example
cuando empezó
[Raise the Arm, drive to the Goal, release the Pin.]
spin [ArmMotor v] [up v] for (300) [degrees v] ▶
drive [forward v] for (10) [inches v] ▶
spin [ClawMotor v] [open v] for (180) [degrees v] ▶
turn [left v] for (70) degrees ▶
get [AI Classifications v] data from [AIVision v]
[Check if any AI Classifications were detected in the last snapshot.]
if <[AIVision v] object exists?> then
[If any AI Classification is detected, check if any of them are a specific game element.]
if <[AIVision v] object is [RedBluePin v]?> then
print [RedBluePin detected.] ▶
demás
print [No RedBluePin detected.] ▶
fin
fin
Values#
object exists#
The object exists block returns a Boolean indicating whether any object is detected in the dataset.
True – The dataset includes a detected object.
False – The dataset does not include any detected objects.
<[AIVision v] object exists?>
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
cuando empezó
[Raise the Arm, drive to the Goal, release the Pin.]
spin [ArmMotor v] [up v] for (300) [degrees v] ▶
drive [forward v] for (10) [inches v] ▶
spin [ClawMotor v] [open v] for (180) [degrees v] ▶
turn [left v] for (70) degrees ▶
get [AI Classifications v] data from [AIVision v]
[Check if any AI Classifications were detected in the last snapshot.]
if <[AIVision v] object exists?> then
print ([AIVision v] object count) ◀ and set cursor to next row
fin
object is#
The object is block returns a Boolean indicating whether a detected object matches a specific classification.
True – The item in the dataset is the specific object.
False – The item in the dataset is not the specific object.
<[AIVision v] object is [RedBluePin v]?>
Parameter |
Description |
|---|---|
object |
Which object to compare the item to:
|
Example
cuando empezó
[Raise the Arm, drive to the Goal, release the Pin.]
spin [ArmMotor v] [up v] for (300) [degrees v] ▶
drive [forward v] for (10) [inches v] ▶
spin [ClawMotor v] [open v] for (180) [degrees v] ▶
turn [left v] for (70) degrees ▶
get [AI Classifications v] data from [AIVision v]
if <[AIVision v] object exists?> then
if <[AIVision v] object is [RedBluePin v]?> then
print [RedBluePin detected.] ▶
demás
print [No RedBluePin detected.] ▶
fin
fin
object is AprilTag#
The object is AprilTag block returns a Boolean indicating whether the detected object is an AprilTag that matches a specific ID.
True – The detected object is an AprilTag with the given ID.
False – The detected object is not an AprilTag with the given ID.
<[AIVision v] object is AprilTag [0] ?>
Parameter |
Description |
|---|---|
AprilTag ID |
The ID number to compare against the detected AprilTag. |
Example
cuando empezó
[Report if AprilTag 3 is detected.]
get [AprilTags v] data from [AIVision v]
if <[AIVision v] object exists?> then
if <[AIVision v] object is AprilTag [3] ?> then
print [That is 3!] ▶
demás
print [That isn't 3!] ▶
fin
fin
object count#
The object count block returns the number of detected objects in the dataset as an integer.
([AIVision] object count)
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
cuando empezó
[Raise the Arm, drive to the Goal, release the Pin.]
spin [ArmMotor v] [up v] for (300) [degrees v] ▶
drive [forward v] for (10) [inches v] ▶
spin [ClawMotor v] [open v] for (180) [degrees v] ▶
turn [left v] for (70) degrees ▶
get [AI Classifications v] data from [AIVision v]
if <[AIVision v] object exists?> then
print ([AIVision v] object count) ◀ and set cursor to next row
fin
object property#
There are six properties that are included with each object (shown below) stored after the get object data block is used.
([AIVision v] object [width v])
All property values describe the detected object’s position and size in the AI Vision Sensor’s view at the moment the get object data block was used. These values are measured in pixels, based on the sensor’s 320 by 240 pixel resolution.
Parameter |
Description |
|---|---|
property |
Which property of the detected object to use: |
width#
The width property reports the width of the detected object in pixels as a whole number from 1 to 320.
([AIVision v] object [width v])
Example
cuando empezó
[Raise the Arm, drive to the Goal, release the Pin.]
spin [ArmMotor v] [up v] for (300) [degrees v] ▶
drive [forward v] for (10) [inches v] ▶
spin [ClawMotor v] [open v] for (180) [degrees v] ▶
turn [left v] for (70) degrees ▶
[Approach the next Cup and Pin.]
set drive velocity to (30) [% v]
para siempre
get [AI Classifications v] data from [AIVision v]
if <[AIVision v] object exists?> then
if <([AIVision v] object [width v]) > (140)> then
deja de conducir
romper
demás
unidad [adelante v]
fin
fin
fin
height#
The height property reports the height of the detected object in pixels as a whole number from 1 to 240.
([AIVision v] object [height v])
Example
cuando empezó
[Raise the Arm, drive to the Goal, release the Pin.]
spin [ArmMotor v] [up v] for (300) [degrees v] ▶
drive [forward v] for (10) [inches v] ▶
spin [ClawMotor v] [open v] for (180) [degrees v] ▶
turn [left v] for (70) degrees ▶
[Approach the next Cup and Pin.]
set drive velocity to (30) [% v]
para siempre
get [AI Classifications v] data from [AIVision v]
if <[AIVision v] object exists?> then
if <([AIVision v] object [height v]) > (200)> then
deja de conducir
romper
demás
unidad [adelante v]
fin
fin
fin
centerX#
The centerX property reports the x-coordinate of the center of the detected object in pixels as a whole number from 0 to 320.
([AIVision v] object [centerX v])
Example
cuando empezó
[Raise the Arm, drive to the Goal, release the Pin.]
spin [ArmMotor v] [up v] for (300) [degrees v] ▶
drive [forward v] for (10) [inches v] ▶
spin [ClawMotor v] [open v] for (180) [degrees v] ▶
turn [left v] for (70) degrees ▶
[Turn and approach the next Cup and Pin.]
set turn velocity to (30) [% v]
para siempre
get [AI Classifications v] data from [AIVision v]
if <[AIVision v] object exists?> then
if <([AIVision v] object [centerX v]) < (140)> then
turn [left v] for (5) degrees ▶
demás
unidad [adelante v] para (25) [pulgadas v] ▶
romper
fin
fin
fin
centerY#
The centerY property reports the y-coordinate of the center of the detected object in pixels as a whole number from 0 to 240.
([AIVision v] object [centerY v])
Example
cuando empezó
[Raise the Arm, drive to the Goal, release the Pin.]
spin [ArmMotor v] [up v] for (300) [degrees v] ▶
drive [forward v] for (10) [inches v] ▶
spin [ClawMotor v] [open v] for (180) [degrees v] ▶
turn [left v] for (70) degrees ▶
[Approach the next Cup and Pin.]
set drive velocity to (30) [% v]
para siempre
get [AI Classifications v] data from [AIVision v]
if <[AIVision v] object exists?> then
if <([AIVision v] object [centerY v]) > (230)> then
deja de conducir
romper
demás
unidad [adelante v]
fin
fin
fin
originX#
The originX property reports the x-coordinate of the top-left corner of the detected object’s bounding box in pixels as a whole number from 0 to 320.
([AIVision v] object [originX v])
Example
cuando empezó
[Raise the Arm, drive to the Goal, release the Pin.]
spin [ArmMotor v] [up v] for (300) [degrees v] ▶
drive [forward v] for (10) [inches v] ▶
spin [ClawMotor v] [open v] for (180) [degrees v] ▶
turn [left v] for (70) degrees ▶
[Turn and approach the next Cup and Pin.]
set turn velocity to (30) [% v]
para siempre
get [AI Classifications v] data from [AIVision v]
if <[AIVision v] object exists?> then
if <([AIVision v] object [originX v]) < (100)> then
turn [left v] for (5) degrees ▶
demás
unidad [adelante v] para (25) [pulgadas v] ▶
romper
fin
fin
fin
originY#
The originY property reports the y-coordinate of the top-left corner of the detected object’s bounding box in pixels as a whole number from 0 to 240.
([AIVision v] object [originY v])
Example
cuando empezó
[Raise the Arm, drive to the Goal, release the Pin.]
spin [ArmMotor v] [up v] for (300) [degrees v] ▶
drive [forward v] for (10) [inches v] ▶
spin [ClawMotor v] [open v] for (180) [degrees v] ▶
turn [left v] for (70) degrees ▶
[Approach the next Cup and Pin.]
set drive velocity to (30) [% v]
para siempre
get [AI Classifications v] data from [AIVision v]
if <[AIVision v] object exists?> then
if <([AIVision v] object [originY v]) > (140)> then
deja de conducir
romper
demás
unidad [adelante v]
fin
fin
fin
Sensing#
Distance#
Distance found an object#
The Distance found an object Boolean block reports whether the Distance Sensor currently detects an object within 2000mm.
True — The Distance Sensor detects an object.
False — The Distance Sensor does not detect an object.
<[FrontDistance v] Encontraste un objeto?>
Parameters |
Description |
|---|---|
distance sensor |
The Distance Sensor to use. Choose from the Distance Sensors available for Flex. |
Example
cuando empezó :: hat events
[Turn until something is detected, then release the Pin.]
turno [derecha v]
esperar hasta <[FrontDistance v] Encontraste un objeto?>
deja de conducir
spin [ArmMotor v] [up v] for (300) [degrees v] ▶
drive [forward v] for (10) [inches v] ▶
spin [ClawMotor v] [open v] for (180) [degrees v] ▶
object distance#
The object distance reporter block reports the distance between the Distance Sensor and the nearest detected object.
([FrontDistance v] distancia en [mm v])
Parameters |
Description |
|---|---|
distance sensor |
The Distance Sensor to use. Choose from the Distance Sensors available for Flex. |
unit |
The distance unit: mm or inches. |
Example
cuando empezó :: hat events
[Drive until 200 mm from the Goal, then release the Pin.]
unidad [adelante v]
wait until <([FrontDistance v] distance in [mm v]) < (200)>
deja de conducir
spin [ArmMotor v] [up v] for (300) [degrees v] ▶
drive [forward v] for (10) [inches v] ▶
spin [ClawMotor v] [open v] for (180) [degrees v] ▶
GPS#
GPS position#
The GPS position block returns the positional offset of the robot’s turning reference point from the center of a field with the GPS (Game Positioning System™) Sensor.
([GPS v] position [X v] in [mm v])
Parameters |
Description |
|---|---|
axis |
Which axis to report:
|
units |
The unit to represent the position: mm or inches |
Example
cuando empezó :: hat events
[Raise the Arm, drive to the Goal, release the Pin.]
spin [ArmMotor v] [up v] for (300) [degrees v] ▶
unidad [adelante v]
wait until <([GPS v] position [X v] in [mm v]) > (-1370)>
deja de conducir
spin [ClawMotor v] [open v] for (180) [degrees v] ▶
GPS heading#
The GPS heading block returns the heading that the robot is currently facing based on the GPS (Game Positioning System™) Sensor’s readings from the VEX GPS Field Code from 0.00 to 359.99 degrees.
([GPS v] heading in degrees)
Parameters |
Description |
|---|---|
This block has no parameters. |
Example
cuando empezó :: hat events
[Raise the Arm, drive to the Goal, release the Pin.]
spin [ArmMotor v] [up v] for (300) [degrees v] ▶
drive [forward v] for (10) [inches v] ▶
spin [ClawMotor v] [open v] for (180) [degrees v] ▶
[Turn left to face the Neutral Goal.]
set turn velocity to (30) [% v]
turno [izquierda v]
wait until <([GPS v] heading in degrees) < (18)>
deja de conducir