Distance#
Introduction#
The Distance Sensor can detect whether an object is in front of the sensor and report how far away that object is.
Below is a list of available blocks:
Distance found an object — Reports whether the Distance Sensor currently detects an object.
object distance — Reports the distance between the Distance Sensor and the nearest detected object.
Distance found an object#
The Distance found an object Boolean block reports whether the Distance Sensor currently detects an object within 2000mm.
True — The Distance Sensor detects an object.
False — The Distance Sensor does not detect an object.
<[FrontDistance v] found an object?>
Parameters |
Description |
|---|---|
distance sensor |
The Distance Sensor to use. Choose from the Distance Sensors available for the VR Robot. |
Example
when started :: hat events
[Spin until the Distance Sensor detects an object.]
turn [right v]
wait until <[FrontDistance v] found an object?>
stop driving
object distance#
The object distance reporter block reports the distance between the Distance Sensor and the nearest detected object.
([FrontDistance v] distance in [mm v])
Parameters |
Description |
|---|---|
distance sensor |
The Distance Sensor to use. Choose from the Distance Sensors available for the VR Robot. |
unit |
The distance unit: mm or inches. |
Example
when started :: hat events
[Print the distance only after the Distance Sensor detects an object.]
turn [right v]
wait until <[FrontDistance v] found an object?>
stop driving
print ([FrontDistance v] distance in [mm v]) ▶