Vision#
Introduction#
The VEX AIR Hornet’s Vision Sensor detects and tracks AprilTags. This allows the Hornet to analyze its surroundings, follow objects, and react based on detected visual data.
Below is a list of all available blocks:
Actions – Control the Vision feed and capture object data.
get object data – Captures data for AprilTags.
Settings – Adjust which detected objects are accessed.
set Vision object item – Selects a specific object from the detected object list.
Values – Retrieve object presence, classification, and properties.
Vision object exists? – Reports whether an object is detected.
Vision object is? – Checks if a detected object matches a specific classification.
Vision object is AprilTag ID – Checks if a detected AprilTag matches a specific ID.
Vision object count – Returns the number of detected objects.
Vision object property – Retrieves details such as:
centerX & centerY – Center position coordinates in the sensor’s view.
bearing – Horizontal angle relative to the front of the Vision Sensor.
angle – Angle of a detected Color Code.
rotation – Orientation of the object.
originX & originY – Top-left corner position coordinates in the sensor’s view.
id – Identification number of an AprilTag.
score – Identification number of an AprilTag.
type – Identification number of an AprilTag.
Actions#
get object data#
The get object data block filters data from the Vision Sensor frame. The Vision Sensor can detect AprilTags.
The dataset stores objects ordered from largest to smallest by width, starting at index 0. Each object’s properties can be accessed using Vision object property block. An empty dataset is returned if no matching objects are detected.
get [all AprilTags v] data from Vision [forward v] camera
Parameter |
Description |
---|---|
signature |
Filters the dataset to only include data of the given signature. Available signatures are:
|
Note: AprilTags 5 through 37 can be obtained by using the printed AprilTags from AIM Printables.
Example
Example coming soon!
Settings#
set Vision object item#
The set Vision object item block sets which item in the dataset to use.
set Vision object item to [1]
Parameters |
Description |
---|---|
item |
The number of the item in the dataset to use. |
Example
Example coming soon!
Values#
Vision object exists?#
The Vision object exists? block reports if the Vision Sensor currently detects any objects. This block returns a Boolean value:
True – The Vision Sensor detects an object.
False – The Vision Sensor does not detect an object.
Note: The get data block returns an empty list if no objects are detected, so if no objects exist, interacting with the empty list of Vision Objects will result in an error.
<Vision object exists?>
Parameter |
Description |
---|---|
This block has no parameters. |
Example
Example coming soon!
Vision object type is?#
The Vision object type is? block reports if the item in the dataset is a specific object type. This block returns a Boolean value.
True – The item in the dataset is the specific object type.
False – The item in the dataset is not the specific object type.
<Vision object type is [all AprilTags v] ?>
Parameter |
Description |
---|---|
object |
Which object to compare the item to:
|
Example
Example coming soon!
Vision object is AprilTag ID#
The Vision object is AprilTag ID? block reports if the AprilTag is a specific ID number. This block returns a Boolean value:
True – The AprilTag ID is the number.
False – The AprilTag ID is not the number.
<Vision object is AprilTag [1]>
Parameters |
Description |
---|---|
AprilTag number |
The number to compare against the detected AprilTag’s ID number from 0 to 37. |
Example
Example coming soon!
Vision object count#
The Vision object count block returns the amount of detected objects in the dataset.
(Vision object count)
Parameters |
Description |
---|---|
This block has no parameters. |
Example
Example coming soon!
Vision object property#
There are nine properties that are included with each object (shown below) stored after the get object data block is used.
(Vision object [width v])
Some property values are based off of the detected object’s position in the Vision Sensor’s view at the time that the Get object data block was used. The Vision Sensor has a resolution of 240 by 320 pixels.
Parameter |
Description |
---|---|
property |
Which property of the detected object to use: |
width#
width returns the width of the detected object in pixels as an integer from 1 to 320.
(Vision object [width v])
Example
Example coming soon!
height#
height returns the height of the detected object in pixels as an integer from 1 to 240.
(Vision object [height v])
Example
Example coming soon!
centerX#
centerX returns the x-coordinate of the center of the detected object in pixels as an integer from 0 to 320.
(Vision object [centerX v])
Example
Example coming soon!
centerY#
centerY returns the y-coordinate of the center of the detected object in pixels as an integer from 0 to 240.
(Vision object [centerY v])
Example
Example coming soon!
bearing#
bearing reports how far an object is to the left or right of the center of the Vision Sensor’s view as a degree. A value of 0 means it’s centered, positive values mean the object is to the right, and negative values mean the object is to the left.
(Vision object [bearing v])
Example
Example coming soon!
angle#
Documentation Coming Soon
rotation#
rotation returns the orientation of the detected AprilTag as an integer in degrees from 0 to 359.
(Vision object [rotation v])
Example
Example coming soon!
originX#
originX returns the x-coordinate of the top-left corner of the detected object’s bounding box in pixels as an integer from 0 to 320.
(Vision object [originX v])
Example
Example coming soon!
originY#
originY returns the y-coordinate of the top-left corner of the detected object’s bounding box in pixels as an integer from 0 to 240.
(Vision object [originY v])
Example
Example coming soon!
id#
id returns the identification number of the detected AprilTag as an integer.
(Vision object [id v])
Example
Example coming soon!
score#
score returns the confidence score of the detected AI Classification as an integer from 1 to 100, representing a percentage.
(Vision object [score v])
Example
Example coming soon!
type#
type returns the returns what type of object is detected. It will return the following:
Object Type |
Included Objects |
---|---|
AiVision.TAG_OBJECT |
AprilTags |
(Vision object [type v])
Example
Example coming soon!