12 #include <hal/Encoder.h>
14 #include "frc/Counter.h"
15 #include "frc/CounterBase.h"
16 #include "frc/ErrorBase.h"
17 #include "frc/PIDSource.h"
18 #include "frc/smartdashboard/SendableBase.h"
23 class DigitalGlitchFilter;
75 Encoder(
int aChannel,
int bChannel,
bool reverseDirection =
false,
76 EncodingType encodingType = k4X);
102 bool reverseDirection =
false, EncodingType encodingType = k4X);
128 bool reverseDirection =
false, EncodingType encodingType = k4X);
130 Encoder(std::shared_ptr<DigitalSource> aSource,
131 std::shared_ptr<DigitalSource> bSource,
bool reverseDirection =
false,
132 EncodingType encodingType = k4X);
146 int Get()
const override;
153 void Reset()
override;
306 double PIDGet()
override;
316 void SetIndexSource(
int channel, IndexingType type = kResetOnRisingEdge);
327 IndexingType type = kResetOnRisingEdge);
329 int GetFPGAIndex()
const;
351 void InitEncoder(
bool reverseDirection, EncodingType encodingType);
357 double DecodingScaleFactor()
const;
359 std::shared_ptr<DigitalSource> m_aSource;
360 std::shared_ptr<DigitalSource> m_bSource;
361 std::shared_ptr<DigitalSource> m_indexSource =
nullptr;
362 HAL_EncoderHandle m_encoder = HAL_kInvalidHandle;
WPILib FRC namespace.
Definition: SPIAccelerometerSim.h:18
int GetSamplesToAverage() const
Get the Samples to Average which specifies the number of samples of the timer to average when calcula...
double GetRate() const
Get the current rate of the encoder.
void SetDistancePerPulse(double distancePerPulse)
Set the distance per pulse for this encoder.
void SetMaxPeriod(double maxPeriod) override
Sets the maximum period for stopped detection.
Class to read quad encoders.
Definition: Encoder.h:40
PIDSource interface is a generic sensor source for the PID class.
Definition: PIDSource.h:20
Class to enable glitch filtering on a set of digital inputs.
Definition: DigitalGlitchFilter.h:32
double GetDistancePerPulse() const
Get the distance per pulse for this encoder.
Interface for counting the number of ticks on a digital input channel.
Definition: CounterBase.h:21
bool GetDirection() const override
The last direction the encoder value changed.
int GetRaw() const
Gets the raw value from the encoder.
void Reset() override
Reset the Encoder distance to zero.
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
void SetReverseDirection(bool reverseDirection)
Set the direction sensing for this encoder.
int GetEncodingScale() const
The encoding scale factor 1x, 2x, or 4x, per the requested encodingType.
DigitalSource Interface.
Definition: DigitalSource.h:25
bool GetStopped() const override
Determine if the encoder is stopped.
void SetMinRate(double minRate)
Set the minimum rate of the device before the hardware reports it stopped.
Encoder(int aChannel, int bChannel, bool reverseDirection=false, EncodingType encodingType=k4X)
Encoder constructor.
Base class for most objects.
Definition: ErrorBase.h:74
void SetSamplesToAverage(int samplesToAverage)
Set the Samples to Average which specifies the number of samples of the timer to average when calcula...
Definition: SendableBase.h:19
double GetDistance() const
Get the distance the robot has driven since the last reset.
int Get() const override
Gets the current count.
Definition: SendableBuilder.h:23
void SetIndexSource(int channel, IndexingType type=kResetOnRisingEdge)
Set the index source for the encoder.
double GetPeriod() const override
Returns the period of the most recent pulse.