2022-Robot
Robot code for 2022 FRC Season by Argos, FRC team #1756
Loading...
Searching...
No Matches
hysteresis_filter.h
Go to the documentation of this file.
1
4
5#pragma once
6
7namespace argos_lib {
8
14 template <typename T>
16 public:
17 HysteresisFilter() = delete;
18
25 HysteresisFilter(T deactivateThreshold, T activateThreshold)
26 : m_activateThreshold(activateThreshold), m_deactivateThreshold(deactivateThreshold) {}
27
34 [[nodiscard]] bool operator()(T newValue) {
35 if (m_currentState) {
36 if (newValue < m_deactivateThreshold) {
37 m_currentState = false;
38 }
39 } else {
40 if (newValue > m_activateThreshold) {
41 m_currentState = true;
42 }
43 }
44 return m_currentState;
45 }
46
47 private:
51 };
52} // namespace argos_lib
A simple hysteresis filter for giving a bool output for a threshold.
Definition: hysteresis_filter.h:15
HysteresisFilter(T deactivateThreshold, T activateThreshold)
Construct a new Hysteresis Filter object.
Definition: hysteresis_filter.h:25
const T m_activateThreshold
Threshold above which output becomes true.
Definition: hysteresis_filter.h:48
const T m_deactivateThreshold
Threshold below which output becomes false.
Definition: hysteresis_filter.h:49
bool operator()(T newValue)
Gets new status after applying hysteresis.
Definition: hysteresis_filter.h:34
bool m_currentState
Latest state after applying hysteresis.
Definition: hysteresis_filter.h:50
Definition: swap_controllers_command.h:12