Valkyrie 2026
Loading...
Searching...
No Matches
valor::Gamepad::AnalogValue Class Reference

Represents a processed analog controller input. More...

#include <valkyrie/Gamepad.h>

Inheritance diagram for valor::Gamepad::AnalogValue:
valor::sensors::BaseSensor< double > valor::sensors::BaseSensorCore valor::Loggable

Public Member Functions

void SetGetter (std::function< double()> getter)
 Sets the function used to retrieve the raw input value.
void Reset () override
 Resets the internal filter state.
bool Active () const
 Checks whether the analog input is currently active.
AnalogValueSetDeadband (double deadband)
 Sets the deadband applied to the input.
AnalogValueSetRange (double min, double max=1)
 Sets the output range of the processed analog input.
double GetDeadband () const
 Gets the configured deadband threshold.
double GetMaxValue () const
 Gets the configured maximum output value.
double GetMinValue () const
 Gets the configured minimum output value.
AnalogValueSetPolynomial (int poly)
 Sets the polynomial response curve exponent.
int GetPolynomial () const
 Gets the configured polynomial exponent.
void Calculate () override
 Updates the internal filter with the current processed value.
double GetFiltered () const
 Gets the filtered analog value.
AnalogValueSetFilterSize (int size)
 Sets the moving-average filter window size.
AnalogValueSetFilterTime (units::second_t time)
 Sets the moving-average filter duration.
Public Member Functions inherited from valor::sensors::BaseSensor< double >
void SetGetter (std::function< double()> _lambda)
 Set the lambda function to fetch sensor data.
void ApplyPostProcessing (std::function< double(double)> func)
 Set a post-processing function for sensor data.
double Get () const
 Get the current sensor state.
void Refresh () override
 Refresh the sensor state.
Public Member Functions inherited from valor::Loggable
 Loggable (std::string_view name)
 Construct a Loggable that registers a top-level table name.
 Loggable (std::shared_ptr< nt::NetworkTable > table)
 Construct a Loggable that uses an existing NetworkTable.
 Loggable ()
 Default construct an uninitialized Loggable.
void LogChild (std::string_view name, Loggable *child)
 Register a child Loggable under a named subtree.
void LogChild (std::string_view name, wpi::Sendable *child)
 Register a child Sendable under a named subtree.
void SetPeriodicLevel (LogLevel level)
 Set the logging level for LoggablePeriodic.
template<typename T>
WriteLog (std::string_view field, const T &data, LogLevel level=LogLevel::Normal)
 Publish a value to NetworkTables under the given field.
template<typename T>
ReadLog (std::string_view field, const T &defaultValue={})
 Read a value from NetworkTables for the given field.
template<>
decltype(Loggable::subscribers) ::iterator addSubscriber (std::string_view field, const std::vector< bool > &defaultValue)
template<>
void WriteLogImpl (nt::Publisher *pub, const std::vector< bool > &data)
template<>
std::vector< bool > ReadLogImpl (nt::Subscriber *sub)

Additional Inherited Members

Static Public Member Functions inherited from valor::Loggable
static units::millisecond_t GetLoggingTime ()
static constexpr LoggableGetRoot ()
Static Public Attributes inherited from valor::sensors::BaseSensorCore
static constexpr units::millisecond_t LOOP_PERIOD = frc::TimedRobot::kDefaultPeriod / 2
Protected Member Functions inherited from valor::Loggable
virtual void OnLoggingStart ()
 Hook invoked when logging is started for this object.
virtual void LoggablePeriodic ()
 Periodic callback for logging updates.
Protected Attributes inherited from valor::sensors::BaseSensor< double >
std::function< double()> sensorLambda
 Lambda function to fetch sensor data.
std::function< double(double)> postProcessor
 Lambda function to post-process sensor data.
double prevState
 Previous and current sensor states.
double currState

Detailed Description

Represents a processed analog controller input.

AnalogValue wraps a raw controller axis and provides optional:

  • Deadband processing
  • Polynomial scaling
  • Moving-average filtering

This class inherits from BaseSensor<double> to integrate with the sensor abstraction framework

Member Function Documentation

◆ Active()

bool valor::Gamepad::AnalogValue::Active ( ) const
inline

Checks whether the analog input is currently active.

An input is considered active if its processed value is nonzero.

Returns
true if the processed value is nonzero
false if the processed value is zero

◆ Calculate()

void valor::Gamepad::AnalogValue::Calculate ( )
inlineoverridevirtual

Updates the internal filter with the current processed value.

Will automatically be called periodically by BaseSensor

Reimplemented from valor::sensors::BaseSensorCore.

◆ GetDeadband()

double valor::Gamepad::AnalogValue::GetDeadband ( ) const
inline

Gets the configured deadband threshold.

Returns
Current deadband value

◆ GetFiltered()

double valor::Gamepad::AnalogValue::GetFiltered ( ) const
inline

Gets the filtered analog value.

Returns
Most recent filtered value

◆ GetMaxValue()

double valor::Gamepad::AnalogValue::GetMaxValue ( ) const
inline

Gets the configured maximum output value.

Returns
Maximum output value

◆ GetMinValue()

double valor::Gamepad::AnalogValue::GetMinValue ( ) const
inline

Gets the configured minimum output value.

Returns
Minimum output value

◆ GetPolynomial()

int valor::Gamepad::AnalogValue::GetPolynomial ( ) const
inline

Gets the configured polynomial exponent.

Returns
Polynomial exponent

◆ Reset()

void valor::Gamepad::AnalogValue::Reset ( )
inlineoverridevirtual

Resets the internal filter state.

Reimplemented from valor::sensors::BaseSensor< double >.

◆ SetDeadband()

AnalogValue & valor::Gamepad::AnalogValue::SetDeadband ( double deadband)
inline

Sets the deadband applied to the input.

Input values whose magnitude is less than the deadband are treated as zero.

Parameters
deadbandDeadband threshold
Returns
Reference to this AnalogValue instance for chaining

◆ SetFilterSize()

AnalogValue & valor::Gamepad::AnalogValue::SetFilterSize ( int size)
inline

Sets the moving-average filter window size.

Parameters
sizeNumber of samples used in the moving average

◆ SetFilterTime()

AnalogValue & valor::Gamepad::AnalogValue::SetFilterTime ( units::second_t time)
inline

Sets the moving-average filter duration.

The filter size is computed using LOOP_PERIOD.

Parameters
timeDesired averaging duration

◆ SetGetter()

void valor::Gamepad::AnalogValue::SetGetter ( std::function< double()> getter)

Sets the function used to retrieve the raw input value.

Typically bound to one of the underlying XboxController axis getter functions.

Parameters
getterFunction returning the raw analog value

◆ SetPolynomial()

AnalogValue & valor::Gamepad::AnalogValue::SetPolynomial ( int poly)
inline

Sets the polynomial response curve exponent.

Higher exponents reduce sensitivity near zero while preseving full-scale output

Examples:

  • 1 = linear
  • 2 = quadratic
  • 3 = cubic

◆ SetRange()

AnalogValue & valor::Gamepad::AnalogValue::SetRange ( double min,
double max = 1 )
inline

Sets the output range of the processed analog input.

The processed input is linearly mapped into the range [min, max] after deadband removal and polynomial scaling.

Parameters
minMinimum output magnitude immediately outside the deadband
maxMaximum output magnitude at full input
Returns
Reference to this AnalogValue instance for chaining

The documentation for this class was generated from the following file: