Giroscopio#
Introducción#
El sensor giroscópico proporciona métodos para rastrear y cambiar la orientación del robot. Estos métodos permiten al cerebro rastrear su orientación y rumbo.
For the examples below, the configured Gyro Sensor will be named Gyro1
, and will be used in all subsequent examples throughout this API documentation when referring to Gyro class methods.
A continuación se muestra una lista de todos los métodos:
Acciones: calibrar y detectar cambios de orientación con el sensor giroscópico.
calibrate
– Calibrates the Gyro Sensor for stable heading tracking.changed
– Registers a function to call when the Gyro Sensor detects change.
Mutadores: modifican el rumbo y la rotación del sensor giroscópico.
setHeading
– Sets the Gyro Sensor’s heading to a specified value.setRotation
– Sets the Gyro Sensor’s rotation value.resetHeading
– Sets the heading of the Gyro Sensor to 0.resetRotation
– Sets the rotation of the Gyro Sensor to 0.
Getters: devuelve datos de orientación y movimiento con el sensor giroscópico.
heading
– Returns the current heading.rotation
– Returns the cumulative rotation.rat
– Returns the angular velocity around the x, y, or z axis.isCalibrating
– Returns whether or not the Gyro Sensor is calibrating.installed
– Returns whether or not a Gyro Sensor is connected to the Brain.
Constructores: inicializan manualmente el sensor giroscópico.
gyro
– Create a Gyro Sensor.
Comportamiento#
calibrate#
calibrate
calibrates the Gyro Sensor. Calibration should be used when the Gyro Sensor is not moving.
Usage:
Gyro1.calibrate(time, wait);
Parámetros |
Descripción |
---|---|
|
One of the valid calibration types:
|
|
Optional. Whether or not to wait before executing the next command:
|
// Example coming soon
changed#
changed
registers a callback function for when the Gyro Sensor’s heading changes.
Usage:
Gyro1.changed(callback);
Parámetros |
Descripción |
---|---|
|
Una función que se define previamente para ejecutarse cuando cambia el rumbo del sensor giroscópico. |
// Example coming soon
Mutadores#
setHeading#
setHeading
sets the heading of the Gyro Sensor to a specific value.
Usage:
Gyro1.setHeading(value, units);
Parámetros |
Descripción |
---|---|
|
El valor del encabezado a establecer. |
|
The unit that represents the new heading:
|
// Example coming soon
setRotation#
setRotation
sets the rotation of the Gyro Sensor to a specific value.
Usage:
Gyro1.setRotation(value, units);
Parámetros |
Descripción |
---|---|
|
El valor de rotación a establecer. |
|
The unit that represents the new rotation:
|
// Example coming soon
resetHeading#
resetHeading
resets the heading of the Gyro Sensor to 0.
Usage:
Gyro1.resetHeading();
Parámetros |
Descripción |
---|---|
Este método no tiene parámetros. |
// Example coming soon
resetRotation#
resetRotation
resets the rotation of the Gyro Sensor to 0.
Usage:
Gyro1.resetRotation();
Parámetros |
Descripción |
---|---|
Este método no tiene parámetros. |
// Example coming soon
Captadores#
heading#
heading
returns the current heading of the Gyro Sensor.
Usage:
Gyro1.heading(units)
Parámetros |
Descripción |
---|---|
|
Optional. The unit that represents the heading:
|
// Example coming soon
rotation#
rotation
returns the current rotation of the Gyro Sensor.
Usage:
Gyro1.rotation(units)
Parámetros |
Descripción |
---|---|
|
Optional. The unit that represents the rotation:
|
// Example coming soon
rate#
rate
returns the current rate of change of the Gyro Sensor’s rotation.
Usage:
Gyro1.rate(units)
Parámetros |
Descripción |
---|---|
|
Optional. The unit used to represent the gyro rate:
|
// Example coming soon
isCalibrating#
isCalibrating
returns a Boolean indicating if the Gyro Sensor is currently calibrating.
true
- The Gyro Sensor is calibrating.false
- The Gyro Sensor is not calibrating.
Usage:
Gyro1.isCalibrating()
Parámetros |
Descripción |
---|---|
Este método no tiene parámetros. |
// Example coming soon
installed#
installed
returns a Boolean indicating whether the Gyro Sensor is connected to the Brain.
true
- The Gyro Sensor is connected to the Brain.false
- The Gyro Sensor is not connected to the Brain.
Usage:
Gyro1.installed()
Parámetros |
Descripción |
---|---|
Este método no tiene parámetros. |
Constructores#
gyro#
gyro
creates an object of the gyro Class in the specified port.
Usage:
gyro Gyro1 = gyro(port);
Parámetro |
Descripción |
---|---|
|
Which Smart Port that the Gyro Sensor is connected to as |
// Example coming soon