Skip to content

Commit

Permalink
idk
Browse files Browse the repository at this point in the history
  • Loading branch information
Ishan1522 committed Sep 22, 2024
1 parent bf480d2 commit 6c3e685
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 41 deletions.
28 changes: 27 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,30 @@ jobs:
java-version: 17
distribution: temurin
- name: Run formatter
run: ./gradlew spotlessCheck
run: ./gradlew spotlessCheck

pmd-code-scan:
name: "Linter"
permissions:
contents: read # for actions/checkout to fetch code
security-events: write # for github/codeql-action/upload-sarif to upload SARIF results
actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
- name: Run PMD
id: pmd
uses: pmd/pmd-github-action@967a81f8b657c87f7c3e96b62301cb1a48efef29
with:
rulesets: 'pmd-ruleset.xml'
# sourcePath: 'src/main/java'
analyzeModifiedFilesOnly: false
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: pmd-report.sarif
4 changes: 1 addition & 3 deletions pmd-ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

<description>PMD Ruleset for WPILib</description>

<exclude-pattern>.*/*JNI.*</exclude-pattern>
<exclude-pattern>.*/*IntegrationTests.*</exclude-pattern>
<exclude-pattern>.*/math/proto.*</exclude-pattern>
<exclude-pattern>.*/LimeligtHelpers.java</exclude-pattern>

<rule ref="category/java/bestpractices.xml">
<exclude name="AccessorClassGeneration" />
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/frc/robot/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ public static final class PivotConstants {
public static final double SHOOT_TRAP_ANGLE = 0;
public static final double PIVOT_ACCEPTABLE_ERROR = 0.015;

public static double[][] SPEAKER_PIVOT_POSITION = {
public static final double[][] SPEAKER_PIVOT_POSITION = {
// Distance, Angle (rotations)
{1.3, 0.029},
{1.5, 0.037265625},
Expand All @@ -438,7 +438,7 @@ public static final class PivotConstants {
{4.9, 0.1135}
};

public static double[][] PASS_PIVOT_POSITION = {
public static final double[][] PASS_PIVOT_POSITION = {
// Distance, Angle (rotations)
{10.680643009839416, 0.037400390625},
{9.11398136590441, 0.038},
Expand Down Expand Up @@ -482,24 +482,24 @@ public static final class ShooterConstants {
public static final double AUTO_SHOOT_P = 5; // 7 --> 4.5 --> 5
public static final double AUTO_SHOOT_I = 0.0;
public static final double AUTO_SHOOT_D = 0.0;
public static Constraints AUTO_SHOOT_CONSTRAINTS =
public static final Constraints AUTO_SHOOT_CONSTRAINTS =
new Constraints(DriveConstants.MAX_ANGULAR_SPEED_RADIANS_PER_SECOND, 2);

public static final double AUTO_SHOOT_MOVE_P = 10.0;
public static final double AUTO_SHOOT_MOVE_I = 0.0;
public static final double AUTO_SHOOT_MOVE_D = 0.0;
public static Constraints AUTO_SHOOT_MOVE_CONSTRAINTS = new Constraints(10, 5);
public static final Constraints AUTO_SHOOT_MOVE_CONSTRAINTS = new Constraints(10, 5);

public static final double AUTO_LINEUP_ROTATION_P = 3;
public static final double AUTO_LINEUP_ROTATION_I = 0.0;
public static final double AUTO_LINEUP_ROTATION_D = 0.0;
public static Constraints AUTO_LINEUP_ROTATION_CONSTRAINTS =
public static final Constraints AUTO_LINEUP_ROTATION_CONSTRAINTS =
new Constraints(DriveConstants.MAX_ANGULAR_SPEED_RADIANS_PER_SECOND, 2);

public static final double AUTO_LINEUP_TRANSLATION_P = 10; // 4.5, 4.0
public static final double AUTO_LINEUP_TRANSLATION_I = 0.0;
public static final double AUTO_LINEUP_TRANSLATION_D = 0.0;
public static Constraints AUTO_LINEUP_TRANSLATION_CONSTRAINTS = new Constraints(1, 1);
public static final Constraints AUTO_LINEUP_TRANSLATION_CONSTRAINTS = new Constraints(1, 1);

// TODO: calc
public static final double NOTE_LAUNCH_VELOCITY_METERS_PER_SECOND = 10.8;
Expand Down Expand Up @@ -552,13 +552,13 @@ public static final class TrajectoryConstants {
public static final double AUTO_ALIGN_TRANSLATIONAL_I = 0;
public static final double AUTO_ALIGN_TRANSLATIONAL_D = 0;

public static Constraints AUTO_ALIGN_TRANSLATION_CONSTRAINTS = new Constraints(5, 2);
public static final Constraints AUTO_ALIGN_TRANSLATION_CONSTRAINTS = new Constraints(5, 2);

public static final double AUTO_ALIGN_ROTATIONAL_P = 3;
public static final double AUTO_ALIGN_ROTATIONAL_I = 0;
public static final double AUTO_ALIGN_ROTATIONAL_D = 0;

public static Constraints AUTO_ALIGN_ROTATIONAL_CONSTRAINTS =
public static final Constraints AUTO_ALIGN_ROTATIONAL_CONSTRAINTS =
new Constraints(DriveConstants.MAX_ANGULAR_SPEED_RADIANS_PER_SECOND, 2);
}

Expand Down
12 changes: 6 additions & 6 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ private void configureButtonBindings() {

Trigger driverRightBumper = new Trigger(driverController::getRightBumper);
Trigger driverRightDirectionPad = new Trigger(() -> driverController.getPOV() == 90);
Trigger driverDownDirectionPad = new Trigger(() -> driverController.getPOV() == 180);
// Trigger driverDownDirectionPad = new Trigger(() -> driverController.getPOV() == 180);
Trigger driverLeftDirectionPad = new Trigger(() -> driverController.getPOV() == 270);

// autodrive
Expand All @@ -233,8 +233,8 @@ private void configureButtonBindings() {
Trigger operatorLeftTrigger = new Trigger(() -> operatorController.getLeftTriggerAxis() > 0.2);
Trigger operatorLeftBumper = new Trigger(operatorController::getLeftBumper);
// amp and speaker
Trigger operatorBButton = new Trigger(operatorController::getBButton);
Trigger operatorRightBumper = new Trigger(operatorController::getRightBumper);
// Trigger operatorBButton = new Trigger(operatorController::getBButton);
// Trigger operatorRightBumper = new Trigger(operatorController::getRightBumper);
Trigger operatorRightTrigger =
new Trigger(() -> operatorController.getRightTriggerAxis() > 0.2);
Trigger driverRightTrigger = new Trigger(() -> driverController.getRightTriggerAxis() > 0.2);
Expand All @@ -246,13 +246,13 @@ private void configureButtonBindings() {
DoubleSupplier operatorRightStickY = operatorController::getRightY;
// unused
Trigger operatorUpDirectionPad = new Trigger(() -> operatorController.getPOV() == 0);
Trigger operatorLeftDirectionPad = new Trigger(() -> operatorController.getPOV() == 270);
// Trigger operatorLeftDirectionPad = new Trigger(() -> operatorController.getPOV() == 270);
Trigger operatorDownDirectionPad = new Trigger(() -> operatorController.getPOV() == 180);
Trigger driverLeftTrigger = new Trigger(() -> driverController.getLeftTriggerAxis() > 0.2);
Trigger driverLeftBumper = new Trigger(driverController::getLeftBumper);
Trigger driverBButton = new Trigger(driverController::getBButton);
Trigger driverYButton = new Trigger(driverController::getYButton);
DoubleSupplier operatorLeftStickY = operatorController::getLeftY;
// Trigger driverYButton = new Trigger(driverController::getYButton);
// DoubleSupplier operatorLeftStickY = operatorController::getLeftY;

// DRIVER BUTTONS

Expand Down
27 changes: 4 additions & 23 deletions src/main/java/frc/robot/commands/shooter/AutoSpinUp.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,12 @@ public class AutoSpinUp extends DriveCommandBase {
private final DriveSubsystem driveSubsystem;
private final ShooterSubsystem shooterSubsystem;
private final PivotSubsystem pivotSubsystem;
private final VisionSubsystem visionSubsystem;
private final LEDSubsystem leds;

private final DoubleSupplier leftX, leftY, rightX;
private final BooleanSupplier isFieldRelative;

private double headingError = 0;

private boolean isRed = false;
private double desiredHeading = 0;
private double desiredHeading;
private Translation2d speakerPos;

/** Creates a new SpinUpForSpeaker. */
Expand All @@ -53,7 +49,6 @@ public AutoSpinUp(
this.driveSubsystem = driveSubsystem;
this.shooterSubsystem = shooterSubsystem;
this.pivotSubsystem = pivotSubsystem;
this.visionSubsystem = visionSubsystem;
this.leftX = leftX;
this.leftY = leftY;
this.rightX = rightX;
Expand All @@ -66,14 +61,8 @@ public AutoSpinUp(
@Override
public void initialize() {
Optional<Alliance> alliance = DriverStation.getAlliance();
// if alliance is detected
if (alliance.isPresent()) {
// and if it's red, we're red
isRed = alliance.get() == Alliance.Red;
} else {
// otherwise default to red alliance
isRed = true;
}
boolean isRed = alliance.get() == Alliance.Red;

// SmartDashboard.putBoolean("red", isRed);
speakerPos =
isRed
Expand All @@ -89,15 +78,10 @@ public void execute() {

// get positions of various things
Translation2d robotPos = driveSubsystem.getPose().getTranslation();
// distance (for speaker lookups)
double distance = robotPos.getDistance(speakerPos);
// arctangent for desired heading
desiredHeading =
Math.atan2((robotPos.getY() - speakerPos.getY()), (robotPos.getX() - speakerPos.getX()));

// current
headingError = desiredHeading - driveSubsystem.getOdometryRotation2d().getRadians();

// allow the driver to drive slowly (NOT full speed - will mess up shooter)
driveSubsystem.drive(
deadband(leftY.getAsDouble()) * DriveConstants.MAX_SPEED_METERS_PER_SECOND,
Expand Down Expand Up @@ -129,10 +113,7 @@ public boolean isFinished() {
}

public boolean isInRange() {
if (desiredHeading > 25) {
return true;
}
return false;
return (desiredHeading > 25);
}

private double deadband(double val) {
Expand Down

0 comments on commit 6c3e685

Please sign in to comment.