swerve pid constants and gains

This commit is contained in:
aarav18
2021-12-06 16:38:29 -07:00
parent 7672d58439
commit c8927be4f0
3 changed files with 70 additions and 4 deletions
@@ -7,6 +7,7 @@
package frc4388.robot;
import frc4388.utility.Gains;
import frc4388.utility.LEDPatterns;
/**
@@ -46,6 +47,12 @@ public final class Constants {
public static final int RIGHT_FRONT_STEER_CAN_ENCODER_ID = 0;
public static final int LEFT_BACK_STEER_CAN_ENCODER_ID = 0;
public static final int RIGHT_BACK_STEER_CAN_ENCODER_ID = 0;
// swerve PID constants
public static final int SWERVE_SLOT_IDX = 0;
public static final int SWERVE_PID_LOOP_IDX = 1;
public static final int SWERVE_TIMEOUT_MS = 30;
public static final Gains SWERVE_GAINS = new Gains(0.0, 0.0, 0.0, 0.0, 0, 1.0);
}
public static final class LEDConstants {
public static final int LED_SPARK_ID = 0;
@@ -32,7 +32,8 @@ public class SwerveDrive extends SubsystemBase
private CANCoder m_leftFrontEncoder;
private CANCoder m_rightFrontEncoder;
private CANCoder m_leftBackEncoder;
private CANCoder m_rightBackEncoder;
private CANCoder m_rightBackEncoder;
public SwerveDrive(WPI_TalonFX leftFrontSteerMotor,WPI_TalonFX leftFrontWheelMotor,WPI_TalonFX rightFrontSteerMotor,WPI_TalonFX rightFrontWheelMotor,
WPI_TalonFX leftBackSteerMotor,WPI_TalonFX leftBackWheelMotor,WPI_TalonFX rightBackSteerMotor,WPI_TalonFX rightBackWheelMotor, CANCoder leftFrontEncoder,
CANCoder rightFrontEncoder,
@@ -89,9 +90,7 @@ public class SwerveDrive extends SubsystemBase
m_rightFrontWheelMotor.set(m_rightFrontSteerMotor.get() + rightFront.speedMetersPerSecond * SwerveDriveConstants.WHEEL_SPEED);
m_leftBackWheelMotor.set(m_leftBackSteerMotor.get() + leftBack.speedMetersPerSecond * SwerveDriveConstants.WHEEL_SPEED);
m_rightBackWheelMotor.set(m_rightBackSteerMotor.get() + rightBack.speedMetersPerSecond * SwerveDriveConstants.WHEEL_SPEED);
// PID
}
// public void driveFieldRelative(double awayFromStation, double towardLeftBoundary, double rotate)