Maxwell Henderson | f8c9689 | 2023-06-28 19:55:59 -0700 | [diff] [blame] | 1 | #ifndef FRC971_WPILIB_SWERVE_SWERVE_MODULE_H_ |
| 2 | #define FRC971_WPILIB_SWERVE_SWERVE_MODULE_H_ |
| 3 | |
| 4 | #include "frc971/wpilib/falcon.h" |
| 5 | |
| 6 | namespace frc971 { |
| 7 | namespace wpilib { |
| 8 | namespace swerve { |
| 9 | |
| 10 | struct SwerveModule { |
| 11 | SwerveModule(int rotation_id, int translation_id, std::string canbus, |
| 12 | std::vector<ctre::phoenix6::BaseStatusSignal *> *signals, |
| 13 | double stator_current_limit, double supply_current_limit) |
| 14 | : rotation(std::make_shared<Falcon>(rotation_id, canbus, signals, |
| 15 | stator_current_limit, |
| 16 | supply_current_limit)), |
| 17 | translation(std::make_shared<Falcon>(translation_id, canbus, signals, |
| 18 | stator_current_limit, |
| 19 | supply_current_limit)) {} |
| 20 | |
| 21 | void WriteModule( |
| 22 | const frc971::control_loops::drivetrain::swerve::SwerveModuleOutput |
| 23 | *module_output, |
| 24 | double max_voltage) { |
| 25 | double rotation_current = 0.0; |
| 26 | double translation_current = 0.0; |
| 27 | |
| 28 | if (module_output != nullptr) { |
| 29 | rotation_current = module_output->rotation_current(); |
| 30 | translation_current = module_output->translation_current(); |
| 31 | } |
| 32 | |
| 33 | rotation->WriteCurrent(rotation_current, max_voltage); |
| 34 | translation->WriteCurrent(translation_current, max_voltage); |
| 35 | } |
| 36 | |
| 37 | std::shared_ptr<Falcon> rotation; |
| 38 | std::shared_ptr<Falcon> translation; |
| 39 | }; |
| 40 | |
| 41 | } // namespace swerve |
| 42 | } // namespace wpilib |
| 43 | } // namespace frc971 |
| 44 | #endif // FRC971_WPILIB_SWERVE_SWERVE_MODULE_H_ |