|
Valor 6800 1.0
|
Sensor for detecting changes in motor current. More...
#include <CurrentSensor.h>
Public Member Functions | |
| CurrentSensor (frc::TimedRobot &robot) | |
| Construct a new CurrentSensor object. | |
| void | reset () override |
| Reset the sensor state. | |
| void | setSpikeCallback (std::function< void()> _lambda) |
| Set a callback function to trigger when a current spike is detected. | |
| void | setSpikeSetpoint (double _setpoint) |
| Set the threshold for detecting a current spike. | |
| void | setCacheSize (int _size) |
| Set the size of the rolling average cache. | |
Public Member Functions inherited from valor::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 () |
| Get the current sensor state. | |
Public Member Functions inherited from valor::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 | setLoggingPeriod (units::millisecond_t period) |
| Set the minimum period between LoggablePeriodic() invocations. | |
| 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) |
Protected Member Functions | |
| void | calculate () override |
| Perform current sensor-specific calculations. | |
| double | getAverage () |
| Get the average current from the rolling cache. | |
Protected Member Functions inherited from valor::BaseSensor< double > | |
| BaseSensor (frc::TimedRobot &robot) | |
| Construct a new BaseSensor object. | |
| virtual void | refresh () |
| Refresh the sensor state. | |
Protected Member Functions inherited from valor::Loggable | |
| Loggable (std::string_view name) | |
| Construct a Loggable that registers a top-level table name. | |
| Loggable () | |
| Default construct an uninitialized Loggable. | |
| virtual | ~Loggable ()=default |
| Virtual destructor. | |
| virtual void | OnLoggingStart () |
| Hook invoked when logging is started for this object. | |
| virtual void | LoggablePeriodic () |
| Periodic callback for logging updates. | |
| template<typename T > | |
| T | WriteLog (std::string_view field, const T &data) |
| Publish a value to NetworkTables under the given field. | |
| template<typename T > | |
| T | ReadLog (std::string_view field, const T &defaultValue={}) |
| Read a value from NetworkTables for the given field. | |
Additional Inherited Members | |
Static Public Member Functions inherited from valor::Loggable | |
| static units::millisecond_t | GetLoggingTime () |
Protected Attributes inherited from valor::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 |
| frc::Timer | profiler |
Sensor for detecting changes in motor current.
This class monitors the output current of a motor and uses a rolling average to detect spikes in current. It can trigger callbacks when a spike is detected.
|
explicit |
Construct a new CurrentSensor object.
| robot | Reference to the robot, used to schedule the calculate method. |
|
overrideprotectedvirtual |
Perform current sensor-specific calculations.
This method is called every 10ms and processes the current data to detect spikes.
Implements valor::BaseSensor< double >.
|
protected |
Get the average current from the rolling cache.
|
overridevirtual |
Reset the sensor state.
Clears the rolling average cache and resets the spike setpoint.
Reimplemented from valor::BaseSensor< double >.
Set the size of the rolling average cache.
| _size | Number of data points to include in the rolling average. |
Set a callback function to trigger when a current spike is detected.
| _lambda | Lambda function to execute on a current spike. |
Set the threshold for detecting a current spike.
| _setpoint | Current value that triggers a spike. |