Maxwell Henderson | f29e318 | 2023-05-25 06:51:24 -0700 | [diff] [blame] | 1 | #ifndef FRC971_WPILIB_CAN_SENSOR_READER_H_ |
| 2 | #define FRC971_WPILIB_CAN_SENSOR_READER_H_ |
| 3 | |
| 4 | #include <vector> |
| 5 | |
| 6 | #include "aos/containers/sized_array.h" |
| 7 | #include "aos/events/event_loop.h" |
| 8 | #include "aos/events/shm_event_loop.h" |
| 9 | #include "aos/realtime.h" |
Maxwell Henderson | 10ed5c3 | 2024-01-09 12:40:54 -0800 | [diff] [blame^] | 10 | #include "frc971/wpilib/talonfx.h" |
Maxwell Henderson | f29e318 | 2023-05-25 06:51:24 -0700 | [diff] [blame] | 11 | |
| 12 | namespace frc971 { |
| 13 | namespace wpilib { |
| 14 | class CANSensorReader { |
| 15 | public: |
| 16 | CANSensorReader( |
| 17 | aos::EventLoop *event_loop, |
Maxwell Henderson | fcc0d12 | 2023-08-05 17:03:34 -0700 | [diff] [blame] | 18 | std::vector<ctre::phoenix6::BaseStatusSignal *> signals_registry, |
Maxwell Henderson | 10ed5c3 | 2024-01-09 12:40:54 -0800 | [diff] [blame^] | 19 | std::vector<std::shared_ptr<TalonFX>> talonfxs, |
Maxwell Henderson | 6c6faaf | 2023-07-26 19:44:24 -0700 | [diff] [blame] | 20 | std::function<void(ctre::phoenix::StatusCode status)> |
| 21 | flatbuffer_callback); |
Maxwell Henderson | f29e318 | 2023-05-25 06:51:24 -0700 | [diff] [blame] | 22 | |
| 23 | private: |
| 24 | void Loop(); |
| 25 | |
| 26 | aos::EventLoop *event_loop_; |
| 27 | |
Maxwell Henderson | fcc0d12 | 2023-08-05 17:03:34 -0700 | [diff] [blame] | 28 | const std::vector<ctre::phoenix6::BaseStatusSignal *> signals_; |
Maxwell Henderson | f29e318 | 2023-05-25 06:51:24 -0700 | [diff] [blame] | 29 | |
Maxwell Henderson | 10ed5c3 | 2024-01-09 12:40:54 -0800 | [diff] [blame^] | 30 | // This is a vector of talonfxs becuase we don't need to care |
| 31 | // about talonfxs individually. |
| 32 | std::vector<std::shared_ptr<TalonFX>> talonfxs_; |
Maxwell Henderson | f29e318 | 2023-05-25 06:51:24 -0700 | [diff] [blame] | 33 | |
| 34 | // Pointer to the timer handler used to modify the wakeup. |
| 35 | ::aos::TimerHandler *timer_handler_; |
Maxwell Henderson | 6c6faaf | 2023-07-26 19:44:24 -0700 | [diff] [blame] | 36 | |
| 37 | // Callback used to send the CANPosition flatbuffer |
| 38 | std::function<void(ctre::phoenix::StatusCode status)> flatbuffer_callback_; |
Maxwell Henderson | f29e318 | 2023-05-25 06:51:24 -0700 | [diff] [blame] | 39 | }; |
| 40 | } // namespace wpilib |
| 41 | } // namespace frc971 |
| 42 | #endif // FRC971_WPILIB_CAN_SENSOR_READER_H_ |