diff --git a/src/main/cpp/cowlib/SwerveModule.cpp b/src/main/cpp/cowlib/SwerveModule.cpp index 5cad1da..d277c88 100644 --- a/src/main/cpp/cowlib/SwerveModule.cpp +++ b/src/main/cpp/cowlib/SwerveModule.cpp @@ -4,14 +4,21 @@ #include "Constants.h" #include "rev/CANSparkMax.h" +#include "units/base.h" #include "cowlib/SwerveModule.h" using namespace SwerveConstants; +using namespace units::constants; using MotorType = rev::CANSparkMax::MotorType; -SwerveModule::SwerveModule(int driveMotorId, int steerMotorId, int encoderId) +SwerveModule::SwerveModule(int driveMotorId, int steerMotorId, int encoderId, + bool driveInverted) : driveMotor{driveMotorId, rev::CANSparkMax::MotorType::kBrushless}, steerMotor{steerMotorId, rev::CANSparkMax::MotorType::kBrushless}, - encoder{encoderId}, pid{SwervePID::p, SwervePID::i, SwervePID::d} {} + encoder{encoderId}, pid{SwervePID::p, SwervePID::i, SwervePID::d} { + this->pid.EnableContinuousInput(-180, 180); + + this->driveMotor.SetInverted(driveInverted); +} diff --git a/src/main/include/cowlib/SwerveModule.h b/src/main/include/cowlib/SwerveModule.h index fd348a3..8bdf28d 100644 --- a/src/main/include/cowlib/SwerveModule.h +++ b/src/main/include/cowlib/SwerveModule.h @@ -16,5 +16,6 @@ private: frc::PIDController pid; public: - SwerveModule(int driveMotorId, int steerMotorId, int encoderId); + SwerveModule(int driveMotorId, int steerMotorId, int encoderId, + bool driveInverted); };