7#include <frc/TimedRobot.h>
9#include "valkyrie/sensors/BaseSensor.h"
74 static constexpr int DEFAULT_CACHE_SIZE = 20 / 20.0;
75 static constexpr double DEFAULT_SPIKE_VALUE = 22;
77 std::function<
void()> spikeCallback;
78 std::deque<double> cache;
79 double spikedSetpoint{DEFAULT_SPIKE_VALUE};
80 int cacheSize{DEFAULT_CACHE_SIZE};
Abstract class that all Valor sensors should implement.
Definition BaseSensor.h:27
Sensor for detecting changes in motor current.
Definition CurrentSensor.h:19
void reset() override
Reset the sensor state.
void calculate() override
Perform current sensor-specific calculations.
void setSpikeCallback(std::function< void()> _lambda)
Set a callback function to trigger when a current spike is detected.
CurrentSensor(frc::TimedRobot &robot)
Construct a new CurrentSensor object.
void setSpikeSetpoint(double _setpoint)
Set the threshold for detecting a current spike.
double getAverage()
Get the average current from the rolling cache.
void setCacheSize(int _size)
Set the size of the rolling average cache.
T ReadLog(std::string_view field, const T &defaultValue={})
Read a value from NetworkTables for the given field.
Definition Loggable.h:343