122 units::turn_t
Get()
const;
219 double MapSensorRange(
double pos)
const;
221 std::shared_ptr<DutyCycle> m_dutyCycle;
222 std::unique_ptr<AnalogTrigger> m_analogTrigger;
223 std::unique_ptr<Counter> m_counter;
224 int m_frequencyThreshold = 100;
225 double m_positionOffset = 0;
226 double m_distancePerRotation = 1.0;
227 mutable units::turn_t m_lastPosition{0.0};
228 double m_sensorMin = 0;
229 double m_sensorMax = 1;
231 hal::SimDevice m_simDevice;
232 hal::SimDouble m_simPosition;
233 hal::SimDouble m_simAbsolutePosition;
234 hal::SimDouble m_simDistancePerRotation;
235 hal::SimBoolean m_simIsConnected;
DigitalSource Interface.
Definition: DigitalSource.h:22
Class for supporting duty cycle/PWM encoders, such as the US Digital MA3 with PWM Output,...
Definition: DutyCycleEncoder.h:28
DutyCycleEncoder(std::shared_ptr< DigitalSource > digitalSource)
Construct a new DutyCycleEncoder attached to a DigitalSource object.
DutyCycleEncoder(DutyCycle &dutyCycle)
Construct a new DutyCycleEncoder attached to an existing DutyCycle object.
double GetAbsolutePosition() const
Get the absolute position of the duty cycle encoder encoder.
DutyCycleEncoder(DutyCycle *dutyCycle)
Construct a new DutyCycleEncoder attached to an existing DutyCycle object.
double GetDistance() const
Get the distance the sensor has driven since the last reset as scaled by the value from SetDistancePe...
bool IsConnected() const
Get if the sensor is connected.
DutyCycleEncoder(DigitalSource &digitalSource)
Construct a new DutyCycleEncoder attached to a DigitalSource object.
void SetPositionOffset(double offset)
Set the position offset.
DutyCycleEncoder(DigitalSource *digitalSource)
Construct a new DutyCycleEncoder attached to a DigitalSource object.
double GetDistancePerRotation() const
Get the distance per rotation for this encoder.
~DutyCycleEncoder() override=default
int GetFrequency() const
Get the frequency in Hz of the duty cycle signal from the encoder.
int GetSourceChannel() const
Get the channel of the source.
void SetDistancePerRotation(double distancePerRotation)
Set the distance per rotation of the encoder.
int GetFPGAIndex() const
Get the FPGA index for the DutyCycleEncoder.
DutyCycleEncoder(std::shared_ptr< DutyCycle > dutyCycle)
Construct a new DutyCycleEncoder attached to an existing DutyCycle object.
void InitSendable(wpi::SendableBuilder &builder) override
Initializes this Sendable object.
units::turn_t Get() const
Get the encoder value since the last reset.
DutyCycleEncoder & operator=(DutyCycleEncoder &&)=default
double GetPositionOffset() const
Get the offset of position relative to the last reset.
void Reset()
Reset the Encoder distance to zero.
void SetDutyCycleRange(double min, double max)
Set the encoder duty cycle range.
void SetConnectedFrequencyThreshold(int frequency)
Change the frequency threshold for detecting connection used by IsConnected.
DutyCycleEncoder(int channel)
Construct a new DutyCycleEncoder on a specific channel.
DutyCycleEncoder(DutyCycleEncoder &&)=default
Class to read a duty cycle PWM input.
Definition: DutyCycle.h:31
Definition: SendableBuilder.h:18
A helper class for use with objects that add themselves to SendableRegistry.
Definition: SendableHelper.h:19
Interface for Sendable objects.
Definition: Sendable.h:16
constexpr common_t< T1, T2 > max(const T1 x, const T2 y) noexcept
Compile-time pairwise maximum function.
Definition: max.hpp:35
constexpr common_t< T1, T2 > min(const T1 x, const T2 y) noexcept
Compile-time pairwise minimum function.
Definition: min.hpp:35
Definition: AprilTagFieldLayout.h:22