12 #include <hal/Types.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/Sendable.h"
19 #include "frc/smartdashboard/SendableHelper.h"
24 class DigitalGlitchFilter;
25 class SendableBuilder;
83 Encoder(
int aChannel,
int bChannel,
bool reverseDirection =
false,
84 EncodingType encodingType = k4X);
110 bool reverseDirection =
false, EncodingType encodingType = k4X);
136 bool reverseDirection =
false, EncodingType encodingType = k4X);
138 Encoder(std::shared_ptr<DigitalSource> aSource,
139 std::shared_ptr<DigitalSource> bSource,
bool reverseDirection =
false,
140 EncodingType encodingType = k4X);
157 int Get()
const override;
164 void Reset()
override;
317 double PIDGet()
override;
327 void SetIndexSource(
int channel, IndexingType type = kResetOnRisingEdge);
338 IndexingType type = kResetOnRisingEdge);
347 int GetFPGAIndex()
const;
369 void InitEncoder(
bool reverseDirection, EncodingType encodingType);
375 double DecodingScaleFactor()
const;
377 std::shared_ptr<DigitalSource> m_aSource;
378 std::shared_ptr<DigitalSource> m_bSource;
379 std::shared_ptr<DigitalSource> m_indexSource =
nullptr;
380 hal::Handle<HAL_EncoderHandle> m_encoder;
PIDSource interface is a generic sensor source for the PID class.
Definition: PIDSource.h:20
int Get() const override
Gets the current count.
double GetDistancePerPulse() const
Get the distance per pulse for this encoder.
Definition: DMASample.h:23
double GetDistance() const
Get the distance the robot has driven since the last reset.
void SetSimDevice(HAL_SimDeviceHandle device)
Indicates this encoder is used by a simulated device.
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.
void SetMinRate(double minRate)
Set the minimum rate of the device before the hardware reports it stopped.
bool GetStopped() const override
Determine if the encoder is stopped.
void SetDistancePerPulse(double distancePerPulse)
Set the distance per pulse for this encoder.
void InitSendable(SendableBuilder &builder) override
Initializes this Sendable object.
void SetReverseDirection(bool reverseDirection)
Set the direction sensing for this encoder.
void SetMaxPeriod(double maxPeriod) override
Sets the maximum period for stopped detection.
Base class for most objects.
Definition: ErrorBase.h:104
int GetSamplesToAverage() const
Get the Samples to Average which specifies the number of samples of the timer to average when calcula...
int GetRaw() const
Gets the raw value from the encoder.
Class to enable glitch filtering on a set of digital inputs.
Definition: DigitalGlitchFilter.h:33
void SetIndexSource(int channel, IndexingType type=kResetOnRisingEdge)
Set the index source for the encoder.
int GetEncodingScale() const
The encoding scale factor 1x, 2x, or 4x, per the requested encodingType.
void Reset() override
Reset the Encoder distance to zero.
Encoder(int aChannel, int bChannel, bool reverseDirection=false, EncodingType encodingType=k4X)
Encoder constructor.
void SetSamplesToAverage(int samplesToAverage)
Set the Samples to Average which specifies the number of samples of the timer to average when calcula...
Interface for Sendable objects.
Definition: Sendable.h:17
Class to read quad encoders.
Definition: Encoder.h:44
A class that enforces constraints on the differential drive kinematics.
Definition: SPIAccelerometerSim.h:16
double GetRate() const
Get the current rate of the encoder.
DigitalSource Interface.
Definition: DigitalSource.h:25
double GetPeriod() const override
Returns the period of the most recent pulse.
A helper class for use with objects that add themselves to SendableRegistry.
Definition: SendableHelper.h:28
Definition: SendableBuilder.h:23