blob: d65547a2aa623b3ee016b22a361162c6d4807c16 [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
Maxwell Henderson10ed5c32024-01-09 12:40:54 -08004#include "frc971/wpilib/talonfx.h"
Maxwell Hendersonf8c96892023-06-28 19:55:59 -07005
6namespace frc971 {
7namespace wpilib {
8namespace swerve {
9
10struct SwerveModule {
Maxwell Henderson10ed5c32024-01-09 12:40:54 -080011 SwerveModule(TalonFXParams rotation_params, TalonFXParams translation_params,
Maxwell Hendersonacf63682023-08-19 22:18:09 -070012 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 Henderson10ed5c32024-01-09 12:40:54 -080015 : rotation(std::make_shared<TalonFX>(rotation_params, canbus, signals,
16 stator_current_limit,
17 supply_current_limit)),
18 translation(std::make_shared<TalonFX>(translation_params, canbus,
19 signals, stator_current_limit,
20 supply_current_limit)) {}
Maxwell Hendersonf8c96892023-06-28 19:55:59 -070021
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
Maxwell Henderson10ed5c32024-01-09 12:40:54 -080038 std::shared_ptr<TalonFX> rotation;
39 std::shared_ptr<TalonFX> translation;
Maxwell Hendersonf8c96892023-06-28 19:55:59 -070040};
41
42} // namespace swerve
43} // namespace wpilib
44} // namespace frc971
45#endif // FRC971_WPILIB_SWERVE_SWERVE_MODULE_H_