:linenothreshold: 5

Range#

Introduction#

The VEX AIR Drone features 2 Range Sensors, one on the front of the drone, and one on the bottom. These sensors allow the drone to detect the distance between it and the nearest object.

Below is a list of all available methods:

Getters

  • get_distance – Returns the distance from a Range Sensor.

Getters#

get_distance#

get_distance returns the distance between a Range Sensor and the nearest object.

Usage:

drone.range.get_distance(range, units)

Parameters

Description

range

The Range Sensor to use:

  • FORWARD_RANGE – The distance from the front of the drone.
  • DOWNWARD_RANGE – The distance from the bottom of the drone.

units

Optional. The unit that represents the distance:

  • DistanceUnits.CM – Centimeters
  • MM (default) – Millimeters
  • INCHES
# Fly forward until close to an object
drone.take_off(500)
drone.move_at(0, 50)
while not drone.range.get_distance(FORWARD_RANGE, MM) < 75:
    wait(0.1, SECONDS)
drone.land()