Inercial#

Introducción#

El cerebro VEX IQ (2.ª generación) incluye un giroscopio de 3 ejes integrado para medir el movimiento de rotación y un acelerómetro de 3 ejes para detectar cambios de movimiento. Estos sensores permiten al robot rastrear su orientación, rumbo y aceleración.

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

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

Orientación: mide el movimiento de rotación del sensor inercial.

  • encabezado – Devuelve el encabezado actual.

  • rotación – Devuelve la rotación acumulada.

  • setHeading – Establece el rumbo del sensor inercial en un valor específico.

  • setRotation – Establece el valor de rotación del sensor inercial.

  • calibrar – Calibra el sensor inercial para un seguimiento de rumbo estable.

  • isCalibrating – Devuelve si el sensor inercial está calibrando o no.

  • resetHeading – Establece el rumbo del sensor inercial en 0.

  • resetRotation – Establece la rotación del sensor inercial en 0.

Movimiento – Detecta cambios en el movimiento.

  • aceleración – Devuelve la aceleración lineal a lo largo del eje x, y o z.

  • gyroRate – Devuelve la velocidad angular alrededor del eje x, y o z.

  • orientación – Devuelve el balanceo, cabeceo o guiñada en función de la inclinación y la rotación.

  • cambiado – Registra una función para llamar cuando el sensor inercial detecta un cambio.

Constructores: inicializan y configuran manualmente un sensor inercial.

Orientación#

heading#

heading returns the current heading of the Inertial Sensor.

Usage:
BrainInertial.heading(units)

Parámetros

Descripción

units

Optional. The units that represent the heading:

  • degrees (default)
  • turns
// Example coming soon

rotation#

rotation returns the current rotation of the Inertial Sensor.

Usage:
BrainInertial.rotation(units)

Parámetros

Descripción

units

Optional. The units that represent the rotation:

  • degrees (default)
  • turns
// Example coming soon

setHeading#

setHeading sets the heading of the Inertial Sensor to a specific value.

Usage:
BrainInertial.setHeading(value, units);

Parámetros

Descripción

value

El valor del encabezado a establecer.

units

The unit that represents the new heading:

  • degrees
  • turns
// Example coming soon

setRotation#

setRotation sets the rotation of the Inertial Sensor to a specific value.

Usage:
BrainInertial.setRotation(value, units);

Parámetros

Descripción

value

El valor de rotación a establecer.

units

The unit that represents the new rotation:

  • degrees
  • turns
// Example coming soon

calibrate#

calibrate calibrates the Inertial Sensor. All subsequent lines will wait for the calibration to complete before executing. Calibration is an internal procedure that measures and compensates for sensor noise and drift over a specified period. During this time, the Brain must remain completely still (i.e., on a stable surface without any external movement). Movement during calibration will produce inaccurate results.

../../_images/IQ_right_orientation.png../../_images/IQ_left_orientation.png../../_images/IQ_top_orientation.png

Los cerebros VEX intentan calibrarse automáticamente al inicio de cada proyecto. Sin embargo, si el robot se transporta o se mueve durante el inicio del proyecto, el sensor podría no calibrarse correctamente o generar una calibración incorrecta.

Usage:
BrainInertial.calibrate();

Parámetro

Descripción

Este método no tiene parámetros.

// Example coming soon

isCalibrating#

isCalibrating checks if the Inertial Sensor is currently calibrating.

  • 1 - The Inertial Sensor is calibrating.

  • 0 - The Inertial Sensor is not calibrating.

Usage:
isCalibrating()

Parámetro

Descripción

Este método no tiene parámetros.

// Example coming soon

resetHeading#

resetHeading resets the heading of the Inertial Sensor to 0.

Usage:
BrainInertial.resetHeading();

Parámetros

Descripción

Este método no tiene parámetros.

// Example coming soon

resetRotation#

resetRotation resets the rotation of the Inertial Sensor to 0.

Usage:
BrainInertial.resetRotation();

Parámetros

Descripción

Este método no tiene parámetros.

// Example coming soon

Movimiento#

acceleration#

acceleration returns the acceleration of the Inertial Sensor in terms of G (gravity).

Usage:
BrainInertial.acceleration(axis);

Parámetros

Descripción

axis

The axis to return the acceleration from:

  • xaxis
  • yaxis
  • zaxis
// Example coming soon

gyroRate#

gyroRate returns the gyro rate for one axis of the Inertial Sensor.

Usage:
BrainInertial.gyroRate(axis, units);

Parámetros

Descripción

axis

The axis to return the gyro rate from:

  • xaxis
  • yaxis
  • zaxis

units

The unit used to represent the gyro rate:

  • dps – degrees per second
  • rpm – rotations per minute
  • velocityUnits::pct – percent
// Example coming soon

orientation#

orientation returns the orientation for one axis of the Inertial Sensor.

Usage:
BrainInertial.orientation(type, units);

Parámetros

Descripción

type

The axis to return the orientation from:

  • pitch
  • roll
  • yaw

units

The unit used to represent the orientation:

  • degrees
  • turns
// Example coming soon

changed#

changed registers a callback function for when the Inertial Sensor’s heading changes.

Usage:
BrainInertial.changed(callback);

Parámetros

Descripción

callback

La función de devolución de llamada que se llamará cuando cambie el rumbo del sensor inercial.

// Example coming soon

Constructores#

inertial#

inertial creates an Inertial Sensor.

Usage:
inertial BrainInertial = inertial();

Parámetro

Descripción

Este método no tiene parámetros.

// Example coming soon