Sensor GPS#

Introducción#

El sensor V5 GPS (Game Positioning System™) proporciona un seguimiento preciso de la posición y la orientación de un robot en el campo VEX. Utiliza el código de campo GPS alrededor del perímetro del campo para calcular las coordenadas X e Y del robot y su rumbo en tiempo real.

El sensor GPS devuelve la posición del robot utilizando un punto de referencia calculado automáticamente a partir de los desplazamientos ingresados ​​al configurar el sensor GPS en la ventana Dispositivos.

Para obtener más información sobre el sensor GPS, lea Uso del sensor GPS con VEX V5 en la biblioteca VEX.

El punto de referencia actúa como la posición propia (0, 0) del sensor GPS, donde todas las coordenadas, rumbos y movimientos devueltos por los métodos GPS son relativos a este punto configurado.

El sensor GPS VEX V5.

This page uses gps_sensor as the example GPS Sensor name. Replace it with your own configured name as needed.

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

  • calibrate – Calibrates the GPS Sensor to set its heading as the current drivetrain heading.

  • set_origin – Sets the position of the reference point on the robot.

  • set_location – Sets both the reference point’s position and heading on the Field.

  • x_position – Returns the reference point’s x coordinate on the Field.

  • y_position – Returns the reference point’s y coordinate on the Field.

  • heading – Returns the reference point’s heading based on the Field orientation.

  • acceleration – Returns the robot’s acceleration on a selected axis.

  • gyro_rate – Returns the robot’s rotational speed on a selected axis.

  • orientation – Returns the robot’s roll, pitch, or yaw orientation in degrees.

  • quality – Returns the signal strength of the GPS Sensor.

  • changed – Registers a function to be called whenever the GPS Sensor detects a change in heading.

Constructor – Inicializa manualmente un sensor GPS.

  • Gps – Creates a GPS Sensor.

calibrar#

calibrate calibrates the reference point, setting its configured heading as the current drivetrain heading. During this time, the robot must remain completely still as movement during calibration will produce inaccurate results.

Usage:
gps_sensor.calibrate()

Parámetros

Descripción

Este método no tiene parámetros.

establecer_origen#

set_origin sets the position of the reference point on the robot manually. This can be done so to manually set a GPS Sensor’s location on a robot instead of doing so in the configuration settings.

Usage:
gps_sensor.set_origin(x, y, distance_units)

Parámetros

Descripción

incógnita

La coordenada x del punto de referencia en el robot.

y

La coordenada y del punto de referencia en el robot.

unidades_de_distancia

The unit of measurement for the x and y coordinates:

  • MM – millimeters
  • INCHES

# GPS Sensor is mounted 25mm forward
# from the reference point on a robot

gps.set_origin(0, 25, MM)

establecer_ubicación#

set_location sets the position and heading of the reference point on the Field manually. This can be done to help reduce inaccuracies if the GPS Sensor is too close to the Field’s walls on startup to get a sufficient amount of the GPS Field Code in its view.

Una vista de arriba hacia abajo del campo VEX V5 que muestra el sensor mirando el código de campo en los lados del campo.

Usage:
gps_sensor.set_location(x, y, distance_units, heading, heading_units)

Parámetros

Descripción

incógnita

La coordenada x del punto de referencia en el campo.

y

La coordenada y del punto de referencia en el campo.

unidades_de_distancia

The unit of measurement for the x and y coordinates:

  • MM – millimeters
  • INCHES

título

El rumbo hacia el que se orienta el punto de referencia en relación con el rumbo del campo absoluto, de 0 a 359,9 grados.

unidades de encabezado

The unit of measurement for the heading:

  • DEGREES

posición x#

x_position returns the reference point’s x coordinate on the Field.

Usage:
gps_sensor.x_position(units)

Parámetros

Descripción

unidad

The unit of measurement:

  • MM – millimeters
  • INCHES

posición y#

y_position returns the reference point’s y coordinate on the Field.

Usage:
gps_sensor.y_position(units)

Parámetros

Descripción

unidad

The unit of measurement:

  • MM – millimeters
  • INCHES

título#

heading returns the reference point’s heading based on the Field’s orientation from 0 to 359.9 degrees.

El rumbo corresponde al rumbo absoluto del campo, que abarca un rango de 0º a 359,9º en sentido horario. El 0º se encuentra en la posición de las 12 en punto.

Una vista de arriba hacia abajo del campo VEX V5 que muestra los grados alrededor del campo.

Usage:
gps_sensor.heading()

Parámetros

Descripción

Este método no tiene parámetros.

aceleración#

acceleration returns the robot’s acceleration on a specified axis from -4.0 to 4.0 Gs.

Usage:
gps_sensor.acceleration(axis)

Parámetros

Descripción

eje

Which axis to use:

  • AxisType.XAXIS
  • AxisType.YAXIS
  • AxisType.ZAXIS

tasa de giro#

gyro_rate returns the robot’s rotational speed on a selected axis.

Usage:
gps_sensor.gyro_rate(axis, units)

Parámetros

Descripción

eje

Which axis to use:

  • AxisType.XAXIS
  • AxisType.YAXIS
  • AxisType.ZAXIS

unidades

The unit of measurement:

  • VelocityUnits.DPS – degrees per second, from -1000 to 1000
  • VelocityUnits.RPM – revolutions per minute, from -167 to 167

orientación#

orientation returns the robot’s roll, pitch, or yaw orientation in degrees.

Usage:
gps_sensor.orientation(axis, units)

Parámetros

Descripción

eje

Which orientation to use:

  • OrientationType.ROLL
  • OrientationType.PITCH
  • OrientationType.YAW

unidades

The unit of measurement:

  • DEGREES

calidad#

quality returns the signal strength of the GPS Sensor as a percent.

Valores posibles

Descripción

100

Todos los datos de posición y rumbo informados por el sensor GPS son válidos.

~90

Los datos de posición ya no se calculan capturando información del código de campo GPS, sino a través de medios alternativos.

0 - 80

Solo los valores de rumbo del sensor GPS son válidos, pero a medida que pasa el tiempo en el que un sensor GPS no escanea lo suficiente del código de campo GPS para determinar con precisión la información de posición y rumbo, la calidad de la señal informada continuará cayendo hasta 0, donde todos los datos del sensor GPS quedan efectivamente congelados y ya no son válidos.

Usage:
gps_sensor.quality()

Parámetros

Descripción

Este método no tiene parámetros.

cambió#

changed registers a function to be called whenever the GPS Sensor detects a change in heading.

Usage:
gps_sensor.changed(callback, arg)

Parámetros

Descripción

callback

Una función previamente definida que se ejecuta cuando cambia el rumbo del sensor GPS.

arg

Opcional. Una tupla que contiene los argumentos que se pasan a la función de devolución de llamada. Consulte Uso de funciones con parámetros para obtener más información.

def my_function():
  brain.screen.print("GPS heading changed")

# Call my_function whenever gps_sensor's heading changes
gps_sensor.changed(my_function)

Constructor#

Constructors are used to manually create Gps objects, which are necessary for configuring a GPS Sensor outside of VEXcode.

Gps#

Gps creates a GPS Sensor.

Usage:
Gps(smartport)

Parámetro

Descripción

smartport

The Smart Port that the GPS Sensor is connected to, written as Ports.PORTx where x is the number of the port.

# Create a GPS Sensor in Port 10
gps_sensor = Gps(Ports.PORT10)