7#include <frc/TimedRobot.h>
10#include "valkyrie/Loggable.h"
11#include "valkyrie/util/Profiler.h"
66 inline T get() {
return currState; }
83 if (util::Profiler::IsEnabled()) {
84 WriteLog(
"Profiler/Cycle Time", units::millisecond_t{profiler.Get()});
89 frc::TimedRobot::kDefaultPeriod / 2, 5
_ms);
Abstract class that all Valor sensors should implement.
Definition BaseSensor.h:27
T get()
Get the current sensor state.
Definition BaseSensor.h:66
BaseSensor(frc::TimedRobot &robot)
Construct a new BaseSensor object.
Definition BaseSensor.h:74
void setGetter(std::function< T()> _lambda)
Set the lambda function to fetch sensor data.
Definition BaseSensor.h:46
virtual void reset()
Reset the sensor state.
Definition BaseSensor.h:36
T prevState
Previous and current sensor states.
Definition BaseSensor.h:137
void applyPostProcessing(std::function< T(T)> func)
Set a post-processing function for sensor data.
Definition BaseSensor.h:56
std::function< T()> sensorLambda
Lambda function to fetch sensor data.
Definition BaseSensor.h:122
std::function< T(T)> postProcessor
Lambda function to post-process sensor data.
Definition BaseSensor.h:129
virtual void refresh()
Refresh the sensor state.
Definition BaseSensor.h:108
virtual void calculate()=0
Perform sensor-specific calculations.
Base helper for publishing and subscribing values to NetworkTables.
Definition Loggable.h:204
T ReadLog(std::string_view field, const T &defaultValue={})
Read a value from NetworkTables for the given field.
Definition Loggable.h:343
T WriteLog(std::string_view field, const T &data)
Publish a value to NetworkTables under the given field.
Definition Loggable.h:313