WPILibC++ 2024.3.2
|
Class to control a simulated encoder. More...
#include <frc/simulation/EncoderSim.h>
Public Member Functions | |
EncoderSim (const Encoder &encoder) | |
Constructs from an Encoder object. More... | |
std::unique_ptr< CallbackStore > | RegisterInitializedCallback (NotifyCallback callback, bool initialNotify) |
Register a callback on the Initialized property of the encoder. More... | |
bool | GetInitialized () const |
Read the Initialized value of the encoder. More... | |
void | SetInitialized (bool initialized) |
Change the Initialized value of the encoder. More... | |
std::unique_ptr< CallbackStore > | RegisterCountCallback (NotifyCallback callback, bool initialNotify) |
Register a callback on the count property of the encoder. More... | |
int | GetCount () const |
Read the count of the encoder. More... | |
void | SetCount (int count) |
Change the count of the encoder. More... | |
std::unique_ptr< CallbackStore > | RegisterPeriodCallback (NotifyCallback callback, bool initialNotify) |
Register a callback on the period of the encoder. More... | |
double | GetPeriod () const |
Read the period of the encoder. More... | |
void | SetPeriod (double period) |
Change the encoder period. More... | |
std::unique_ptr< CallbackStore > | RegisterResetCallback (NotifyCallback callback, bool initialNotify) |
Register a callback to be called whenever the encoder is reset. More... | |
bool | GetReset () const |
Check if the encoder has been reset. More... | |
void | SetReset (bool reset) |
Change the reset property of the encoder. More... | |
std::unique_ptr< CallbackStore > | RegisterMaxPeriodCallback (NotifyCallback callback, bool initialNotify) |
Register a callback to be run whenever the max period of the encoder is changed. More... | |
double | GetMaxPeriod () const |
Get the max period of the encoder. More... | |
void | SetMaxPeriod (double maxPeriod) |
Change the max period of the encoder. More... | |
std::unique_ptr< CallbackStore > | RegisterDirectionCallback (NotifyCallback callback, bool initialNotify) |
Register a callback on the direction of the encoder. More... | |
bool | GetDirection () const |
Get the direction of the encoder. More... | |
void | SetDirection (bool direction) |
Set the direction of the encoder. More... | |
std::unique_ptr< CallbackStore > | RegisterReverseDirectionCallback (NotifyCallback callback, bool initialNotify) |
Register a callback on the reverse direction. More... | |
bool | GetReverseDirection () const |
Get the reverse direction of the encoder. More... | |
void | SetReverseDirection (bool reverseDirection) |
Set the reverse direction. More... | |
std::unique_ptr< CallbackStore > | RegisterSamplesToAverageCallback (NotifyCallback callback, bool initialNotify) |
Register a callback on the samples-to-average value of this encoder. More... | |
int | GetSamplesToAverage () const |
Get the samples-to-average value. More... | |
void | SetSamplesToAverage (int samplesToAverage) |
Set the samples-to-average value. More... | |
std::unique_ptr< CallbackStore > | RegisterDistancePerPulseCallback (NotifyCallback callback, bool initialNotify) |
Register a callback on the distance per pulse value of this encoder. More... | |
double | GetDistancePerPulse () const |
Read the distance per pulse of the encoder. More... | |
void | SetDistancePerPulse (double distancePerPulse) |
Change the encoder distance per pulse. More... | |
void | ResetData () |
Resets all simulation data for this encoder. More... | |
void | SetDistance (double distance) |
Change the encoder distance. More... | |
double | GetDistance () const |
Read the distance of the encoder. More... | |
void | SetRate (double rate) |
Change the rate of the encoder. More... | |
double | GetRate () const |
Get the rate of the encoder. More... | |
Static Public Member Functions | |
static EncoderSim | CreateForChannel (int channel) |
Creates an EncoderSim for a digital input channel. More... | |
static EncoderSim | CreateForIndex (int index) |
Creates an EncoderSim for a simulated index. More... | |
Class to control a simulated encoder.
|
explicit |
|
static |
Creates an EncoderSim for a digital input channel.
Encoders take two channels, so either one may be specified.
channel | digital input channel |
NoSuchElementException | if no Encoder is configured for that channel |
|
static |
Creates an EncoderSim for a simulated index.
The index is incremented for each simulated Encoder.
index | simulator index |
int frc::sim::EncoderSim::GetCount | ( | ) | const |
Read the count of the encoder.
bool frc::sim::EncoderSim::GetDirection | ( | ) | const |
Get the direction of the encoder.
double frc::sim::EncoderSim::GetDistance | ( | ) | const |
Read the distance of the encoder.
double frc::sim::EncoderSim::GetDistancePerPulse | ( | ) | const |
Read the distance per pulse of the encoder.
bool frc::sim::EncoderSim::GetInitialized | ( | ) | const |
Read the Initialized value of the encoder.
double frc::sim::EncoderSim::GetMaxPeriod | ( | ) | const |
Get the max period of the encoder.
double frc::sim::EncoderSim::GetPeriod | ( | ) | const |
Read the period of the encoder.
double frc::sim::EncoderSim::GetRate | ( | ) | const |
Get the rate of the encoder.
bool frc::sim::EncoderSim::GetReset | ( | ) | const |
Check if the encoder has been reset.
bool frc::sim::EncoderSim::GetReverseDirection | ( | ) | const |
Get the reverse direction of the encoder.
int frc::sim::EncoderSim::GetSamplesToAverage | ( | ) | const |
Get the samples-to-average value.
std::unique_ptr< CallbackStore > frc::sim::EncoderSim::RegisterCountCallback | ( | NotifyCallback | callback, |
bool | initialNotify | ||
) |
Register a callback on the count property of the encoder.
callback | the callback that will be called whenever the count property is changed |
initialNotify | if true, the callback will be run on the initial value |
std::unique_ptr< CallbackStore > frc::sim::EncoderSim::RegisterDirectionCallback | ( | NotifyCallback | callback, |
bool | initialNotify | ||
) |
Register a callback on the direction of the encoder.
callback | the callback that will be called whenever the direction is changed |
initialNotify | if true, the callback will be run on the initial value |
std::unique_ptr< CallbackStore > frc::sim::EncoderSim::RegisterDistancePerPulseCallback | ( | NotifyCallback | callback, |
bool | initialNotify | ||
) |
Register a callback on the distance per pulse value of this encoder.
callback | the callback that will be called whenever the distance per pulse is changed |
initialNotify | if true, the callback will be run on the initial value |
std::unique_ptr< CallbackStore > frc::sim::EncoderSim::RegisterInitializedCallback | ( | NotifyCallback | callback, |
bool | initialNotify | ||
) |
Register a callback on the Initialized property of the encoder.
callback | the callback that will be called whenever the Initialized property is changed |
initialNotify | if true, the callback will be run on the initial value |
std::unique_ptr< CallbackStore > frc::sim::EncoderSim::RegisterMaxPeriodCallback | ( | NotifyCallback | callback, |
bool | initialNotify | ||
) |
Register a callback to be run whenever the max period of the encoder is changed.
callback | the callback |
initialNotify | whether to run the callback on the initial value |
std::unique_ptr< CallbackStore > frc::sim::EncoderSim::RegisterPeriodCallback | ( | NotifyCallback | callback, |
bool | initialNotify | ||
) |
Register a callback on the period of the encoder.
callback | the callback that will be called whenever the period is changed |
initialNotify | if true, the callback will be run on the initial value |
std::unique_ptr< CallbackStore > frc::sim::EncoderSim::RegisterResetCallback | ( | NotifyCallback | callback, |
bool | initialNotify | ||
) |
Register a callback to be called whenever the encoder is reset.
callback | the callback |
initialNotify | whether to run the callback on the initial value |
std::unique_ptr< CallbackStore > frc::sim::EncoderSim::RegisterReverseDirectionCallback | ( | NotifyCallback | callback, |
bool | initialNotify | ||
) |
Register a callback on the reverse direction.
callback | the callback that will be called whenever the reverse direction is changed |
initialNotify | if true, the callback will be run on the initial value |
std::unique_ptr< CallbackStore > frc::sim::EncoderSim::RegisterSamplesToAverageCallback | ( | NotifyCallback | callback, |
bool | initialNotify | ||
) |
Register a callback on the samples-to-average value of this encoder.
callback | the callback that will be called whenever the samples-to-average is changed |
initialNotify | if true, the callback will be run on the initial value |
void frc::sim::EncoderSim::ResetData | ( | ) |
Resets all simulation data for this encoder.
void frc::sim::EncoderSim::SetCount | ( | int | count | ) |
Change the count of the encoder.
count | the new count |
void frc::sim::EncoderSim::SetDirection | ( | bool | direction | ) |
Set the direction of the encoder.
direction | the new direction |
void frc::sim::EncoderSim::SetDistance | ( | double | distance | ) |
Change the encoder distance.
distance | the new distance |
void frc::sim::EncoderSim::SetDistancePerPulse | ( | double | distancePerPulse | ) |
Change the encoder distance per pulse.
distancePerPulse | the new distance per pulse |
void frc::sim::EncoderSim::SetInitialized | ( | bool | initialized | ) |
Change the Initialized value of the encoder.
initialized | the new value |
void frc::sim::EncoderSim::SetMaxPeriod | ( | double | maxPeriod | ) |
Change the max period of the encoder.
maxPeriod | the new value |
void frc::sim::EncoderSim::SetPeriod | ( | double | period | ) |
Change the encoder period.
period | the new period |
void frc::sim::EncoderSim::SetRate | ( | double | rate | ) |
Change the rate of the encoder.
rate | the new rate |
void frc::sim::EncoderSim::SetReset | ( | bool | reset | ) |
Change the reset property of the encoder.
reset | the new value |
void frc::sim::EncoderSim::SetReverseDirection | ( | bool | reverseDirection | ) |
Set the reverse direction.
reverseDirection | the new value |
void frc::sim::EncoderSim::SetSamplesToAverage | ( | int | samplesToAverage | ) |
Set the samples-to-average value.
samplesToAverage | the new value |