距离传感器#

介绍#

The Distance Sensor can detect whether an object is in front of the sensor and return how far away that object is. It can also report the detected object’s relative velocity and estimate whether the object is small, medium, or large.

The Distance Sensor operates over a range of 20 mm to 2000 mm.

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

The Distance Sensor uses a Class 1 laser. Detection is directed straight ahead and is classroom-safe.

The Distance Sensor.

以下是可用模块列表:

  • object distance — Reports the distance between the Distance Sensor and the nearest detected object.

  • object velocity — Reports how quickly the detected object is moving toward or away from the Distance Sensor.

  • object size is — Reports whether the detected object matches the selected size.

  • Distance found an object — Reports whether the Distance Sensor currently detects an object.

物距#

The object distance reporter block reports the distance between the Distance Sensor and the nearest detected object.

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

参数

描述

设备

The Distance Sensor to use. Choose from the Distance Sensors configured in the Devices window.

单位

The distance unit: mm (20 mm to 2000 mm) or inches (0.78 inches to 78.74 inches).

例子

向前行驶,直到在 200 毫米范围内检测到物体为止#
当开始
[Drive forward until the object is within 50 mm away.]
驱动 [向前 v]
等到 <([Distance 1 v] 对象距离 [毫米 v]) [math_less_than v] [50]>
驱动停止

物体速度#

The object velocity reporter block reports the relative velocity of the detected object as a decimal number in m/s (meters per second).

Velocity shows how quickly the object is moving toward or away from the Distance Sensor. A value near 0 means the object is not moving much relative to the sensor.

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

参数

描述

设备

The Distance Sensor to use. Choose from the Distance Sensors configured in the Devices window.

object size is#

The object size is Boolean block reports whether the object detected by the Distance Sensor matches the selected size.

The Distance Sensor estimates object size based on how much of the sensor’s view is taken up by the detected object.

  • True — The Distance Sensor detects an object of the selected size.

  • False — The Distance Sensor does not detect an object of the selected size.

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

参数

描述

设备

The Distance Sensor to use. Choose from the Distance Sensors configured in the Devices window.

尺寸

The object size to check for:

  • small
  • medium
  • large

Distance found an object#

The Distance found an object Boolean block reports whether the Distance Sensor currently detects an object.

  • True — The Distance Sensor detects an object.

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

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

参数

描述

设备

The Distance Sensor to use. Choose from the Distance Sensors configured in the Devices window.

例子

向前行驶,直到在 50 毫米范围内检测到物体为止#
当开始
[Drive forward until the object is within 50 mm away.]
永久循环
驱动 [向前 v]
如果 <[Distance 1 v] 发现对象?> 那么
如果 <([Distance 1 v] 对象距离 [毫米 v]) [math_less_than v] [50]> 那么
驱动停止
退出循环