|
Valkyrie 2026
|
Sensor for debouncing and detecting rising/falling edges of boolean inputs. More...
#include <valkyrie/sensors/DebounceSensor.h>
Public Member Functions | |
| DebounceSensor () | |
| Construct a new DebounceSensor object. | |
| void | SetEdgeCallback (std::function< void()> lambda) |
| Set a callback function for detecting any edge (rising or falling). | |
| void | SetRisingEdgeCallback (std::function< void()> lambda) |
| Set a callback function for detecting a rising edge. | |
| void | SetFallingEdgeCallback (std::function< void()> lambda) |
| Set a callback function for detecting a falling edge. | |
| void | LoggablePeriodic () override |
| Periodic callback for logging updates. | |
| Public Member Functions inherited from valor::sensors::BaseSensor< bool > | |
| virtual void | Reset () |
| Reset the sensor state. | |
| void | SetGetter (std::function< bool()> _lambda) |
| Set the lambda function to fetch sensor data. | |
| void | ApplyPostProcessing (std::function< bool(bool)> func) |
| Set a post-processing function for sensor data. | |
| bool | 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 | |
| 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. | |
| bool | WriteLog (std::string_view field, bool data) |
| double | WriteLog (std::string_view field, double data) |
| void | WriteLog (std::string_view field, const std::vector< double > &data) |
|
template<typename U> requires units::traits::is_unit_t_v<U> | |
| U | WriteLog (std::string_view field, U data) |
| void | WriteLog (std::string_view field, std::string_view data) |
|
template<typename E> requires std::is_enum_v<E> | |
| void | WriteLog (std::string_view field, E data) |
|
template<typename T> requires wpi::StructSerializable<T> && (!std::is_arithmetic_v<T>) | |
| void | WriteLog (std::string_view field, const T &data) |
|
template<typename T> requires wpi::StructSerializable<T> && (!std::is_arithmetic_v<T>) | |
| void | WriteLog (std::string_view field, const std::vector< T > &data) |
| bool | ReadLog (std::string_view field, bool defaultValue) |
| double | ReadLog (std::string_view field, double defaultValue) |
|
template<typename U> requires units::traits::is_unit_t_v<U> | |
| U | ReadLog (std::string_view field, U defaultValue) |
Protected Member Functions | |
| void | Calculate () override |
| Perform debounce-specific calculations. | |
| Protected Member Functions inherited from valor::Loggable | |
| virtual void | OnLoggingStart () |
| Hook invoked when logging is started for this object. | |
Additional Inherited Members | |
| Static Public Member Functions inherited from valor::Loggable | |
| static constexpr Loggable & | GetRoot () |
| Static Public Attributes inherited from valor::sensors::BaseSensorCore | |
| static constexpr units::millisecond_t | LOOP_PERIOD = frc::TimedRobot::kDefaultPeriod / 2 |
| Protected Attributes inherited from valor::sensors::BaseSensor< bool > | |
| std::function< bool()> | sensorLambda |
| Lambda function to fetch sensor data. | |
| std::function< bool(bool)> | postProcessor |
| Lambda function to post-process sensor data. | |
| bool | prevState |
| Previous and current sensor states. | |
| bool | currState |
Sensor for debouncing and detecting rising/falling edges of boolean inputs.
This class filters out noise in boolean inputs and detects edges (state changes).
Debouncing ensures that rapid state changes are treated as a single edge.
| valor::sensors::DebounceSensor::DebounceSensor | ( | ) |
Construct a new DebounceSensor object.
| robot | Reference to the robot, used to schedule the calculate method. |
|
overrideprotectedvirtual |
Perform debounce-specific calculations.
This method is called every 10ms and processes the boolean input to detect edges.
Reimplemented from valor::sensors::BaseSensorCore.
Reimplemented in valor::sensors::LaserProximitySensor.
|
overridevirtual |
Periodic callback for logging updates.
If a derived class needs to perform periodic updates to published values, override this method. It is intended to be called by the logging framework; this base class provides an empty implementation.
Reimplemented from valor::Loggable.
|
inline |
Set a callback function for detecting any edge (rising or falling).
| _lambda | Lambda function to execute when an edge is detected. |
|
inline |
Set a callback function for detecting a falling edge.
| _lambda | Lambda function to execute when a falling edge is detected. |
|
inline |
Set a callback function for detecting a rising edge.
| _lambda | Lambda function to execute when a rising edge is detected. |