From a91c1a493270a2508f96e6d66a1254f0de2727c4 Mon Sep 17 00:00:00 2001 From: Zynh0722 Date: Wed, 27 Mar 2024 17:46:46 -0700 Subject: [PATCH] pid settings --- src/main/cpp/cowlib/SwerveModule.cpp | 11 +++++++++-- src/main/include/cowlib/SwerveModule.h | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) 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); };