Distance Sensor#

Introduction#

The V5 Distance Sensor measures the distance to an object, its approximate size, and its approach speed. It operates over a range of 20 mm to 2,000 mm.

Below 200 mm, accuracy is approximately ±15 mm, and above 200 mm, accuracy improves to about 5%.

The Distance Sensor uses a Class 1 laser, ensuring detection is always directed straight ahead and is classroom-safe.

The VEX V5 Distance Sensor.

Below is a list of available Distance Sensor measurements:

object distance#

The object distance block returns the distance from the sensor to the nearest object.

([Distance 1 v] 对象距离 [毫米 v])

Parameters

Description

device

Which Distance Sensor to use, configured in the Devices window.

units

The unit of measurement:

  • mm – millimeters, from 20 to 2000.
  • inches – 0.78 to 78.74

Example

Drive forward until an object is detected within 200 mm#
当开始
[Drive forward until the object is within 50 mm away.]
驱动 [向前 v]
等到 <([Distance 1 v] 对象距离 [毫米 v]) [math_less_than v] [50]>
驱动停止

object velocity#

The object velocity block returns the relative speed of an object traveling toward or away from the Distance Sensor in m/s (meters per second).

([Distance 1 v] 对象速度m/s)

Parameters

Description

device

Which Distance Sensor to use, configured in the Devices window.

object size is?#

The object size is? block returns whether the detected object is of a certain size. The size is determined by how much of the Distance Sensor’s view is taken up by the detected object.

  • True – The Distance Sensor is detecting an object of the specified size.

  • False – The Distance Sensor is not detecting an object of the specified size.

<[Distance 1 v] 对象尺寸 [小 v]?>

Parameters

Description

device

Which Distance Sensor to use, configured in the Devices window.

size

The size of the object to look for:

  • small
  • medium
  • large

Distance Sensor found object?#

The Distance Sensor found object? block returns whether the Distance Sensor is detecting an object.

  • True – The Distance Sensor is detecting an object.

  • False – The Distance Sensor is not detecting an object.

<[Distance 1 v] 发现对象?>

Parameters

Description

device

Which Distance Sensor to use, configured in the Devices window.

Example

Drive forward until an object is detected within 50 mm#
当开始
[Drive forward until the object is within 50 mm away.]
永久循环
驱动 [向前 v]
如果 <[Distance 1 v] 发现对象?> 那么
如果 <([Distance 1 v] 对象距离 [毫米 v]) [math_less_than v] [50]> 那么
驱动停止
退出循环