Skip to content

Commit

Permalink
ministry of truth
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew-K961 committed Mar 13, 2024
1 parent ed626fe commit 012fcac
Show file tree
Hide file tree
Showing 38 changed files with 756 additions and 523 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ spotless {
include '**/*.java'
exclude '**/build/**', '**/build-*/**'
}
toggleOffOn()
palantirJavaFormat().style("AOSP")
removeUnusedImports()
trimTrailingWhitespace()
toggleOffOn()
}

groovyGradle {
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/frc/lib/math/Conversions.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package frc.lib.math;

public class Conversions {

/**
* @param wheelRPS Wheel Velocity: (in Rotations per Second)
* @param circumference Wheel Circumference: (in Meters)
* @return Wheel Velocity: (in Meters per Second)
*/
public static double RPSToMPS(double wheelRPS, double circumference){
public static double RPSToMPS(double wheelRPS, double circumference) {
double wheelMPS = wheelRPS * circumference;
return wheelMPS;
}
Expand All @@ -17,7 +17,7 @@ public static double RPSToMPS(double wheelRPS, double circumference){
* @param circumference Wheel Circumference: (in Meters)
* @return Wheel Velocity: (in Rotations per Second)
*/
public static double MPSToRPS(double wheelMPS, double circumference){
public static double MPSToRPS(double wheelMPS, double circumference) {
double wheelRPS = wheelMPS / circumference;
return wheelRPS;
}
Expand All @@ -27,7 +27,7 @@ public static double MPSToRPS(double wheelMPS, double circumference){
* @param circumference Wheel Circumference: (in Meters)
* @return Wheel Distance: (in Meters)
*/
public static double rotationsToMeters(double wheelRotations, double circumference){
public static double rotationsToMeters(double wheelRotations, double circumference) {
double wheelMeters = wheelRotations * circumference;
return wheelMeters;
}
Expand All @@ -37,8 +37,8 @@ public static double rotationsToMeters(double wheelRotations, double circumferen
* @param circumference Wheel Circumference: (in Meters)
* @return Wheel Position: (in Rotations)
*/
public static double metersToRotations(double wheelMeters, double circumference){
public static double metersToRotations(double wheelMeters, double circumference) {
double wheelRotations = wheelMeters / circumference;
return wheelRotations;
}
}
}
4 changes: 2 additions & 2 deletions src/main/java/frc/lib/math/FiringSolutions.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package frc.lib.math;
// format:off
// spotless:off
public final class FiringSolutions {
private static final double shooterHeight = 0.355;
private static final double noteFallAccel = 9.8;
Expand Down Expand Up @@ -86,5 +86,5 @@ public static double getShooterAngle(double shooterVelocityX, double shooterVelo
public static double getRobotOffsetAngle(double robotVelocityPerpendicularToSpeaker, double shooterVelocityX){
return Math.atan(robotVelocityPerpendicularToSpeaker / shooterVelocityX);
}

// spotless:on
}
4 changes: 2 additions & 2 deletions src/main/java/frc/lib/math/FiringSolutionsV2.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package frc.lib.math;
// format:off
// spotless:off
public class FiringSolutionsV2 {

private static final double shooterHeight = 0.355;
Expand Down Expand Up @@ -141,5 +141,5 @@ public static double getR() {
public static double getShooterAngle() {
return Math.acos(R);
}

// spotless:on
}
4 changes: 2 additions & 2 deletions src/main/java/frc/lib/math/FiringSolutionsV3.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package frc.lib.math;
// format:off
// spotless:off
import java.util.Optional;

import edu.wpi.first.math.geometry.Translation2d;
Expand Down Expand Up @@ -346,5 +346,5 @@ public static double getDistanceToMovingTarget(double robotX, double robotY, dou
public static double convertToRPM(double velocity) {
return (60 * velocity) / (slipPercent * Math.PI * .1016);
}

// spotless:on
}
34 changes: 17 additions & 17 deletions src/main/java/frc/lib/math/Interpolations.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,26 @@
public class Interpolations {

public InterpolatingDoubleTreeMap shooterSpeeds = new InterpolatingDoubleTreeMap();
public InterpolatingDoubleTreeMap bozoDefenseBotDriversHonestReactionWhenElevatorGoUp_speeds = new InterpolatingDoubleTreeMap();
public InterpolatingDoubleTreeMap bozoDefenseBotDriversHonestReactionWhenElevatorGoUp_speeds =
new InterpolatingDoubleTreeMap();

private double offset = 1;

public Interpolations() {
/*
shooterSpeeds.put(1.25, 53.0);
shooterSpeeds.put(1.5, 48.0);
shooterSpeeds.put(1.75, 44.0);
shooterSpeeds.put(2.0, 41.0);
shooterSpeeds.put(2.25, 39.0);
shooterSpeeds.put(2.5, 37.5);
shooterSpeeds.put(2.75, 35.5);
shooterSpeeds.put(3.0, 34.0);
shooterSpeeds.put(3.25, 33.0);
shooterSpeeds.put(3.5, 32.0);
shooterSpeeds.put(4.0, 30.75);
shooterSpeeds.put(4.5, 29.75);
*/
/*
shooterSpeeds.put(1.25, 53.0);
shooterSpeeds.put(1.5, 48.0);
shooterSpeeds.put(1.75, 44.0);
shooterSpeeds.put(2.0, 41.0);
shooterSpeeds.put(2.25, 39.0);
shooterSpeeds.put(2.5, 37.5);
shooterSpeeds.put(2.75, 35.5);
shooterSpeeds.put(3.0, 34.0);
shooterSpeeds.put(3.25, 33.0);
shooterSpeeds.put(3.5, 32.0);
shooterSpeeds.put(4.0, 30.75);
shooterSpeeds.put(4.5, 29.75);
*/
bozoDefenseBotDriversHonestReactionWhenElevatorGoUp_speeds.put(1.25, 44.0);
bozoDefenseBotDriversHonestReactionWhenElevatorGoUp_speeds.put(1.5, 39.5);
bozoDefenseBotDriversHonestReactionWhenElevatorGoUp_speeds.put(1.75, 36.0);
Expand All @@ -52,7 +53,6 @@ public Interpolations() {
shooterSpeeds.put(3.25, 31.0 + offset);
shooterSpeeds.put(3.5, 30.0 + offset);
shooterSpeeds.put(4.0, 28.25 + offset);

}

public double getShooterAngleFromInterpolation(double distanceToTarget) {
Expand All @@ -62,4 +62,4 @@ public double getShooterAngleFromInterpolation(double distanceToTarget) {
public double getShooterAngleFromInterpolationElevatorUp(double distanceToTarget) {
return bozoDefenseBotDriversHonestReactionWhenElevatorGoUp_speeds.get(distanceToTarget);
}
}
}
5 changes: 2 additions & 3 deletions src/main/java/frc/lib/util/COTSTalonFXSwerveConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.ctre.phoenix6.signals.SensorDirectionValue;

import edu.wpi.first.math.util.Units;

// spotless:off
/* Contains values and required settings for common COTS swerve modules. */
public class COTSTalonFXSwerveConstants {
public final double wheelDiameter;
Expand Down Expand Up @@ -307,5 +307,4 @@ public static final class driveRatios{
}
}
}


// spotless:on
3 changes: 2 additions & 1 deletion src/main/java/frc/lib/util/SwerveModuleConstants.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package frc.lib.util;

import edu.wpi.first.math.geometry.Rotation2d;

// spotless:off
public class SwerveModuleConstants {
public final int driveMotorID;
public final int angleMotorID;
Expand All @@ -22,3 +22,4 @@ public SwerveModuleConstants(int driveMotorID, int angleMotorID, int canCoderID,
this.angleOffset = angleOffset;
}
}
// spotless:on
33 changes: 21 additions & 12 deletions src/main/java/frc/robot/CTREConfigs.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public final class CTREConfigs {
public TalonFXConfiguration swerveDriveFXConfig = new TalonFXConfiguration();
public CANcoderConfiguration swerveCANcoderConfig = new CANcoderConfiguration();

public CTREConfigs(){
public CTREConfigs() {
/** Swerve CANCoder Configuration */
swerveCANcoderConfig.MagnetSensor.SensorDirection = Constants.Swerve.cancoderInvert;

Expand All @@ -20,12 +20,15 @@ public CTREConfigs(){
/* Gear Ratio and Wrapping Config */
swerveAngleFXConfig.Feedback.SensorToMechanismRatio = Constants.Swerve.angleGearRatio;
swerveAngleFXConfig.ClosedLoopGeneral.ContinuousWrap = true;

/* Current Limiting */
swerveAngleFXConfig.CurrentLimits.SupplyCurrentLimitEnable = Constants.Swerve.angleEnableCurrentLimit;
swerveAngleFXConfig.CurrentLimits.SupplyCurrentLimitEnable =
Constants.Swerve.angleEnableCurrentLimit;
swerveAngleFXConfig.CurrentLimits.SupplyCurrentLimit = Constants.Swerve.angleCurrentLimit;
swerveAngleFXConfig.CurrentLimits.SupplyCurrentThreshold = Constants.Swerve.angleCurrentThreshold;
swerveAngleFXConfig.CurrentLimits.SupplyTimeThreshold = Constants.Swerve.angleCurrentThresholdTime;
swerveAngleFXConfig.CurrentLimits.SupplyCurrentThreshold =
Constants.Swerve.angleCurrentThreshold;
swerveAngleFXConfig.CurrentLimits.SupplyTimeThreshold =
Constants.Swerve.angleCurrentThresholdTime;

/* PID Config */
swerveAngleFXConfig.Slot0.kP = Constants.Swerve.angleKP;
Expand All @@ -41,21 +44,27 @@ public CTREConfigs(){
swerveDriveFXConfig.Feedback.SensorToMechanismRatio = Constants.Swerve.driveGearRatio;

/* Current Limiting */
swerveDriveFXConfig.CurrentLimits.SupplyCurrentLimitEnable = Constants.Swerve.driveEnableCurrentLimit;
swerveDriveFXConfig.CurrentLimits.SupplyCurrentLimitEnable =
Constants.Swerve.driveEnableCurrentLimit;
swerveDriveFXConfig.CurrentLimits.SupplyCurrentLimit = Constants.Swerve.driveCurrentLimit;
swerveDriveFXConfig.CurrentLimits.SupplyCurrentThreshold = Constants.Swerve.driveCurrentThreshold;
swerveDriveFXConfig.CurrentLimits.SupplyTimeThreshold = Constants.Swerve.driveCurrentThresholdTime;
swerveDriveFXConfig.CurrentLimits.SupplyCurrentThreshold =
Constants.Swerve.driveCurrentThreshold;
swerveDriveFXConfig.CurrentLimits.SupplyTimeThreshold =
Constants.Swerve.driveCurrentThresholdTime;

/* PID Config */
swerveDriveFXConfig.Slot0.kP = Constants.Swerve.driveKP;
swerveDriveFXConfig.Slot0.kI = Constants.Swerve.driveKI;
swerveDriveFXConfig.Slot0.kD = Constants.Swerve.driveKD;

/* Open and Closed Loop Ramping */
swerveDriveFXConfig.OpenLoopRamps.DutyCycleOpenLoopRampPeriod = Constants.Swerve.openLoopRamp;
swerveDriveFXConfig.OpenLoopRamps.DutyCycleOpenLoopRampPeriod =
Constants.Swerve.openLoopRamp;
swerveDriveFXConfig.OpenLoopRamps.VoltageOpenLoopRampPeriod = Constants.Swerve.openLoopRamp;

swerveDriveFXConfig.ClosedLoopRamps.DutyCycleClosedLoopRampPeriod = Constants.Swerve.closedLoopRamp;
swerveDriveFXConfig.ClosedLoopRamps.VoltageClosedLoopRampPeriod = Constants.Swerve.closedLoopRamp;
swerveDriveFXConfig.ClosedLoopRamps.DutyCycleClosedLoopRampPeriod =
Constants.Swerve.closedLoopRamp;
swerveDriveFXConfig.ClosedLoopRamps.VoltageClosedLoopRampPeriod =
Constants.Swerve.closedLoopRamp;
}
}
}
Loading

0 comments on commit 012fcac

Please sign in to comment.