WPILibC++ 2025.2.1
Loading...
Searching...
No Matches
frc::AnalogEncoder Class Reference

Class for supporting continuous analog encoders, such as the US Digital MA3. More...

#include <frc/AnalogEncoder.h>

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

Public Member Functions

 AnalogEncoder (int channel)
 Construct a new AnalogEncoder attached to a specific AnalogIn channel.
 
 AnalogEncoder (AnalogInput &analogInput)
 Construct a new AnalogEncoder attached to a specific AnalogInput.
 
 AnalogEncoder (AnalogInput *analogInput)
 Construct a new AnalogEncoder attached to a specific AnalogInput.
 
 AnalogEncoder (std::shared_ptr< AnalogInput > analogInput)
 Construct a new AnalogEncoder attached to a specific AnalogInput.
 
 AnalogEncoder (int channel, double fullRange, double expectedZero)
 Construct a new AnalogEncoder attached to a specific AnalogIn channel.
 
 AnalogEncoder (AnalogInput &analogInput, double fullRange, double expectedZero)
 Construct a new AnalogEncoder attached to a specific AnalogInput.
 
 AnalogEncoder (AnalogInput *analogInput, double fullRange, double expectedZero)
 Construct a new AnalogEncoder attached to a specific AnalogInput.
 
 AnalogEncoder (std::shared_ptr< AnalogInput > analogInput, double fullRange, double expectedZero)
 Construct a new AnalogEncoder attached to a specific AnalogInput.
 
 ~AnalogEncoder () override
 
 AnalogEncoder (AnalogEncoder &&)=default
 
AnalogEncoderoperator= (AnalogEncoder &&)=default
 
double Get () const
 Get the encoder value.
 
void SetVoltagePercentageRange (double min, double max)
 Set the encoder voltage percentage range.
 
void SetInverted (bool inverted)
 Set if this encoder is inverted.
 
int GetChannel () const
 Get the channel number.
 
void InitSendable (wpi::SendableBuilder &builder) override
 Initializes this Sendable object.
 
- Public Member Functions inherited from wpi::Sendable
virtual constexpr ~Sendable ()=default
 
- Public Member Functions inherited from wpi::SendableHelper< AnalogEncoder >
constexpr SendableHelper (const SendableHelper &rhs)=default
 
constexpr SendableHelper (SendableHelper &&rhs)
 
constexpr SendableHelperoperator= (const SendableHelper &rhs)=default
 
constexpr SendableHelperoperator= (SendableHelper &&rhs)
 

Additional Inherited Members

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

Detailed Description

Class for supporting continuous analog encoders, such as the US Digital MA3.

Constructor & Destructor Documentation

◆ AnalogEncoder() [1/9]

frc::AnalogEncoder::AnalogEncoder ( int channel)
explicit

Construct a new AnalogEncoder attached to a specific AnalogIn channel.

This has a fullRange of 1 and an expectedZero of 0.

Parameters
channelthe analog input channel to attach to

◆ AnalogEncoder() [2/9]

frc::AnalogEncoder::AnalogEncoder ( AnalogInput & analogInput)
explicit

Construct a new AnalogEncoder attached to a specific AnalogInput.

This has a fullRange of 1 and an expectedZero of 0.

Parameters
analogInputthe analog input to attach to

◆ AnalogEncoder() [3/9]

frc::AnalogEncoder::AnalogEncoder ( AnalogInput * analogInput)
explicit

Construct a new AnalogEncoder attached to a specific AnalogInput.

This has a fullRange of 1 and an expectedZero of 0.

Parameters
analogInputthe analog input to attach to

◆ AnalogEncoder() [4/9]

frc::AnalogEncoder::AnalogEncoder ( std::shared_ptr< AnalogInput > analogInput)
explicit

Construct a new AnalogEncoder attached to a specific AnalogInput.

This has a fullRange of 1 and an expectedZero of 0.

Parameters
analogInputthe analog input to attach to

◆ AnalogEncoder() [5/9]

frc::AnalogEncoder::AnalogEncoder ( int channel,
double fullRange,
double expectedZero )

Construct a new AnalogEncoder attached to a specific AnalogIn channel.

Parameters
channelthe analog input channel to attach to
fullRangethe value to report at maximum travel
expectedZerothe reading where you would expect a 0 from get()

◆ AnalogEncoder() [6/9]

frc::AnalogEncoder::AnalogEncoder ( AnalogInput & analogInput,
double fullRange,
double expectedZero )

Construct a new AnalogEncoder attached to a specific AnalogInput.

Parameters
analogInputthe analog input to attach to
fullRangethe value to report at maximum travel
expectedZerothe reading where you would expect a 0 from get()

◆ AnalogEncoder() [7/9]

frc::AnalogEncoder::AnalogEncoder ( AnalogInput * analogInput,
double fullRange,
double expectedZero )

Construct a new AnalogEncoder attached to a specific AnalogInput.

Parameters
analogInputthe analog input to attach to
fullRangethe value to report at maximum travel
expectedZerothe reading where you would expect a 0 from get()

◆ AnalogEncoder() [8/9]

frc::AnalogEncoder::AnalogEncoder ( std::shared_ptr< AnalogInput > analogInput,
double fullRange,
double expectedZero )

Construct a new AnalogEncoder attached to a specific AnalogInput.

Parameters
analogInputthe analog input to attach to
fullRangethe value to report at maximum travel
expectedZerothe reading where you would expect a 0 from get()

◆ ~AnalogEncoder()

frc::AnalogEncoder::~AnalogEncoder ( )
override

◆ AnalogEncoder() [9/9]

frc::AnalogEncoder::AnalogEncoder ( AnalogEncoder && )
default

Member Function Documentation

◆ Get()

double frc::AnalogEncoder::Get ( ) const

Get the encoder value.

Returns
the encoder value scaled by the full range input

◆ GetChannel()

int frc::AnalogEncoder::GetChannel ( ) const

Get the channel number.

Returns
The channel number.

◆ InitSendable()

void frc::AnalogEncoder::InitSendable ( wpi::SendableBuilder & builder)
overridevirtual

Initializes this Sendable object.

Parameters
buildersendable builder

Implements wpi::Sendable.

◆ operator=()

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

◆ SetInverted()

void frc::AnalogEncoder::SetInverted ( bool inverted)

Set if this encoder is inverted.

Parameters
invertedtrue to invert the encoder, false otherwise

◆ SetVoltagePercentageRange()

void frc::AnalogEncoder::SetVoltagePercentageRange ( double min,
double max )

Set the encoder voltage percentage range.

Analog sensors are not always fully stable at the end of their travel ranges. Shrinking this range down can help mitigate issues with that.

Parameters
minminimum voltage percentage (0-1 range)
maxmaximum voltage percentage (0-1 range)

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