WPILibC++ 2024.3.2
frc::AnalogPotentiometer Class Reference

Class for reading analog potentiometers. More...

#include <frc/AnalogPotentiometer.h>

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

Public Member Functions

 AnalogPotentiometer (int channel, double fullRange=1.0, double offset=0.0)
 Construct an Analog Potentiometer object from a channel number. More...
 
 AnalogPotentiometer (AnalogInput *input, double fullRange=1.0, double offset=0.0)
 Construct an Analog Potentiometer object from an existing Analog Input pointer. More...
 
 AnalogPotentiometer (std::shared_ptr< AnalogInput > input, double fullRange=1.0, double offset=0.0)
 Construct an Analog Potentiometer object from an existing Analog Input pointer. More...
 
 ~AnalogPotentiometer () override=default
 
 AnalogPotentiometer (AnalogPotentiometer &&)=default
 
AnalogPotentiometeroperator= (AnalogPotentiometer &&)=default
 
double Get () const
 Get the current reading of the potentiometer. 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< AnalogPotentiometer >
 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< AnalogPotentiometer >
 SendableHelper ()=default
 
 ~SendableHelper ()
 

Detailed Description

Class for reading analog potentiometers.

Analog potentiometers read in an analog voltage that corresponds to a position. The position is in whichever units you choose, by way of the scaling and offset constants passed to the constructor.

Constructor & Destructor Documentation

◆ AnalogPotentiometer() [1/4]

frc::AnalogPotentiometer::AnalogPotentiometer ( int  channel,
double  fullRange = 1.0,
double  offset = 0.0 
)
explicit

Construct an Analog Potentiometer object from a channel number.

Use the fullRange and offset values so that the output produces meaningful values. I.E: you have a 270 degree potentiometer and you want the output to be degrees with the halfway point as 0 degrees. The fullRange value is 270.0 degrees and the offset is -135.0 since the halfway point after scaling is 135 degrees.

This will calculate the result from the fullRange times the fraction of the supply voltage, plus the offset.

Parameters
channelThe Analog Input channel number on the roboRIO the potentiometer is plugged into. 0-3 are on-board and 4-7 are on the MXP port.
fullRangeThe value (in desired units) representing the full 0-5V range of the input.
offsetThe value (in desired units) representing the angular output at 0V.

◆ AnalogPotentiometer() [2/4]

frc::AnalogPotentiometer::AnalogPotentiometer ( AnalogInput input,
double  fullRange = 1.0,
double  offset = 0.0 
)
explicit

Construct an Analog Potentiometer object from an existing Analog Input pointer.

Use the fullRange and offset values so that the output produces meaningful values. I.E: you have a 270 degree potentiometer and you want the output to be degrees with the halfway point as 0 degrees. The fullRange value is 270.0 degrees and the offset is -135.0 since the halfway point after scaling is 135 degrees.

This will calculate the result from the fullRange times the fraction of the supply voltage, plus the offset.

Parameters
inputThe existing Analog Input pointer
fullRangeThe value (in desired units) representing the full 0-5V range of the input.
offsetThe value (in desired units) representing the angular output at 0V.

◆ AnalogPotentiometer() [3/4]

frc::AnalogPotentiometer::AnalogPotentiometer ( std::shared_ptr< AnalogInput input,
double  fullRange = 1.0,
double  offset = 0.0 
)
explicit

Construct an Analog Potentiometer object from an existing Analog Input pointer.

Use the fullRange and offset values so that the output produces meaningful values. I.E: you have a 270 degree potentiometer and you want the output to be degrees with the halfway point as 0 degrees. The fullRange value is 270.0 degrees and the offset is -135.0 since the halfway point after scaling is 135 degrees.

This will calculate the result from the fullRange times the fraction of the supply voltage, plus the offset.

Parameters
inputThe existing Analog Input pointer
fullRangeThe value (in desired units) representing the full 0-5V range of the input.
offsetThe value (in desired units) representing the angular output at 0V.

◆ ~AnalogPotentiometer()

frc::AnalogPotentiometer::~AnalogPotentiometer ( )
overridedefault

◆ AnalogPotentiometer() [4/4]

frc::AnalogPotentiometer::AnalogPotentiometer ( AnalogPotentiometer &&  )
default

Member Function Documentation

◆ Get()

double frc::AnalogPotentiometer::Get ( ) const

Get the current reading of the potentiometer.

Returns
The current position of the potentiometer (in the units used for fullRange and offset).

◆ InitSendable()

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

Initializes this Sendable object.

Parameters
buildersendable builder

Implements wpi::Sendable.

◆ operator=()

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

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