13 #include <HAL/Encoder.h> 16 #include "CounterBase.h" 17 #include "LiveWindow/LiveWindowSendable.h" 18 #include "PIDSource.h" 19 #include "SensorBase.h" 20 #include "networktables/NetworkTableEntry.h" 54 Encoder(
int aChannel,
int bChannel,
bool reverseDirection =
false,
55 EncodingType encodingType = k4X);
56 Encoder(std::shared_ptr<DigitalSource> aSource,
57 std::shared_ptr<DigitalSource> bSource,
bool reverseDirection =
false,
58 EncodingType encodingType = k4X);
60 bool reverseDirection =
false, EncodingType encodingType = k4X);
62 bool reverseDirection =
false, EncodingType encodingType = k4X);
66 int Get()
const override;
69 void Reset()
override;
84 void SetIndexSource(
int channel, IndexingType type = kResetOnRisingEdge);
86 IndexingType type = kResetOnRisingEdge);
92 void InitTable(std::shared_ptr<nt::NetworkTable> subTable)
override;
94 int GetFPGAIndex()
const;
97 void InitEncoder(
bool reverseDirection, EncodingType encodingType);
99 double DecodingScaleFactor()
const;
101 std::shared_ptr<DigitalSource> m_aSource;
102 std::shared_ptr<DigitalSource> m_bSource;
103 std::unique_ptr<DigitalSource> m_indexSource =
nullptr;
104 HAL_EncoderHandle m_encoder = HAL_kInvalidHandle;
double GetDistance() const
Get the distance the robot has driven since the last reset.
Definition: Encoder.cpp:313
int GetSamplesToAverage() const
Get the Samples to Average which specifies the number of samples of the timer to average when calcula...
Definition: Encoder.cpp:419
void SetReverseDirection(bool reverseDirection)
Set the direction sensing for this encoder.
Definition: Encoder.cpp:382
void SetMinRate(double minRate)
Set the minimum rate of the device before the hardware reports it stopped.
Definition: Encoder.cpp:343
std::string GetSmartDashboardType() const override
Definition: Encoder.cpp:498
void UpdateTable() override
Update the table for this sendable object with the latest values.
Definition: Encoder.cpp:482
void SetIndexSource(int channel, IndexingType type=kResetOnRisingEdge)
Set the index source for the encoder.
Definition: Encoder.cpp:451
int Get() const override
Gets the current count.
Definition: Encoder.cpp:203
bool GetStopped() const override
Determine if the encoder is stopped.
Definition: Encoder.cpp:274
Live Window Sendable is a special type of object sendable to the live window.
Definition: LiveWindowSendable.h:17
Base class for all sensors.
Definition: SensorBase.h:20
Class to read quad encoders.
Definition: Encoder.h:42
PIDSource interface is a generic sensor source for the PID class.
Definition: PIDSource.h:19
Class to enable glitch filtering on a set of digital inputs.
Definition: DigitalGlitchFilter.h:28
bool GetDirection() const override
The last direction the encoder value changed.
Definition: Encoder.cpp:287
Interface for counting the number of ticks on a digital input channel.
Definition: CounterBase.h:20
double GetPeriod() const override
Returns the period of the most recent pulse.
Definition: Encoder.cpp:234
virtual ~Encoder()
Free the resources for an Encoder.
Definition: Encoder.cpp:160
void SetSamplesToAverage(int samplesToAverage)
Set the Samples to Average which specifies the number of samples of the timer to average when calcula...
Definition: Encoder.cpp:398
void InitTable(std::shared_ptr< nt::NetworkTable > subTable) override
Initializes a table for this sendable object.
Definition: Encoder.cpp:508
void SetDistancePerPulse(double distancePerPulse)
Set the distance per pulse for this encoder.
Definition: Encoder.cpp:367
DigitalSource Interface.
Definition: DigitalSource.h:26
double PIDGet() override
Implement the PIDSource interface.
Definition: Encoder.cpp:431
void SetMaxPeriod(double maxPeriod) override
Sets the maximum period for stopped detection.
Definition: Encoder.cpp:258
int GetEncodingScale() const
The encoding scale factor 1x, 2x, or 4x, per the requested encodingType.
Definition: Encoder.cpp:171
double GetRate() const
Get the current rate of the encoder.
Definition: Encoder.cpp:329
void Reset() override
Reset the Encoder distance to zero.
Definition: Encoder.cpp:216
void StopLiveWindowMode() override
Stop having this sendable object automatically respond to value changes.
Definition: Encoder.cpp:496
int GetRaw() const
Gets the raw value from the encoder.
Definition: Encoder.cpp:186
Encoder(int aChannel, int bChannel, bool reverseDirection=false, EncodingType encodingType=k4X)
Encoder constructor.
Definition: Encoder.cpp:75
NetworkTables Entry.
Definition: NetworkTableEntry.h:30
void StartLiveWindowMode() override
Start having this sendable object automatically respond to value changes reflect the value on the tab...
Definition: Encoder.cpp:494