Class AnalogAccelerometer
java.lang.Object
org.wpilib.hardware.accelerometer.AnalogAccelerometer
- All Implemented Interfaces:
AutoCloseable, TelemetryLoggable
Handle operation of an analog accelerometer. The accelerometer reads acceleration directly
through the sensor. Many sensors have multiple axis and can be treated as multiple devices. Each
is calibrated by finding the center value over a period of time.
-
Constructor Summary
ConstructorsConstructorDescriptionAnalogAccelerometer(int channel) Create a new instance of an accelerometer.AnalogAccelerometer(AnalogInput channel) Create a new instance of Accelerometer from an existing AnalogChannel. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Delete the analog components used for the accelerometer.doubleReturn the acceleration in Gs.Gets the telemetry table type.voidlogTo(TelemetryTable table) Logs the object to aTelemetryTable.voidsetSensitivity(double sensitivity) Set the accelerometer sensitivity.voidsetZero(double zero) Set the voltage that corresponds to 0 G.
-
Constructor Details
-
AnalogAccelerometer
public AnalogAccelerometer(int channel) Create a new instance of an accelerometer.The constructor allocates desired analog channel.
- Parameters:
channel- The channel number for the analog input the accelerometer is connected to
-
AnalogAccelerometer
Create a new instance of Accelerometer from an existing AnalogChannel. Make a new instance of accelerometer given an AnalogChannel. This is particularly useful if the port is going to be read as an analog channel as well as through the Accelerometer class.- Parameters:
channel- The existing AnalogInput object for the analog input the accelerometer is connected to
-
-
Method Details
-
close
public void close()Delete the analog components used for the accelerometer.- Specified by:
closein interfaceAutoCloseable
-
getAcceleration
public double getAcceleration()Return the acceleration in Gs.The acceleration is returned units of Gs.
- Returns:
- The current acceleration of the sensor in Gs.
-
setSensitivity
public void setSensitivity(double sensitivity) Set the accelerometer sensitivity.This sets the sensitivity of the accelerometer used for calculating the acceleration. The sensitivity varies by accelerometer model.
- Parameters:
sensitivity- The sensitivity of accelerometer in Volts per G.
-
setZero
public void setZero(double zero) Set the voltage that corresponds to 0 G.The zero G voltage varies by accelerometer model.
- Parameters:
zero- The zero G voltage.
-
logTo
Description copied from interface:TelemetryLoggableLogs the object to aTelemetryTable.- Specified by:
logToin interfaceTelemetryLoggable- Parameters:
table- telemetry table
-
getTelemetryType
Description copied from interface:TelemetryLoggableGets the telemetry table type. Default is no specified table type (null). A mismatch in type during logging results in a reported warning, so this should always return the same value.- Specified by:
getTelemetryTypein interfaceTelemetryLoggable- Returns:
- Table type
-