The VEX VR Robot has a multitude of sensors, including two Eye Sensors.
Eye Sensors on the VR Robot
The VR Robot has two Eye Sensors, one that faces forward, and another that faces down. The sensors can detect if there is an object present as well as detect color (red, green, blue, none).
The Eye Sensor values can be displayed on the Dashboard in VEXcode VR. To learn more about the Dashboard, view this article.
The Eye Sensor values can be displayed on the Monitor Console in VEXcode VR. To learn more about the Monitor Console, view this article.
Commands Used with the Eye Sensors
Eye sensor near object command
The Eye sensor near object command reports if the Eye Sensor is close enough to an object to detect a color (red, green, blue, none). The Front Eye Sensor and the Down Eye Sensor have respective near object commands.
The Eye sensor near object command returns a Boolean that reports True when the Eye Sensor is close to an object that has detectable colors, and reports False when it is not close enough to an object with detectable colors.
Eye sensor color command
The Eye sensor color command reports if the Eye Sensor detects a specific color.
The color that the Eye Sensor is looking for is set as the command's parameter. Both Eye Sensors can detect red, green, blue, or none.
The Eye sensor color command returns a Boolean that reports True when the Eye Sensor detects the selected color, and reports False when it does not detect the color set as the parameter.
Common Uses of the Eye Sensor
The Eye Sensors on the VR Robot can be used in many ways. One thing to note about the Down Eye Sensor, is that it is tuned to not detect the floor of a Playground as an object. Other items, such as disks, will register as an object.
The Eye Sensors can detect the color of an object near the sensor, such as the colored disks in the Disk Mover Playground or the red border around the Castle Crasher Playground. This is useful if you want the VR Robot to sort differently colored objects, drive up to a specifically colored object, or detect the color of objects as they pass by the sensor.
def main(): |
To use the example above, copy this code into VEXcode VR and run the project on the Disk Mover Playground. |
The VR Robot can use the Eye Sensors to initiate a sequence of behaviors when it is in the correct place to do so. For example, the VR Robot can drive forward until it detects that it is near an object, such as a wall, then turn 90 degrees, or drive in reverse to not crash into an object, such as a castle, disk, or wall.
def main(): |
To use the example above, copy this code into VEXcode VR and run the project on the Wall Maze Playground. |
The VR Robot can use the Eye Sensors to drive toward an object or surface until it is within a specific distance, without touching it. This can be used to make sure that the VR Robot does not fall off of a Playground or crash into walls.
def main(): |
To use the example above, copy this code into VEXcode VR and run the project on the Castle Crasher Playground. |
Eye Sensor Example Project
In the following example, the VR Robot will drive forward until the Front Eye Sensor detects a green object, then it will stop and wait, before driving in reverse. Notice that in the Dashboard, the Front Eye Sensor values are reporting True that an object was detected, and the color of that object (disk) is green.
def main(): |
To use the example above, copy this code into VEXcode VR and run the project on the Disk Maze Playground. |