Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heartland Regional Code #7

Merged
merged 11 commits into from
Mar 22, 2024
Merged

Heartland Regional Code #7

merged 11 commits into from
Mar 22, 2024

Conversation

Mallen220
Copy link
Contributor

Code that was running at the Heartland Regional.

.pathplanner/settings.json Outdated Show resolved Hide resolved
.vscode/settings.json Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
src/main/deploy/pathplanner/autos/driven_source_score.auto Outdated Show resolved Hide resolved
src/main/deploy/pathplanner/autos/overture_amp.auto Outdated Show resolved Hide resolved
public void execute() {
// System.out.println(Timer.getFPGATimestamp());
// testing
if (SHOOTER.isRearBroken()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's try to avoid this significant amount of nested if statements.
ex.

if (!SHOOTER.isRearBroken()) {
  CANDLES.setColorLeft(255, 0, 0);
  return;
}
if (!SHOOTER.isCenterBroken()) {
  CANDLES.setColorLeft(128, 64, 0);
  return;
}
...

The more flat we can keep this logic, the easier it'll be to follow what's going on for all the different conditions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this change really satisfies the comment. I'll try to make a proper suggestion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe something like this should achieve the desired result (or at least similar) while still being easy to digest at a glance:

    if (!SHOOTER.isRearBroken()) {
      CANDLES.setColorLeft(255, 0, 0);
      return;
    }
    if (!SHOOTER.isCenterBroken()) {
      CANDLES.setColorLeft(128, 64, 0);
      return;
    }
    CANDLES.setColorLeft(0, 128, 128);
    if (!PHOTON_SPEAKER.hasTargets()) {
      CANDLES.setColorRight(255, 0, 0);
      return;
    }
    double dist = Util.getInterpolatedDistance(PHOTON_SPEAKER);
    if (dist < 2.25 && dist > 4.25) {
      CANDLES.setColorRight(255, 0, 0);
      return;
    }
    if (Util.isWithinTolerance(PHOTON_SPEAKER.getYawVal(), 0.0, 1)
      && ((Timer.getFPGATimestamp()) / BLINK_CONSTANT) == 0) {
      CANDLES.setColorRight(0, 0, 0);
      return;
    }
    CANDLES.setColorRight(0, 255, 0);

However, this needs to be tested for correctness on the robot before merging.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bc1c238

I implemented the suggestion but changed the .setColor methods with their new counterparts for readability.

src/main/java/frc/robot/commands/qol/DefaultCANdle.java Outdated Show resolved Hide resolved
Comment on lines 75 to 79
// Returns true when the command should end.
@Override
public boolean isFinished() {
return false;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Command super class defaults to returning false, so it should be safe to remove this override.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not just the @Override, but rather the entire method should be good to remove. Since we're not really changing the default behavior of the method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@Lithiuman Lithiuman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Candle Changes are silly. Use a method where you pass a Color#color parameter, instead of having 13 different methods in your subsystem. I'll fix this later, good for now.

@frc1987 frc1987 merged commit 3152234 into main Mar 22, 2024
2 checks passed
@frc1987 frc1987 deleted the pre-heartland-recode branch March 22, 2024 03:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants