Sabina Davis | adc5854 | 2019-02-01 22:23:00 -0800 | [diff] [blame] | 1 | #ifndef FRC971_WPILIB_SENSOR_READER_H_ |
| 2 | #define FRC971_WPILIB_SENSOR_READER_H_ |
| 3 | |
| 4 | #include <atomic> |
| 5 | #include <chrono> |
| 6 | |
Alex Perry | cb7da4b | 2019-08-28 19:35:56 -0700 | [diff] [blame] | 7 | #include "aos/events/event_loop.h" |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 8 | #include "aos/events/shm_event_loop.h" |
Sabina Davis | adc5854 | 2019-02-01 22:23:00 -0800 | [diff] [blame] | 9 | #include "aos/stl_mutex/stl_mutex.h" |
| 10 | #include "aos/time/time.h" |
Maxwell Henderson | cb78f35 | 2024-01-15 00:27:16 -0800 | [diff] [blame] | 11 | #include "frc971/control_loops/control_loops_static.h" |
Maxwell Henderson | f382b4b | 2024-01-14 12:31:41 -0800 | [diff] [blame] | 12 | #include "frc971/control_loops/drivetrain/drivetrain_position_static.h" |
James Kuszmaul | 7077d34 | 2021-06-09 20:23:58 -0700 | [diff] [blame] | 13 | #include "frc971/input/robot_state_generated.h" |
Sabina Davis | adc5854 | 2019-02-01 22:23:00 -0800 | [diff] [blame] | 14 | #include "frc971/wpilib/ahal/DigitalGlitchFilter.h" |
| 15 | #include "frc971/wpilib/ahal/DigitalInput.h" |
Austin Schuh | 3b010bc | 2019-02-24 17:25:37 -0800 | [diff] [blame] | 16 | #include "frc971/wpilib/ahal/DriverStation.h" |
Sabina Davis | 1ffa417 | 2019-02-01 22:38:33 -0800 | [diff] [blame] | 17 | #include "frc971/wpilib/dma.h" |
| 18 | #include "frc971/wpilib/dma_edge_counting.h" |
Austin Schuh | 54667ac | 2019-02-02 16:44:49 -0800 | [diff] [blame] | 19 | #include "frc971/wpilib/encoder_and_potentiometer.h" |
Sabina Davis | adc5854 | 2019-02-01 22:23:00 -0800 | [diff] [blame] | 20 | |
| 21 | using ::aos::monotonic_clock; |
| 22 | namespace chrono = ::std::chrono; |
| 23 | |
Stephan Pleines | d99b1ee | 2024-02-02 20:56:44 -0800 | [diff] [blame^] | 24 | namespace frc971::wpilib { |
Sabina Davis | adc5854 | 2019-02-01 22:23:00 -0800 | [diff] [blame] | 25 | |
| 26 | class SensorReader { |
| 27 | public: |
Austin Schuh | 217a978 | 2019-12-21 23:02:50 -0800 | [diff] [blame] | 28 | SensorReader(::aos::ShmEventLoop *event_loop); |
Austin Schuh | 2c2cc2e | 2019-02-02 20:19:45 -0800 | [diff] [blame] | 29 | virtual ~SensorReader() {} |
Sabina Davis | adc5854 | 2019-02-01 22:23:00 -0800 | [diff] [blame] | 30 | |
Austin Schuh | 45a549f | 2019-02-02 15:43:56 -0800 | [diff] [blame] | 31 | // Updates the fast and medium encoder filter frequencies. |
| 32 | void UpdateFastEncoderFilterHz(int hz); |
| 33 | void UpdateMediumEncoderFilterHz(int hz); |
| 34 | |
Sabina Davis | b6317b7 | 2019-02-01 22:53:23 -0800 | [diff] [blame] | 35 | // Sets the left drivetrain encoder. |
| 36 | void set_drivetrain_left_encoder(::std::unique_ptr<frc::Encoder> encoder); |
| 37 | |
| 38 | // Sets the right drivetrain encoder. |
| 39 | void set_drivetrain_right_encoder(::std::unique_ptr<frc::Encoder> encoder); |
| 40 | |
Sabina Davis | 6292bec | 2019-02-06 22:53:14 -0800 | [diff] [blame] | 41 | // Adds a sensor to DMA. |
Austin Schuh | 2c2cc2e | 2019-02-02 20:19:45 -0800 | [diff] [blame] | 42 | void AddToDMA(DMASampleHandlerInterface *handler) { |
Sabina Davis | 6292bec | 2019-02-06 22:53:14 -0800 | [diff] [blame] | 43 | if (!dma_synchronizer_) { |
| 44 | dma_synchronizer_.reset( |
| 45 | new ::frc971::wpilib::DMASynchronizer(std::make_unique<DMA>())); |
| 46 | } |
Austin Schuh | 2c2cc2e | 2019-02-02 20:19:45 -0800 | [diff] [blame] | 47 | dma_synchronizer_->Add(handler); |
| 48 | } |
| 49 | |
Austin Schuh | 3b010bc | 2019-02-24 17:25:37 -0800 | [diff] [blame] | 50 | // Sets PWM trigger mode. If true, synchronize the control loops with the PWM |
| 51 | // pulses. The sensors are sampled 50 uS after the falling edge of the PWM |
| 52 | // pulse. |
| 53 | void set_pwm_trigger(bool trigger) { pwm_trigger_ = trigger; } |
Sabina Davis | adc5854 | 2019-02-01 22:23:00 -0800 | [diff] [blame] | 54 | |
Sabina Davis | a42cc35 | 2019-02-01 22:55:50 -0800 | [diff] [blame] | 55 | // Stops the pwm trigger on the next iteration. |
| 56 | void Quit() { run_ = false; } |
| 57 | |
Sabina Davis | 399dbd8 | 2019-02-01 23:06:08 -0800 | [diff] [blame] | 58 | virtual void RunIteration() = 0; |
Sabina Davis | 6292bec | 2019-02-06 22:53:14 -0800 | [diff] [blame] | 59 | // Runs the DMA iteration after the synchronizer. This only gets run if a |
| 60 | // sensor has been added to DMA. |
Austin Schuh | 2c2cc2e | 2019-02-02 20:19:45 -0800 | [diff] [blame] | 61 | virtual void RunDmaIteration() {} |
Sabina Davis | 399dbd8 | 2019-02-01 23:06:08 -0800 | [diff] [blame] | 62 | |
Sabina Davis | adc5854 | 2019-02-01 22:23:00 -0800 | [diff] [blame] | 63 | protected: |
Austin Schuh | 54667ac | 2019-02-02 16:44:49 -0800 | [diff] [blame] | 64 | // Copies a DMAEncoder to a IndexPosition with the correct unit and direction |
| 65 | // changes. |
| 66 | void CopyPosition(const ::frc971::wpilib::DMAEncoder &encoder, |
Maxwell Henderson | cb78f35 | 2024-01-15 00:27:16 -0800 | [diff] [blame] | 67 | ::frc971::IndexPositionStatic *position, |
Austin Schuh | 54667ac | 2019-02-02 16:44:49 -0800 | [diff] [blame] | 68 | double encoder_counts_per_revolution, double encoder_ratio, |
| 69 | bool reverse) { |
| 70 | const double multiplier = reverse ? -1.0 : 1.0; |
Maxwell Henderson | cb78f35 | 2024-01-15 00:27:16 -0800 | [diff] [blame] | 71 | position->set_encoder(multiplier * |
| 72 | encoder_translate(encoder.polled_encoder_value(), |
| 73 | encoder_counts_per_revolution, |
| 74 | encoder_ratio)); |
| 75 | position->set_latched_encoder( |
Austin Schuh | 54667ac | 2019-02-02 16:44:49 -0800 | [diff] [blame] | 76 | multiplier * encoder_translate(encoder.last_encoder_value(), |
| 77 | encoder_counts_per_revolution, |
Maxwell Henderson | cb78f35 | 2024-01-15 00:27:16 -0800 | [diff] [blame] | 78 | encoder_ratio)); |
| 79 | position->set_index_pulses(encoder.index_posedge_count()); |
Austin Schuh | 54667ac | 2019-02-02 16:44:49 -0800 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | // Copies a AbsoluteEncoderAndPotentiometer to a PotAndAbsolutePosition with |
| 83 | // the correct unit and direction changes. |
| 84 | void CopyPosition( |
| 85 | const ::frc971::wpilib::AbsoluteEncoderAndPotentiometer &encoder, |
Maxwell Henderson | cb78f35 | 2024-01-15 00:27:16 -0800 | [diff] [blame] | 86 | ::frc971::PotAndAbsolutePositionStatic *position, |
Austin Schuh | 54667ac | 2019-02-02 16:44:49 -0800 | [diff] [blame] | 87 | double encoder_counts_per_revolution, double encoder_ratio, |
| 88 | ::std::function<double(double)> potentiometer_translate, bool reverse, |
| 89 | double pot_offset) { |
| 90 | const double multiplier = reverse ? -1.0 : 1.0; |
Maxwell Henderson | cb78f35 | 2024-01-15 00:27:16 -0800 | [diff] [blame] | 91 | position->set_pot(multiplier * potentiometer_translate( |
| 92 | encoder.ReadPotentiometerVoltage()) + |
| 93 | pot_offset); |
| 94 | position->set_encoder(multiplier * |
| 95 | encoder_translate(encoder.ReadRelativeEncoder(), |
| 96 | encoder_counts_per_revolution, |
| 97 | encoder_ratio)); |
Austin Schuh | 54667ac | 2019-02-02 16:44:49 -0800 | [diff] [blame] | 98 | |
Maxwell Henderson | cb78f35 | 2024-01-15 00:27:16 -0800 | [diff] [blame] | 99 | position->set_absolute_encoder((reverse |
| 100 | ? (1.0 - encoder.ReadAbsoluteEncoder()) |
| 101 | : encoder.ReadAbsoluteEncoder()) * |
| 102 | encoder_ratio * (2.0 * M_PI)); |
Austin Schuh | 54667ac | 2019-02-02 16:44:49 -0800 | [diff] [blame] | 103 | } |
| 104 | |
Ravago Jones | 937587c | 2020-12-26 17:21:09 -0800 | [diff] [blame] | 105 | // Copies an AbsoluteEncoderAndPotentiometer to an AbsoluteAndAbsolutePosition |
| 106 | // with the correct unit and direction changes. |
| 107 | void CopyPosition(const ::frc971::wpilib::AbsoluteAndAbsoluteEncoder &encoder, |
Maxwell Henderson | cb78f35 | 2024-01-15 00:27:16 -0800 | [diff] [blame] | 108 | ::frc971::AbsoluteAndAbsolutePositionStatic *position, |
Ravago Jones | 937587c | 2020-12-26 17:21:09 -0800 | [diff] [blame] | 109 | double encoder_counts_per_revolution, double encoder_ratio, |
| 110 | double single_turn_encoder_ratio, bool reverse) { |
| 111 | const double multiplier = reverse ? -1.0 : 1.0; |
Maxwell Henderson | cb78f35 | 2024-01-15 00:27:16 -0800 | [diff] [blame] | 112 | position->set_encoder(multiplier * |
| 113 | encoder_translate(encoder.ReadRelativeEncoder(), |
| 114 | encoder_counts_per_revolution, |
| 115 | encoder_ratio)); |
Ravago Jones | 937587c | 2020-12-26 17:21:09 -0800 | [diff] [blame] | 116 | |
Maxwell Henderson | cb78f35 | 2024-01-15 00:27:16 -0800 | [diff] [blame] | 117 | position->set_absolute_encoder((reverse |
| 118 | ? (1.0 - encoder.ReadAbsoluteEncoder()) |
| 119 | : encoder.ReadAbsoluteEncoder()) * |
| 120 | encoder_ratio * (2.0 * M_PI)); |
Ravago Jones | 937587c | 2020-12-26 17:21:09 -0800 | [diff] [blame] | 121 | |
Maxwell Henderson | cb78f35 | 2024-01-15 00:27:16 -0800 | [diff] [blame] | 122 | position->set_single_turn_absolute_encoder( |
Ravago Jones | 937587c | 2020-12-26 17:21:09 -0800 | [diff] [blame] | 123 | (reverse ? (1.0 - encoder.ReadSingleTurnAbsoluteEncoder()) |
| 124 | : encoder.ReadSingleTurnAbsoluteEncoder()) * |
Maxwell Henderson | cb78f35 | 2024-01-15 00:27:16 -0800 | [diff] [blame] | 125 | single_turn_encoder_ratio * (2.0 * M_PI)); |
Ravago Jones | 937587c | 2020-12-26 17:21:09 -0800 | [diff] [blame] | 126 | } |
| 127 | |
Austin Schuh | 54667ac | 2019-02-02 16:44:49 -0800 | [diff] [blame] | 128 | // Copies a DMAEdgeCounter to a HallEffectAndPosition with the correct unit |
| 129 | // and direction changes. |
| 130 | void CopyPosition(const ::frc971::wpilib::DMAEdgeCounter &counter, |
Maxwell Henderson | cb78f35 | 2024-01-15 00:27:16 -0800 | [diff] [blame] | 131 | ::frc971::HallEffectAndPositionStatic *position, |
Austin Schuh | 54667ac | 2019-02-02 16:44:49 -0800 | [diff] [blame] | 132 | double encoder_counts_per_revolution, double encoder_ratio, |
| 133 | bool reverse) { |
| 134 | const double multiplier = reverse ? -1.0 : 1.0; |
Maxwell Henderson | cb78f35 | 2024-01-15 00:27:16 -0800 | [diff] [blame] | 135 | position->set_encoder(multiplier * |
| 136 | encoder_translate(counter.polled_encoder(), |
| 137 | encoder_counts_per_revolution, |
| 138 | encoder_ratio)); |
| 139 | position->set_current(!counter.polled_value()); |
| 140 | position->set_posedge_count(counter.negative_count()); |
| 141 | position->set_negedge_count(counter.positive_count()); |
| 142 | position->set_posedge_value( |
Austin Schuh | 54667ac | 2019-02-02 16:44:49 -0800 | [diff] [blame] | 143 | multiplier * encoder_translate(counter.last_negative_encoder_value(), |
| 144 | encoder_counts_per_revolution, |
Maxwell Henderson | cb78f35 | 2024-01-15 00:27:16 -0800 | [diff] [blame] | 145 | encoder_ratio)); |
| 146 | position->set_negedge_value( |
Austin Schuh | 54667ac | 2019-02-02 16:44:49 -0800 | [diff] [blame] | 147 | multiplier * encoder_translate(counter.last_positive_encoder_value(), |
| 148 | encoder_counts_per_revolution, |
Maxwell Henderson | cb78f35 | 2024-01-15 00:27:16 -0800 | [diff] [blame] | 149 | encoder_ratio)); |
Austin Schuh | 54667ac | 2019-02-02 16:44:49 -0800 | [diff] [blame] | 150 | } |
| 151 | |
Sabina Davis | 8d8ac0a | 2019-02-06 23:51:07 -0800 | [diff] [blame] | 152 | // Copies a Absolute Encoder with the correct unit |
| 153 | // and direction changes. |
Ravago Jones | 937587c | 2020-12-26 17:21:09 -0800 | [diff] [blame] | 154 | void CopyPosition(const ::frc971::wpilib::AbsoluteEncoder &encoder, |
Maxwell Henderson | cb78f35 | 2024-01-15 00:27:16 -0800 | [diff] [blame] | 155 | ::frc971::AbsolutePositionStatic *position, |
Ravago Jones | 937587c | 2020-12-26 17:21:09 -0800 | [diff] [blame] | 156 | double encoder_counts_per_revolution, double encoder_ratio, |
| 157 | bool reverse) { |
Sabina Davis | 8d8ac0a | 2019-02-06 23:51:07 -0800 | [diff] [blame] | 158 | const double multiplier = reverse ? -1.0 : 1.0; |
Maxwell Henderson | cb78f35 | 2024-01-15 00:27:16 -0800 | [diff] [blame] | 159 | position->set_encoder(multiplier * |
| 160 | encoder_translate(encoder.ReadRelativeEncoder(), |
| 161 | encoder_counts_per_revolution, |
| 162 | encoder_ratio)); |
Sabina Davis | 8d8ac0a | 2019-02-06 23:51:07 -0800 | [diff] [blame] | 163 | |
Maxwell Henderson | cb78f35 | 2024-01-15 00:27:16 -0800 | [diff] [blame] | 164 | position->set_absolute_encoder((reverse |
| 165 | ? (1.0 - encoder.ReadAbsoluteEncoder()) |
| 166 | : encoder.ReadAbsoluteEncoder()) * |
| 167 | encoder_ratio * (2.0 * M_PI)); |
Sabina Davis | 8d8ac0a | 2019-02-06 23:51:07 -0800 | [diff] [blame] | 168 | } |
| 169 | |
Ravago Jones | 937587c | 2020-12-26 17:21:09 -0800 | [diff] [blame] | 170 | void CopyPosition(const ::frc971::wpilib::DMAEncoderAndPotentiometer &encoder, |
Maxwell Henderson | cb78f35 | 2024-01-15 00:27:16 -0800 | [diff] [blame] | 171 | ::frc971::PotAndIndexPositionStatic *position, |
Ravago Jones | 937587c | 2020-12-26 17:21:09 -0800 | [diff] [blame] | 172 | ::std::function<double(int32_t)> encoder_translate, |
| 173 | ::std::function<double(double)> potentiometer_translate, |
| 174 | bool reverse, double pot_offset) { |
Sabina Davis | 2243cab | 2019-02-05 21:45:08 -0800 | [diff] [blame] | 175 | const double multiplier = reverse ? -1.0 : 1.0; |
Maxwell Henderson | cb78f35 | 2024-01-15 00:27:16 -0800 | [diff] [blame] | 176 | position->set_encoder(multiplier * |
| 177 | encoder_translate(encoder.polled_encoder_value())); |
| 178 | position->set_pot(multiplier * potentiometer_translate( |
| 179 | encoder.polled_potentiometer_voltage()) + |
| 180 | pot_offset); |
| 181 | position->set_latched_encoder( |
| 182 | multiplier * encoder_translate(encoder.last_encoder_value())); |
| 183 | position->set_latched_pot( |
Sabina Davis | 2243cab | 2019-02-05 21:45:08 -0800 | [diff] [blame] | 184 | multiplier * |
| 185 | potentiometer_translate(encoder.last_potentiometer_voltage()) + |
Maxwell Henderson | cb78f35 | 2024-01-15 00:27:16 -0800 | [diff] [blame] | 186 | pot_offset); |
| 187 | position->set_index_pulses(encoder.index_posedge_count()); |
Sabina Davis | 2243cab | 2019-02-05 21:45:08 -0800 | [diff] [blame] | 188 | } |
| 189 | |
Siddhant Kanwar | 0e37f59 | 2022-02-21 19:26:50 -0800 | [diff] [blame] | 190 | // Copies a relative digital encoder. |
Alex Perry | 2712c10 | 2020-02-17 19:17:11 -0800 | [diff] [blame] | 191 | void CopyPosition(const ::frc::Encoder &encoder, |
Maxwell Henderson | cb78f35 | 2024-01-15 00:27:16 -0800 | [diff] [blame] | 192 | ::frc971::RelativePositionStatic *position, |
Alex Perry | 2712c10 | 2020-02-17 19:17:11 -0800 | [diff] [blame] | 193 | double encoder_counts_per_revolution, double encoder_ratio, |
| 194 | bool reverse) { |
| 195 | const double multiplier = reverse ? -1.0 : 1.0; |
Maxwell Henderson | cb78f35 | 2024-01-15 00:27:16 -0800 | [diff] [blame] | 196 | position->set_encoder(multiplier * |
| 197 | encoder_translate(encoder.GetRaw(), |
| 198 | encoder_counts_per_revolution, |
| 199 | encoder_ratio)); |
Alex Perry | 2712c10 | 2020-02-17 19:17:11 -0800 | [diff] [blame] | 200 | } |
| 201 | |
Siddhant Kanwar | 0e37f59 | 2022-02-21 19:26:50 -0800 | [diff] [blame] | 202 | // Copies a potentiometer |
| 203 | void CopyPosition(const ::frc::AnalogInput &input, |
Maxwell Henderson | cb78f35 | 2024-01-15 00:27:16 -0800 | [diff] [blame] | 204 | ::frc971::RelativePositionStatic *position, |
Siddhant Kanwar | 0e37f59 | 2022-02-21 19:26:50 -0800 | [diff] [blame] | 205 | ::std::function<double(double)> potentiometer_translate, |
| 206 | bool reverse, double pot_offset) { |
| 207 | const double multiplier = reverse ? -1.0 : 1.0; |
Maxwell Henderson | cb78f35 | 2024-01-15 00:27:16 -0800 | [diff] [blame] | 208 | position->set_encoder( |
| 209 | multiplier * potentiometer_translate(input.GetVoltage()) + pot_offset); |
Siddhant Kanwar | 0e37f59 | 2022-02-21 19:26:50 -0800 | [diff] [blame] | 210 | } |
| 211 | |
Austin Schuh | 54667ac | 2019-02-02 16:44:49 -0800 | [diff] [blame] | 212 | double encoder_translate(int32_t value, double counts_per_revolution, |
| 213 | double ratio) { |
| 214 | return static_cast<double>(value) / counts_per_revolution * ratio * |
| 215 | (2.0 * M_PI); |
| 216 | } |
| 217 | |
Maxwell Henderson | d5ae85b | 2024-01-08 16:14:28 -0800 | [diff] [blame] | 218 | void SendDrivetrainPosition( |
Maxwell Henderson | f382b4b | 2024-01-14 12:31:41 -0800 | [diff] [blame] | 219 | aos::Sender<control_loops::drivetrain::PositionStatic>::StaticBuilder |
| 220 | builder, |
Maxwell Henderson | d5ae85b | 2024-01-08 16:14:28 -0800 | [diff] [blame] | 221 | std::function<double(double input)> velocity_translate, |
| 222 | std::function<double(double input)> encoder_to_meters, bool left_inverted, |
| 223 | bool right_inverted); |
| 224 | |
Austin Schuh | df6cbb1 | 2019-02-02 13:46:52 -0800 | [diff] [blame] | 225 | ::aos::EventLoop *event_loop_; |
| 226 | ::aos::Sender<::aos::RobotState> robot_state_sender_; |
| 227 | |
Austin Schuh | 45a549f | 2019-02-02 15:43:56 -0800 | [diff] [blame] | 228 | frc::DigitalGlitchFilter fast_encoder_filter_, medium_encoder_filter_; |
| 229 | |
| 230 | ::std::unique_ptr<frc::Encoder> drivetrain_left_encoder_, |
| 231 | drivetrain_right_encoder_; |
| 232 | |
| 233 | private: |
Austin Schuh | 2c2cc2e | 2019-02-02 20:19:45 -0800 | [diff] [blame] | 234 | // Gets called right before the DMA synchronizer is up and running. |
| 235 | virtual void Start() {} |
| 236 | |
Austin Schuh | bd1fe9c | 2019-06-29 16:35:48 -0700 | [diff] [blame] | 237 | // Sets up everything during startup. |
| 238 | void DoStart(); |
| 239 | |
| 240 | // Runs a single iteration. |
milind-u | 61227f2 | 2021-08-29 15:58:33 -0700 | [diff] [blame] | 241 | void Loop(); |
Austin Schuh | bd1fe9c | 2019-06-29 16:35:48 -0700 | [diff] [blame] | 242 | |
Austin Schuh | 3b010bc | 2019-02-24 17:25:37 -0800 | [diff] [blame] | 243 | // Returns the monotonic time of the start of the first PWM cycle. |
| 244 | // Returns min_time if no start time could be calculated. |
| 245 | monotonic_clock::time_point GetPWMStartTime(); |
Sabina Davis | adc5854 | 2019-02-01 22:23:00 -0800 | [diff] [blame] | 246 | |
Austin Schuh | bd1fe9c | 2019-06-29 16:35:48 -0700 | [diff] [blame] | 247 | bool pwm_trigger_ = false; |
Sabina Davis | adc5854 | 2019-02-01 22:23:00 -0800 | [diff] [blame] | 248 | |
Sabina Davis | 1ffa417 | 2019-02-01 22:38:33 -0800 | [diff] [blame] | 249 | ::std::unique_ptr<::frc971::wpilib::DMASynchronizer> dma_synchronizer_; |
| 250 | |
Sabina Davis | adc5854 | 2019-02-01 22:23:00 -0800 | [diff] [blame] | 251 | ::std::atomic<bool> run_{true}; |
Austin Schuh | 3b010bc | 2019-02-24 17:25:37 -0800 | [diff] [blame] | 252 | ::frc::DriverStation *ds_; |
Austin Schuh | bd1fe9c | 2019-06-29 16:35:48 -0700 | [diff] [blame] | 253 | |
| 254 | const int32_t my_pid_; |
| 255 | |
milind-u | 61227f2 | 2021-08-29 15:58:33 -0700 | [diff] [blame] | 256 | // Pointer to the timer handler used to modify the wakeup. |
| 257 | ::aos::TimerHandler *timer_handler_; |
Austin Schuh | bd1fe9c | 2019-06-29 16:35:48 -0700 | [diff] [blame] | 258 | |
| 259 | // Last time we got called. |
| 260 | ::aos::monotonic_clock::time_point last_monotonic_now_ = |
| 261 | ::aos::monotonic_clock::min_time; |
| 262 | // The current period. |
| 263 | chrono::microseconds period_ = chrono::microseconds(5000); |
Sabina Davis | adc5854 | 2019-02-01 22:23:00 -0800 | [diff] [blame] | 264 | }; |
| 265 | |
Stephan Pleines | d99b1ee | 2024-02-02 20:56:44 -0800 | [diff] [blame^] | 266 | } // namespace frc971::wpilib |
Sabina Davis | adc5854 | 2019-02-01 22:23:00 -0800 | [diff] [blame] | 267 | |
| 268 | #endif // FRC971_WPILIB_SENSOR_READER_H_ |