Eye#
Introduction#
The VEX VR Eye Sensor can detect objects and identify their color, brightness, and hue. It also allows you to adjust detection range and lighting settings for more accurate readings.
Below is a list of all available blocks:
eye near object? – Returns whether the Eye Sensor is near an object.
eye detects color? – Returns whether the Eye Sensor detects a specific color.
eye brightness – Return the brightness detected by the Eye Sensor.
when eye – Executes the attached stack of blocks when the Eye Sensor detects or loses an object.
eye near object?#
The eye near object? block returns a Boolean indicating whether or not the Eye Sensor detects an object within range.
True – The sensor has detected an object.
False – The sensor has not detected an object.
<[FrontEye v] 靠近对象?>
Parameters |
Description |
|---|---|
eye |
The Eye Sensor to detect objects with. |
Example
当开始
[Stop driving after detecting an object.]
驱动 [向前 v]
等待 (0.1) 秒
等到 <[FrontEye v] 靠近对象?>
驱动停止
eye detects color?#
The eye detects color? block returns a Boolean indicating whether the Eye Sensor detects a specified color, based on the detected hue value.
True – The sensor detects the specified color.
False – The sensor does not detect the specified color.
<[FrontEye v] 测得 [红色 v]?>
Parameters |
Description |
|---|---|
eye |
The Eye Sensor to detect colors with. |
color |
The color to detect:
|
Example
当开始
[Stop driving after detecting a green object.]
驱动 [向前 v]
等待 (0.1) 秒
等到 <[FrontEye v] 测得 [绿色 v]?>
驱动停止
eye brightness#
The eye brightness block returns the brightness detected by the Eye Sensor from 0% to 100%.
([FrontEye v] 亮度百分比)
Parameters |
Description |
|---|---|
eye |
The Eye Sensor to detect brightness from. |
Example
当开始
[Display whether a detected object is bright.]
驱动 [向前 v]
等到 <[FrontEye v] 靠近对象?>
等待 (0.1) 秒
如果 <([FrontEye v] 亮度百分比) [math_less_than v] [70]> 那么
打印 [Object not bright.] ▶
否则
打印 [Bright object!] ▶
when eye#
The when eye block runs the attached stack of blocks when the selected Optical Sensor detects or loses an object.
当 [FrontEye v] [detects v] 一个对象 :: hat events
Parameters |
Description |
|---|---|
eye |
The Eye Sensor to use. |
state |
Which action to trigger the hat block:
|
Example
当 [FrontEye v] [loses v] 一个对象 :: hat events
[Find an object when it is lost.]
[右 v] 转
等到 <[FrontEye v] 靠近对象?>
驱动停止