Distancia#
Introducción#
El sensor de distancia permite al robot detectar la presencia de un objeto y medir su distancia.
A continuación se muestra una lista de todos los métodos disponibles:
Getters – Devuelven si se detectan objetos y sus distancias.
found_object– Return a Boolean indicating if an object is detected.get_distance– Return the distance of the closest object to the Distance Sensor.
Captadores#
found_object#
found_object returns a Boolean indicating whether or not an object is detected by the Distance Sensor.
True– An object is detected.False– An object is not detected.
Usage:
distance.found_object()
Parámetros |
Descripción |
|---|---|
Este método no tiene parámetros. |
def main():
# Stop turning when an object is detected
drivetrain.turn(RIGHT)
while True:
wait(5, MSEC)
if front_distance.found_object():
drivetrain.stop()
# VR threads — Do not delete
vr_thread(main)
get_distance#
get_distance returns the distance of the object closest to the Distance Sensor.
Usage:
distance.get_distance(units)
Parámetros |
Descripción |
|---|---|
|
The unit that represents the distance:
|
def main():
# Drive forward until an object is 200 mm away
while front_distance.get_distance(MM) > 200:
wait(5, MSEC)
drivetrain.drive(FORWARD)
drivetrain.stop()
# VR threads — Do not delete
vr_thread(main)