blob: f449afaca2849d6ba3cfdd9bc87fac2b9c9a1588 [file] [log] [blame]
Maxwell Hendersonf8c96892023-06-28 19:55:59 -07001#ifndef FRC971_WPILIB_SWERVE_SWERVE_MODULE_H_
2#define FRC971_WPILIB_SWERVE_SWERVE_MODULE_H_
3
4#include "frc971/wpilib/falcon.h"
5
6namespace frc971 {
7namespace wpilib {
8namespace swerve {
9
10struct SwerveModule {
Maxwell Hendersonacf63682023-08-19 22:18:09 -070011 SwerveModule(FalconParams rotation_params, FalconParams translation_params,
12 std::string canbus,
Maxwell Hendersonf8c96892023-06-28 19:55:59 -070013 std::vector<ctre::phoenix6::BaseStatusSignal *> *signals,
14 double stator_current_limit, double supply_current_limit)
Maxwell Hendersonacf63682023-08-19 22:18:09 -070015 : rotation(std::make_shared<Falcon>(rotation_params, canbus, signals,
Maxwell Hendersonf8c96892023-06-28 19:55:59 -070016 stator_current_limit,
17 supply_current_limit)),
Maxwell Hendersonacf63682023-08-19 22:18:09 -070018 translation(std::make_shared<Falcon>(translation_params, canbus,
19 signals, stator_current_limit,
Maxwell Hendersonf8c96892023-06-28 19:55:59 -070020 supply_current_limit)) {}
21
22 void WriteModule(
23 const frc971::control_loops::drivetrain::swerve::SwerveModuleOutput
24 *module_output,
25 double max_voltage) {
26 double rotation_current = 0.0;
27 double translation_current = 0.0;
28
29 if (module_output != nullptr) {
30 rotation_current = module_output->rotation_current();
31 translation_current = module_output->translation_current();
32 }
33
34 rotation->WriteCurrent(rotation_current, max_voltage);
35 translation->WriteCurrent(translation_current, max_voltage);
36 }
37
38 std::shared_ptr<Falcon> rotation;
39 std::shared_ptr<Falcon> translation;
40};
41
42} // namespace swerve
43} // namespace wpilib
44} // namespace frc971
45#endif // FRC971_WPILIB_SWERVE_SWERVE_MODULE_H_