WPILibC++ 2024.3.2
frc::AnalogAccelerometer Class Reference

Handle operation of an analog accelerometer. More...

#include <frc/AnalogAccelerometer.h>

Inheritance diagram for frc::AnalogAccelerometer:
wpi::Sendable wpi::SendableHelper< AnalogAccelerometer >

Public Member Functions

 AnalogAccelerometer (int channel)
 Create a new instance of an accelerometer. More...
 
 AnalogAccelerometer (AnalogInput *channel)
 Create a new instance of Accelerometer from an existing AnalogInput. More...
 
 AnalogAccelerometer (std::shared_ptr< AnalogInput > channel)
 Create a new instance of Accelerometer from an existing AnalogInput. More...
 
 ~AnalogAccelerometer () override=default
 
 AnalogAccelerometer (AnalogAccelerometer &&)=default
 
AnalogAccelerometeroperator= (AnalogAccelerometer &&)=default
 
double GetAcceleration () const
 Return the acceleration in Gs. More...
 
void SetSensitivity (double sensitivity)
 Set the accelerometer sensitivity. More...
 
void SetZero (double zero)
 Set the voltage that corresponds to 0 G. More...
 
void InitSendable (wpi::SendableBuilder &builder) override
 Initializes this Sendable object. More...
 
- Public Member Functions inherited from wpi::Sendable
virtual ~Sendable ()=default
 
virtual void InitSendable (SendableBuilder &builder)=0
 Initializes this Sendable object. More...
 
- Public Member Functions inherited from wpi::SendableHelper< AnalogAccelerometer >
 SendableHelper (const SendableHelper &rhs)=default
 
 SendableHelper (SendableHelper &&rhs)
 
SendableHelperoperator= (const SendableHelper &rhs)=default
 
SendableHelperoperator= (SendableHelper &&rhs)
 

Additional Inherited Members

- Protected Member Functions inherited from wpi::SendableHelper< AnalogAccelerometer >
 SendableHelper ()=default
 
 ~SendableHelper ()
 

Detailed Description

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 & Destructor Documentation

◆ AnalogAccelerometer() [1/4]

frc::AnalogAccelerometer::AnalogAccelerometer ( int  channel)
explicit

Create a new instance of an accelerometer.

The constructor allocates desired analog input.

Parameters
channelThe channel number for the analog input the accelerometer is connected to

◆ AnalogAccelerometer() [2/4]

frc::AnalogAccelerometer::AnalogAccelerometer ( AnalogInput channel)
explicit

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
channelThe existing AnalogInput object for the analog input the accelerometer is connected to

◆ AnalogAccelerometer() [3/4]

frc::AnalogAccelerometer::AnalogAccelerometer ( std::shared_ptr< AnalogInput channel)
explicit

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
channelThe existing AnalogInput object for the analog input the accelerometer is connected to

◆ ~AnalogAccelerometer()

frc::AnalogAccelerometer::~AnalogAccelerometer ( )
overridedefault

◆ AnalogAccelerometer() [4/4]

frc::AnalogAccelerometer::AnalogAccelerometer ( AnalogAccelerometer &&  )
default

Member Function Documentation

◆ GetAcceleration()

double frc::AnalogAccelerometer::GetAcceleration ( ) const

Return the acceleration in Gs.

The acceleration is returned units of Gs.

Returns
The current acceleration of the sensor in Gs.

◆ InitSendable()

void frc::AnalogAccelerometer::InitSendable ( wpi::SendableBuilder builder)
overridevirtual

Initializes this Sendable object.

Parameters
buildersendable builder

Implements wpi::Sendable.

◆ operator=()

AnalogAccelerometer & frc::AnalogAccelerometer::operator= ( AnalogAccelerometer &&  )
default

◆ SetSensitivity()

void frc::AnalogAccelerometer::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. There are constants defined for various models.

Parameters
sensitivityThe sensitivity of accelerometer in Volts per G.

◆ SetZero()

void frc::AnalogAccelerometer::SetZero ( double  zero)

Set the voltage that corresponds to 0 G.

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

Parameters
zeroThe zero G voltage.

The documentation for this class was generated from the following file: