Skip to content

Commit

Permalink
fixed some bugs in the shoot note visualizer in example
Browse files Browse the repository at this point in the history
  • Loading branch information
catr1xLiu committed Sep 10, 2024
1 parent 93138fe commit ab12186
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ public void configureButtonBindings() {
faceTargetWhileDrivingLowSpeed::chassisRotationInPosition,
ledStatusLight,
visualizerForShooter
);
).ifNotePresent();
driverXBox.rightTrigger(0.5).whileTrue(semiAutoAimAndShoot.deadlineWith(faceTargetWhileDrivingLowSpeed));

driverXBox.rightBumper().whileTrue(new PathFindToPoseAndShootSequence(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public AimAndShootSequence(
);
}

private final Intake intake;
/**
* creates a sequence to shoot at speaker in the following steps:
* 1. runs a {@link PrepareToAim} command, until the shooter is prepared
Expand All @@ -55,6 +56,7 @@ public AimAndShootSequence(
CompetitionFieldVisualizer visualizer) {

super();
this.intake = intake;
super.addRequirements(pitch, flyWheels, intake);
super.addCommands(Commands.runOnce(intake::runIdle));

Expand All @@ -70,7 +72,11 @@ public AimAndShootSequence(
super.addCommands(aimAtSpeakerContinuously.raceWith(waitForRightTimingAndShoot));
super.addCommands(Commands.runOnce(() -> visualizer.addGamePieceOnFly(new Crescendo2024FieldObjects.NoteFlyingToShooter(
new Translation3d(drive.getPose().getX(), drive.getPose().getY(), 0.3),
0.5
8
))));
}

public Command ifNotePresent() {
return this.onlyIf(intake::isNotePresent);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public void execute() {

public boolean readyToShoot() {
return shooterOptimizationRunning
&& shooterOptimization.isTargetInRange(targetPositionSupplier.get(), drive.getPose().getTranslation())
&& additionalCondition.getAsBoolean()
&& flyWheels.flyWheelsReady()
&& pitch.inPosition();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static Command shootAtSpeakerStill(HolonomicDriveSubsystem drive, Intake
chassisAimAtSpeaker::isFinished,
statusLight,
visualizer
);
).ifNotePresent();

final Command aimAtSpeakerStill = semiAutoAimAndShoot.deadlineWith(chassisAimAtSpeaker);
aimAtSpeakerStill.addRequirements(drive, pitch, flyWheels);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public PathFindToPoseAndShootSequence(
() -> isChassisSlowEnough(driveSubsystem),
statusLight,
visualizer
)
).ifNotePresent()
);

super.addRequirements(driveSubsystem, pitch, flyWheels, intake);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ public String getTypeName() {
* the flight is simulated by a simple linear animation
* */
public static class NoteFlyingToShooter extends GamePieceOnFlyDisplay {
public NoteFlyingToShooter(Translation3d shooterPosition, double flightTimeSeconds) {
public NoteFlyingToShooter(Translation3d shooterPosition, double speedMPS) {
super(
shooterPosition,
FieldConstants.toCurrentAllianceTranslation(FieldConstants.SPEAKER_POSE_BLUE),
flightTimeSeconds
FieldConstants.toCurrentAllianceTranslation(FieldConstants.SPEAKER_POSE_BLUE).getDistance(shooterPosition) / speedMPS
);
}

Expand Down

0 comments on commit ab12186

Please sign in to comment.