거리#

소개#

거리 센서는 센서 앞에 물체가 있는지 여부를 감지하고 그 물체와의 거리를 측정할 수 있습니다.

아래는 사용 가능한 모든 방법의 목록입니다.

게터 — 객체가 감지되었는지 여부와 객체와의 거리를 반환합니다.

  • found_object — 거리 센서가 현재 객체를 감지하는지 여부를 반환합니다.

  • get_distance — 거리 센서와 가장 가까운 감지된 객체 사이의 거리를 반환합니다.

게터스#

found_object#

found_object 은 거리 센서가 현재 물체를 감지했는지 여부를 반환합니다.

  • True — 거리 센서가 물체를 감지했습니다.

  • False — 거리 센서가 물체를 감지하지 못했습니다.

Usage:
distance.found_object()

매개변수

설명

이 메서드에는 매개변수가 없습니다.

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 get_distance 거리 센서와 가장 가까운 감지된 객체 사이의 거리를 반환합니다.

Usage:
distance.get_distance(units)

매개변수

설명

units

거리 단위: MM 또는 INCHES.

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)