WPILibC++ 2023.4.3-108-ge5452e3
|
Class for supporting continuous analog encoders, such as the US Digital MA3. More...
#include <frc/AnalogEncoder.h>
Public Member Functions | |
AnalogEncoder (int channel) | |
Construct a new AnalogEncoder attached to a specific AnalogIn channel. More... | |
AnalogEncoder (AnalogInput &analogInput) | |
Construct a new AnalogEncoder attached to a specific AnalogInput. More... | |
AnalogEncoder (AnalogInput *analogInput) | |
Construct a new AnalogEncoder attached to a specific AnalogInput. More... | |
AnalogEncoder (std::shared_ptr< AnalogInput > analogInput) | |
Construct a new AnalogEncoder attached to a specific AnalogInput. More... | |
~AnalogEncoder () override=default | |
AnalogEncoder (AnalogEncoder &&)=default | |
AnalogEncoder & | operator= (AnalogEncoder &&)=default |
void | Reset () |
Reset the Encoder distance to zero. More... | |
units::turn_t | Get () const |
Get the encoder value since the last reset. More... | |
double | GetAbsolutePosition () const |
Get the absolute position of the analog encoder. More... | |
double | GetPositionOffset () const |
Get the offset of position relative to the last reset. More... | |
void | SetPositionOffset (double offset) |
Set the position offset. More... | |
void | SetDistancePerRotation (double distancePerRotation) |
Set the distance per rotation of the encoder. More... | |
double | GetDistancePerRotation () const |
Get the distance per rotation for this encoder. More... | |
double | GetDistance () const |
Get the distance the sensor has driven since the last reset as scaled by the value from SetDistancePerRotation. More... | |
int | GetChannel () const |
Get the channel number. 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< AnalogEncoder > | |
SendableHelper (const SendableHelper &rhs)=default | |
SendableHelper (SendableHelper &&rhs) | |
SendableHelper & | operator= (const SendableHelper &rhs)=default |
SendableHelper & | operator= (SendableHelper &&rhs) |
Additional Inherited Members | |
Protected Member Functions inherited from wpi::SendableHelper< AnalogEncoder > | |
SendableHelper ()=default | |
~SendableHelper () | |
Class for supporting continuous analog encoders, such as the US Digital MA3.
|
explicit |
Construct a new AnalogEncoder attached to a specific AnalogIn channel.
channel | the analog input channel to attach to |
|
explicit |
Construct a new AnalogEncoder attached to a specific AnalogInput.
analogInput | the analog input to attach to |
|
explicit |
Construct a new AnalogEncoder attached to a specific AnalogInput.
analogInput | the analog input to attach to |
|
explicit |
Construct a new AnalogEncoder attached to a specific AnalogInput.
analogInput | the analog input to attach to |
|
overridedefault |
|
default |
units::turn_t frc::AnalogEncoder::Get | ( | ) | const |
Get the encoder value since the last reset.
This is reported in rotations since the last reset.
double frc::AnalogEncoder::GetAbsolutePosition | ( | ) | const |
Get the absolute position of the analog encoder.
GetAbsolutePosition() - GetPositionOffset() will give an encoder absolute position relative to the last reset. This could potentially be negative, which needs to be accounted for.
This will not account for rollovers, and will always be just the raw absolute position.
int frc::AnalogEncoder::GetChannel | ( | ) | const |
Get the channel number.
double frc::AnalogEncoder::GetDistance | ( | ) | const |
Get the distance the sensor has driven since the last reset as scaled by the value from SetDistancePerRotation.
double frc::AnalogEncoder::GetDistancePerRotation | ( | ) | const |
Get the distance per rotation for this encoder.
double frc::AnalogEncoder::GetPositionOffset | ( | ) | const |
Get the offset of position relative to the last reset.
GetAbsolutePosition() - GetPositionOffset() will give an encoder absolute position relative to the last reset. This could potentially be negative, which needs to be accounted for.
|
overridevirtual |
|
default |
void frc::AnalogEncoder::Reset | ( | ) |
Reset the Encoder distance to zero.
void frc::AnalogEncoder::SetDistancePerRotation | ( | double | distancePerRotation | ) |
Set the distance per rotation of the encoder.
This sets the multiplier used to determine the distance driven based on the rotation value from the encoder. Set this value based on the how far the mechanism travels in 1 rotation of the encoder, and factor in gearing reductions following the encoder shaft. This distance can be in any units you like, linear or angular.
distancePerRotation | the distance per rotation of the encoder |
void frc::AnalogEncoder::SetPositionOffset | ( | double | offset | ) |
Set the position offset.
This must be in the range of 0-1.
offset | the offset |