AnalogAccelerometer

class wpilib.AnalogAccelerometer(*args, **kwargs)

Bases: Sendable

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.

Overloaded function.

  1. __init__(self: wpilib._wpilib.AnalogAccelerometer, channel: int) -> None

Create a new instance of an accelerometer.

The constructor allocates desired analog input.

Parameters:

channel – The channel number for the analog input the accelerometer is connected to

  1. __init__(self: wpilib._wpilib.AnalogAccelerometer, channel: wpilib._wpilib.AnalogInput) -> None

Create a new instance of Accelerometer from an existing AnalogInput.

Make a new instance of accelerometer given an AnalogInput. 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

getAcceleration() float

Return the acceleration in Gs.

The acceleration is returned units of Gs.

Returns:

The current acceleration of the sensor in Gs.

initSendable(builder: wpiutil._wpiutil.SendableBuilder) None
setSensitivity(sensitivity: float) None

Set the accelerometer sensitivity.

This sets the sensitivity of the accelerometer used for calculating the acceleration. The sensitivity varies by accelerometer model. There are constants defined for various models.

Parameters:

sensitivity – The sensitivity of accelerometer in Volts per G.

setZero(zero: float) None

Set the voltage that corresponds to 0 G.

The zero G voltage varies by accelerometer model. There are constants defined for various models.

Parameters:

zero – The zero G voltage.