眼睛#

介绍#

The VEX GO Eye Sensor can detect objects and colors. It can also report how much light reflects back to the sensor and the hue value of the detected color.

The Eye Sensor has a light that can be turned on or off to help it see objects and colors more clearly. The Eye Sensor can also use a near or far range to detect objects at different distances.

The Eye Sensor can be placed in different positions depending on the build. For example, the Code Base 2.0 - Eye Forward build has the Eye Sensor facing forward. The Code Base 2.0 - Eye Down build, Code Base 2.0 ‑ Eye + Electromagnet, and Super Code Base 2.0 has the Eye Sensor facing down.

Below is a list of all available blocks:

设置眼神光#

The set eye light stack block turns the Eye Sensor’s light on or off. The light can help the Eye Sensor detect objects and colors more clearly.

设定辨色仪灯 [on v]

参数

描述

状态

The state of the Eye Sensor’s light: on or off.

例子

当开始 :: hat events
[Build Used: Code Base 2.0 - Eye Forward]
[Turn the light on and off.]
永久循环
设定辨色仪灯 [on v]
等待 [2] 秒
设定辨色仪灯 [灭 v]
等待 [2] 秒

设置眼睛范围#

The set eye range stack block sets how far an object can be from the Eye Sensor before it can be detected.

Every project begins with the Eye Sensor set to far range by default.

设置辨色仪的视距为 [near v]

参数

描述

范围

The Eye Sensor’s object detection range. near detects objects up to 18 millimeters away, while far detects objects up to 40 millimeters away.

例子

当开始 :: hat events
[Build Used: Code Base 2.0 - Eye Forward]
[Drive to an object with different ranges.]
设置辨色仪的视距为 [far v]
驱动 [向前 v]
等到 <辨色仪发现一个对象?>
驱动 [反 v] [100] [毫米 v] ▶
等待 [1] 秒
[Closer detection range.]
设置辨色仪的视距为 [near v]
驱动 [向前 v]
等到 <辨色仪发现一个对象?>
驱动停止

设置眼部照明功率#

The set eye light power stack block sets how bright the Eye Sensor’s light is. The light can help the Eye Sensor detect objects and colors more clearly.

A higher percentage makes the light brighter. A lower percentage makes the light dimmer.

If the Eye Sensor’s light is off, setting the light power above 0% will turn the light on.

If the Eye Sensor’s light is on, setting the light power at 0% will turn the light off.

设定辨色仪灯功率为 [50]%

参数

描述

亮度

The brightness to set the Eye Sensor’s light to, from 0% to 100%. Use whole numbers.

例子

当开始 :: hat events
[Build Used: Code Base 2.0 - Eye Forward]
[Turn on the light at different brightnesses.]
设定辨色仪灯功率为 [25]%
等待 [2] 秒
设定辨色仪灯功率为 [50]%
等待 [2] 秒
设定辨色仪灯功率为 [100]%

eye found an object#

The eye found an object Boolean block reports whether or not the Eye Sensor detects an object within range.

  • True — The Eye Sensor detects an object.

  • False — The Eye Sensor does not detect an object.

The detection range can be changed using the set eye range block.

<辨色仪发现一个对象?>

参数

描述

该块没有参数。

例子

当开始 :: hat events
[Build Used: Code Base 2.0 - Eye Forward]
[Drive forward until an object is detected.]
驱动 [向前 v]
等到 <辨色仪发现一个对象?>
驱动停止

eye detects color#

The eye detects color Boolean block reports whether the Eye Sensor detects a specific color, based on the detected hue value.

  • True — The Eye Sensor detects the selected color.

  • False — The Eye Sensor does not detect the selected color.

The Eye Sensor works best when the object is close enough to detect and the lighting is clear.

To check the exact hue value detected by the Eye Sensor, use the eye hue reporter block.

<辨色仪测得 [红色 v]?>

参数

描述

颜色

The color for the Eye Sensor to detect:

  • red – Hue value between 340° and 20°.
  • green – Hue value between 75° and 154°.
  • blue – Hue value between 160° and 254°.
  • none – None of the available colors are detected.

例子

当开始 :: hat events
[Build Used: Super Code Base 2.0]
[Drive forward until a Green Disk is detected.]
驱动 [向前 v]
等待 [0.2] 秒
等到 <辨色仪测得 [绿色 v]?>
驱动停止

眼睛亮度#

The eye brightness reporter block reports how much light is reflected back to the Eye Sensor, as a percentage from 0% to 100%.

A higher percentage means more light is reflected back to the Eye Sensor. A lower percentage means less light is reflected back.

(辨色仪亮度百分比)

参数

描述

该块没有参数。

例子

当开始 :: hat events
[Build Used: Super Code Base 2.0]
[Monitor the brightness until a Red Disk is detected.]
驱动 [向前 v]
重复直到 <辨色仪测得 [红色 v]?>
清除所有行
打印 (辨色仪亮度百分比) ▶
等待 [0.1] 秒
结束
驱动停止

眼睛色调#

The eye hue reporter block reports the hue detected by the Eye Sensor as a number from 0 to 359 degrees.

Hue is a way to describe color using numbers around a color wheel.

一个圆形色轮,显示完整的色调光谱,边缘标有度数,从顶部的 0° 到 360°,以 30° 为增量递增。

(辨色仪色度值)

参数

描述

该块没有参数。

例子

当开始 :: hat events
[Build Used: Code Base 2.0 - Eye Forward]
[Display the hue of a pink GO piece.]
永久循环
清除所有行
如果 <[10] [math_less_than v] (辨色仪色度值) [math_less_than v] [40]> 那么
打印 [Pink!] ▶
否则
打印 [Not pink.] ▶