Skip to content

Commit

Permalink
Update PurpleLib
Browse files Browse the repository at this point in the history
  • Loading branch information
viggy96 committed Dec 28, 2023
1 parent 885b895 commit dbf8079
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ dependencies {
nativeRelease wpi.java.vendor.jniRelease(wpi.platforms.desktop)
simulationRelease wpi.sim.enableRelease()

implementation 'com.github.lasarobotics:PurpleLib:2024.0.9'
implementation 'com.github.lasarobotics:PurpleLib:2024.1.0'

implementation 'org.apache.commons:commons-math3:3.+'

Expand Down
18 changes: 9 additions & 9 deletions src/main/java/frc/robot/subsystems/drive/DriveSubsystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import org.lasarobotics.drive.AdvancedSwerveKinematics.ControlCentricity;
import org.lasarobotics.drive.MAXSwerveModule;
import org.lasarobotics.drive.ThrottleMap;
import org.lasarobotics.drive.TurnPIDController;
import org.lasarobotics.drive.RotatePIDController;
import org.lasarobotics.hardware.kauailabs.NavX2;
import org.lasarobotics.led.LEDStrip;
import org.lasarobotics.led.LEDStrip.Pattern;
Expand Down Expand Up @@ -83,7 +83,7 @@ public Hardware(NavX2 navx,


private ThrottleMap m_throttleMap;
private TurnPIDController m_turnPIDController;
private RotatePIDController m_rotatePIDController;
private ProfiledPIDController m_autoAimPIDController;
private SwerveDriveKinematics m_kinematics;
private SwerveDrivePoseEstimator m_poseEstimator;
Expand Down Expand Up @@ -157,7 +157,7 @@ public DriveSubsystem(Hardware drivetrainHardware, PIDConstants pidf, ControlCen
this.m_ledStrip = drivetrainHardware.ledStrip;
this.m_controlCentricity = controlCentricity;
this.m_throttleMap = new ThrottleMap(throttleInputCurve, deadband, DRIVE_MAX_LINEAR_SPEED);
this.m_turnPIDController = new TurnPIDController(turnInputCurve, pidf, turnScalar, deadband, lookAhead);
this.m_rotatePIDController = new RotatePIDController(turnInputCurve, pidf, turnScalar, deadband, lookAhead);
this.m_pathFollowerConfig = new HolonomicPathFollowerConfig(
new com.pathplanner.lib.util.PIDConstants(5.0, 0.0, -0.5),
new com.pathplanner.lib.util.PIDConstants(5.0, 0.0, -0.1),
Expand All @@ -172,8 +172,8 @@ public DriveSubsystem(Hardware drivetrainHardware, PIDConstants pidf, ControlCen
m_navx.reset();

// Setup turn PID
m_turnPIDController.setTolerance(TOLERANCE);
m_turnPIDController.setSetpoint(getAngle());
m_rotatePIDController.setTolerance(TOLERANCE);
m_rotatePIDController.setSetpoint(getAngle());

// Define drivetrain kinematics
m_kinematics = new SwerveDriveKinematics(m_lFrontModule.getModuleCoordinate(),
Expand Down Expand Up @@ -501,7 +501,7 @@ public void teleopPID(double xRequest, double yRequest, double rotateRequest) {
double moveDirection = Math.atan2(yRequest, xRequest);

double velocityOutput = m_throttleMap.throttleLookup(moveRequest);
double rotateOutput = m_turnPIDController.calculate(getAngle(), getRotateRate(), rotateRequest);
double rotateOutput = m_rotatePIDController.calculate(getAngle(), getRotateRate(), rotateRequest);

m_autoAimPIDController.calculate(getPose().getRotation().getDegrees(), getPose().getRotation().getDegrees());

Expand Down Expand Up @@ -533,7 +533,7 @@ public void autoDrive(ChassisSpeeds speeds) {
setSwerveModules(moduleStates);

// Update turn PID
m_turnPIDController.calculate(getAngle(), getRotateRate(), 0.0);
m_rotatePIDController.calculate(getAngle(), getRotateRate(), 0.0);
}

/**
Expand Down Expand Up @@ -629,8 +629,8 @@ public Command goToPose(PurplePathPose goal) {
* Reset DriveSubsystem turn PID
*/
public void resetTurnPID() {
m_turnPIDController.setSetpoint(getAngle());
m_turnPIDController.reset();
m_rotatePIDController.setSetpoint(getAngle());
m_rotatePIDController.reset();
}

/**
Expand Down

0 comments on commit dbf8079

Please sign in to comment.