Distancia#

Introducción#

El sensor de distancia VEX IQ (2.ª generación) ofrece métodos para interactuar con los sensores VEX IQ (2.ª generación). Estos incluyen el seguimiento de distancias y velocidades.

For the examples below, the configured Distance Sensors will be named Distance1, and will be used in all subsequent examples throughout this API documentation when referring to distance class methods.

A continuación se muestra una lista de todos los métodos disponibles:

Obtenedores: devuelven datos del objeto del sensor de distancia.

  • foundObject – (1st Gen) Returns whether an object is within range.

  • distance – (1st Gen) Returns the distance to the nearest object.

  • objectDistance – (2nd Gen) Returns the distance to the nearest object.

  • objectVelocity – (2nd Gen) Returns the speed of a detected object.

  • objectSize – (2nd Gen) Returns the estimated size of the detected object (small, medium, large).

  • isObjectDetected – (2nd Gen) Returns whether an object is within range (approx. 406 mm or 16 inches).

  • installed – Returns whether the Distance Sensor is connected to the Brain.

Constructores – Inicializan manualmente los sensores de distancia.

  • sonar – Create a (1st Gen) Distance Sensor.

  • distance – Create a (2nd Gen) Distance Sensor.

Captadores#

foundObject#

foundObject returns a Boolean indicating whether or not the Distance Sensor detects an object.

  • 1 – The Distance Sensor detects an object.

  • 0 – The Distance Sensor does not detect an object.

Nota: Este es un método de sensor de distancia (1.ª generación).

Usage:
Distance1.foundObject()

Parámetros

Descripción

Este método no tiene parámetros.

// Example coming soon

distance#

distance returns the current distance from the Distance Sensor and a detected object as a double.

Nota: Este es un método de sensor de distancia (1.ª generación).

Usage:
Distance1.distance(units)

Parámetros

Descripción

units

The unit that represents the distance:

  • mm – millimeters
  • inches
  • distanceUnits::cm – centimeters
// Example coming soon

objectDistance#

objectDistance returns the distance between the Distance Sensor and the nearest object as a double.

Nota: Este es un método de sensor de distancia (2.ª generación).

Usage:
Distance1.objectDistance(units)

Parámetros

Descripción

units

The unit that represents the distance:

  • mm – millimeters
  • inches
  • distanceUnits::cm – centimeters
// Example coming soon

objectVelocity#

objectVelocity returns the velocity of a detected object measured in meters per second as a double. A positive value indicates the object is moving toward the Distance Sensor, while a negative value indicates it is moving away.

Nota: Este es un método de sensor de distancia (2.ª generación).

Usage:
Distance1.objectVelocity()

Parámetros

Descripción

Este método no tiene parámetros.

// Example coming soon

objectSize#

objectSize returns an enumerated value (enum) representing the estimated size of the detected object based on how much of the Distance Sensor (2nd gen)’s field of view it occupies:

Cuando se imprime directamente, muestra el valor numérico asociado a ese tamaño:

Tamaño

Valor numérico

none

0

small

1

medium

2

large

3

Nota: Este es un método de sensor de distancia (2.ª generación).

Usage:
Distance1.objectSize()

Parámetros

Descripción

Este método no tiene parámetros.

// Example coming soon

isObjectDetected#

isObjectDetected returns a Boolean indicating whether the Distance Sensor detects an object.

  • 1 – The Distance Sensor detects an object.

  • 0 – The Distance Sensor does not detect an object.

Nota: Este es un método de sensor de distancia (2.ª generación).

Usage:
Distance1.isObjectDetected()

Parámetros

Descripción

Este método no tiene parámetros.

// Example coming soon

installed#

installed returns if the Distance Sensor is connected.

  • 1 – The Distance Sensor is connected to the Brain.

  • 0 – The Distance Sensor is not connected to the Brain.

Usage:
Distance1.installed()

Parámetros

Descripción

Este método no tiene parámetros.

// Example coming soon

Constructores#

sonar#

sonar creates an object of the sonar Class in the specified port.

Usage:
sonar Distance1 = sonar(port);

Parámetro

Descripción

port

Which Smart Port that the Distance Sensor (1st Gen) is connected to as PORT followed by the port number, ranging from 1 to 12.

// Example coming soon

distance#

distance creates an object of the distance Class in the specified port.

Usage:
distance Distance1 = distance(port);

Parámetro

Descripción

port

Which Smart Port that the Distance Sensor is connected to as PORT followed by the port number, ranging from 1 to 12.

// Example coming soon