Acelerómetro#
Introducción#
The accelerometer class measures the acceleration of the robot along one or more axes. The sensor outputs an analog voltage that changes based on acceleration in G-forces (G).
Un puente en el acelerómetro determina su rango de sensibilidad:
2G - Mide la aceleración de -2G a +2G.
6G - Mide la aceleración de -6G a +6G.

Constructor de clases#
accelerometer(
triport::port &port,
bool bHighSensitivity = false);
Instructor de clase#
Destroys the accelerometer object and releases associated resources.
virtual ~accelerometer();
Parámetros#
Parámetro |
Tipo |
Descripción |
|---|---|---|
|
|
The 3-Wire Port the Accelerometer is connected to, written as |
|
|
Optional. Whether to enable high sensitivity mode on the Accelerometer:
|
Ejemplos#
// Create a 6G accelerometer instance in Port A
accelerometer Accel6GA = accelerometer(Brain.ThreeWirePort.A);
// Create a 2G accelerometer instance in Port A
accelerometer Accel2GA = accelerometer(Brain.ThreeWirePort.A, true);
Funciones de los miembros#
The accelerometer class includes the following member functions:
acceleration— Returns the acceleration measured by the Accelerometer in Gs.
Before calling any accelerometer member functions, an accelerometer instance must be created, as shown below:
/* This constructor is required when using VS Code.
Accelerometer configuration is generated automatically
in VEXcode using the Device Menu. Replace the values
as needed. */
// Create a 2G accelerometer instance in Port A
accelerometer Accel2GA = accelerometer(Brain.ThreeWirePort.A, true);
acceleration#
Devuelve la aceleración medida en Gs.
Available Functionsdouble acceleration();
Esta función no acepta ningún parámetro.
Return ValuesReturns a double representing the acceleration measured in Gs.
// Drive the robot forward.
Drivetrain.drive(forward);
// Get the acceleration measured by the Accelerometer.
double accelerationValue = Accel2GA.acceleration();