3#include <frc/XboxController.h>
4#include <frc/filter/LinearFilter.h>
5#include <units/angle.h>
6#include <valkyrie/sensors/BaseSensor.h>
23class Gamepad :
public frc::XboxController {
50 inline void Reset()
override { filter.Reset(); }
71 this->deadband = deadband;
154 filter = frc::LinearFilter<double>::MovingAverage(size);
185 frc::LinearFilter<double> filter = frc::LinearFilter<double>::MovingAverage(1);
201 inline bool DPadUp()
const {
return GetPOV() == 0; }
209 inline bool DPadDown()
const {
return GetPOV() == 180; }
217 inline bool DPadLeft()
const {
return GetPOV() == 270; }
225 inline bool DPadRight()
const {
return GetPOV() == 90; }
313 AnalogValue leftStickX;
316 AnalogValue leftStickY;
319 AnalogValue rightStickX;
322 AnalogValue rightStickY;
325 AnalogValue leftTrigger;
328 AnalogValue rightTrigger;
Represents a processed analog controller input.
Definition Gamepad.h:36
void Reset() override
Resets the internal filter state.
Definition Gamepad.h:50
bool Active() const
Checks whether the analog input is currently active.
Definition Gamepad.h:60
AnalogValue & SetFilterTime(units::second_t time)
Sets the moving-average filter duration.
Definition Gamepad.h:165
int GetPolynomial() const
Gets the configured polynomial exponent.
Definition Gamepad.h:132
AnalogValue & SetPolynomial(int poly)
Sets the polynomial response curve exponent.
Definition Gamepad.h:122
double GetFiltered() const
Gets the filtered analog value.
Definition Gamepad.h:146
void Calculate() override
Updates the internal filter with the current processed value.
Definition Gamepad.h:139
AnalogValue & SetFilterSize(int size)
Sets the moving-average filter window size.
Definition Gamepad.h:153
double GetMaxValue() const
Gets the configured maximum output value.
Definition Gamepad.h:103
void SetGetter(std::function< double()> getter)
Sets the function used to retrieve the raw input value.
double GetDeadband() const
Gets the configured deadband threshold.
Definition Gamepad.h:96
AnalogValue & SetRange(double min, double max=1)
Sets the output range of the processed analog input.
Definition Gamepad.h:85
AnalogValue & SetDeadband(double deadband)
Sets the deadband applied to the input.
Definition Gamepad.h:70
double GetMinValue() const
Gets the configured minimum output value.
Definition Gamepad.h:110
bool DPadUp() const
Is the gamepad's D-pad up button pressed?
Definition Gamepad.h:201
constexpr AnalogValue & LeftTrigger()
Gets the processed left trigger input.
Definition Gamepad.h:288
constexpr const AnalogValue & LeftTrigger() const
Gets the processed left trigger input.
Definition Gamepad.h:295
Gamepad(int id)
Construct a new Valor Gamepad object.
constexpr AnalogValue & LeftStickX()
Gets the processed left stick X-axis input.
Definition Gamepad.h:232
constexpr const AnalogValue & RightTrigger() const
Gets the processed right trigger input.
Definition Gamepad.h:309
bool DPadRight() const
Is the gamepad's D-pad right button pressed?
Definition Gamepad.h:225
constexpr AnalogValue & RightStickY()
Gets the processed right stick Y-axis input.
Definition Gamepad.h:274
constexpr const AnalogValue & LeftStickY() const
Gets the processed left stick Y-axis input.
Definition Gamepad.h:253
constexpr const AnalogValue & RightStickY() const
Gets the processed right stick Y-axis input.
Definition Gamepad.h:281
constexpr const AnalogValue & RightStickX() const
Gets the processed right stick X-axis input.
Definition Gamepad.h:267
constexpr const AnalogValue & LeftStickX() const
Gets the processed left stick X-axis input.
Definition Gamepad.h:239
constexpr AnalogValue & LeftStickY()
Gets the processed left stick Y-axis input.
Definition Gamepad.h:246
bool DPadDown() const
Is the gamepad's D-pad down button pressed?
Definition Gamepad.h:209
constexpr AnalogValue & RightTrigger()
Gets the processed right trigger input.
Definition Gamepad.h:302
constexpr AnalogValue & RightStickX()
Gets the processed right stick X-axis input.
Definition Gamepad.h:260
bool DPadLeft() const
Is the gamepad's D-pad left button pressed?
Definition Gamepad.h:217
Abstract class that all Valor sensors should implement.
Definition BaseSensor.h:50
double Get() const
Definition BaseSensor.h:89