Skip to content

Commit e4eb82a

Browse files
Merge pull request #10 from hammerhead226/amp-bar
Amp bar merge
2 parents c0e1373 + 5bab88d commit e4eb82a

10 files changed

Lines changed: 373 additions & 18 deletions

File tree

src/main/java/frc/robot/BuildConstants.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ public final class BuildConstants {
55
public static final String MAVEN_GROUP = "";
66
public static final String MAVEN_NAME = "2024 Robot Code";
77
public static final String VERSION = "unspecified";
8-
public static final int GIT_REVISION = 315;
9-
public static final String GIT_SHA = "2ba96a67996dd040d4122594e3dc264909194bf6";
10-
public static final String GIT_DATE = "2024-08-12 20:09:58 EDT";
11-
public static final String GIT_BRANCH = "pre-marc";
12-
public static final String BUILD_DATE = "2024-08-12 20:42:00 EDT";
13-
public static final long BUILD_UNIX_TIME = 1723509720423L;
8+
9+
public static final int GIT_REVISION = 321;
10+
public static final String GIT_SHA = "595783aa307f432a03116af1c4f77599478ee51c";
11+
public static final String GIT_DATE = "2024-08-12 20:54:55 EDT";
12+
public static final String GIT_BRANCH = "amp-bar";
13+
public static final String BUILD_DATE = "2024-08-13 23:59:25 EDT";
14+
public static final long BUILD_UNIX_TIME = 1723607965830L;
1415
public static final int DIRTY = 1;
1516

1617
private BuildConstants() {}

src/main/java/frc/robot/Constants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ public static class ElevatorConstants {
116116
public static final double[] PID = {0, 0, 0};
117117

118118
public static final double REDUCTION = (25.0 / 1.0);
119+
public static final double BAR_THRESHOLD = 3;
119120
}
120121

121122
public static class PivotConstants {

src/main/java/frc/robot/RobotContainer.java

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import frc.robot.commands.PositionNoteInFeeder;
4747
import frc.robot.commands.ScoreAmp;
4848
import frc.robot.commands.ScoreTrap;
49+
import frc.robot.commands.SetAmpBarTarget;
4950
import frc.robot.commands.SetElevatorTarget;
5051
import frc.robot.commands.SetPivotTarget;
5152
import frc.robot.commands.SetShooterTargetRPM;
@@ -67,6 +68,9 @@
6768
import frc.robot.subsystems.drive.ModuleIOTalonFX;
6869
import frc.robot.subsystems.drive.VisionIO;
6970
import frc.robot.subsystems.drive.VisionIOLimelight;
71+
import frc.robot.subsystems.elevator.AmpBarIO;
72+
import frc.robot.subsystems.elevator.AmpBarIOSIm;
73+
import frc.robot.subsystems.elevator.AmpBarIOSparkMAX;
7074
import frc.robot.subsystems.elevator.Elevator;
7175
import frc.robot.subsystems.elevator.ElevatorIO;
7276
import frc.robot.subsystems.elevator.ElevatorIOSim;
@@ -133,6 +137,7 @@ public class RobotContainer {
133137
private Trigger driveRightTrigger;
134138
private Trigger driveAButton;
135139
private Trigger driveXButton;
140+
private Trigger driveBButton;
136141

137142
private final LoggedDashboardNumber flywheelSpeed = new LoggedDashboardNumber("fly soeed", 5400);
138143

@@ -178,7 +183,8 @@ public RobotContainer() {
178183
new LeafBlowerIOTalonSRX(18));
179184
elevator =
180185
new Elevator(
181-
new ElevatorIOTalonFX(RobotMap.ElevatorIDs.LEFT, RobotMap.ElevatorIDs.RIGHT));
186+
new ElevatorIOTalonFX(RobotMap.ElevatorIDs.LEFT, RobotMap.ElevatorIDs.RIGHT),
187+
new AmpBarIOSparkMAX(RobotMap.ElevatorIDs.BAR));
182188
pivot =
183189
new Pivot(
184190
new PivotIOTalonFX(
@@ -201,7 +207,7 @@ public RobotContainer() {
201207
new FeederIOSim(),
202208
new DistanceSensorIO() {},
203209
new LeafBlowerIO() {});
204-
elevator = new Elevator(new ElevatorIOSim());
210+
elevator = new Elevator(new ElevatorIOSim(), null);
205211
pivot = new Pivot(new PivotIOSim());
206212
led = new LED(new LED_IOSim());
207213
break;
@@ -221,7 +227,7 @@ public RobotContainer() {
221227
new FeederIOSim(),
222228
new DistanceSensorIO() {},
223229
new LeafBlowerIO() {});
224-
elevator = new Elevator(new ElevatorIOSim());
230+
elevator = new Elevator(new ElevatorIOSim(), new AmpBarIOSIm());
225231
pivot = new Pivot(new PivotIOSim());
226232
led = new LED(new LED_IOSim());
227233
break;
@@ -244,7 +250,7 @@ public RobotContainer() {
244250
new FeederIOTalonFX(RobotMap.ShooterIDs.FEEDER),
245251
new DistanceSensorIO() {},
246252
new LeafBlowerIO() {});
247-
elevator = new Elevator(new ElevatorIO() {});
253+
elevator = new Elevator(new ElevatorIO() {}, new AmpBarIO() {});
248254
pivot = new Pivot(new PivotIO() {});
249255
led = new LED(new LED_IO() {});
250256
break;
@@ -267,6 +273,7 @@ public RobotContainer() {
267273
driveRightTrigger = driveController.rightTrigger();
268274
driveAButton = driveController.a();
269275
driveXButton = driveController.x();
276+
driveBButton = driveController.b();
270277

271278
// intakeLEDCommands =
272279
// new SelectCommand<>(
@@ -292,9 +299,10 @@ public RobotContainer() {
292299
SHOOT_STATE.AMP,
293300
new SequentialCommandGroup(
294301
// amp shoot
295-
new InstantCommand(() -> shooter.setFeedersRPM(500)),
296-
new WaitCommand(1.323),
297-
new InstantCommand(() -> shooter.setFlywheelRPMs(-900, -900)))),
302+
new InstantCommand(() -> shooter.setFeedersRPM(500))
303+
// new WaitCommand(1.323)
304+
)),
305+
// new InstantCommand(() -> shooter.setFlywheelRPMs(-900, -900)))),
298306
Map.entry(
299307
SHOOT_STATE.TRAP,
300308
new SequentialCommandGroup(
@@ -702,6 +710,20 @@ private void testControls() {
702710
// driveController.leftTrigger().onTrue(new InstantCommand(() -> shooter.setFeedersRPM(200)));
703711
driveController.leftTrigger().onTrue(new InstantCommand(() -> shooter.setFeedersRPM(500)));
704712
driveController.leftTrigger().onFalse(new InstantCommand(() -> shooter.stopFeeders()));
713+
714+
driveController.b().onTrue(new SetAmpBarTarget(10, 0, elevator));
715+
driveController
716+
.b()
717+
.onFalse(
718+
new InstantCommand(() -> pivot.setShootState(SHOOT_STATE.AIMBOT))
719+
.andThen(
720+
new SequentialCommandGroup(
721+
new SetAmpBarTarget(5, 3, elevator),
722+
new InstantCommand(() -> shooter.turnOffFan()),
723+
new SetElevatorTarget(0, 0.5, elevator),
724+
new InstantCommand(() -> elevator.setConstraints(30, 85)),
725+
new InstantCommand(() -> shooter.stopFlywheels(), shooter),
726+
new SetPivotTarget(Constants.PivotConstants.STOW_SETPOINT_DEG, pivot))));
705727
}
706728

707729
// TODO:: change drive controls to match changed test controls
@@ -815,7 +837,24 @@ private void driverControls() {
815837
driveAButton.onTrue(climbCommands);
816838

817839
driveXButton.onTrue(trapCommands);
840+
// driveController
841+
// .b()
842+
// .onTrue(
843+
// new InstantCommand(() -> pivot.setShootState(SHOOT_STATE.AMP))
844+
// .andThen(new ScoreAmp(elevator, pivot, shooter, drive)));
818845

846+
// driveController
847+
// .b()
848+
// .onFalse(
849+
// new InstantCommand(() -> pivot.setShootState(SHOOT_STATE.AIMBOT))
850+
// .andThen(
851+
// new SequentialCommandGroup(
852+
// new SetAmpBarTarget(5, 3, elevator),
853+
// new InstantCommand(() -> shooter.turnOffFan()),
854+
// new SetElevatorTarget(0, 0.5, elevator),
855+
// new InstantCommand(() -> elevator.setConstraints(30, 85)),
856+
// new InstantCommand(() -> shooter.stopFlywheels(), shooter),
857+
// new SetPivotTarget(Constants.PivotConstants.STOW_SETPOINT_DEG, pivot))));
819858
// driveController
820859
// .rightBumper()
821860
// .whileTrue(
@@ -872,6 +911,7 @@ private void manipControls() {
872911
new InstantCommand(() -> pivot.setShootState(SHOOT_STATE.AIMBOT))
873912
.andThen(
874913
new SequentialCommandGroup(
914+
new SetAmpBarTarget(5, 3, elevator),
875915
new InstantCommand(() -> shooter.turnOffFan()),
876916
new SetElevatorTarget(0, 0.5, elevator),
877917
new InstantCommand(() -> elevator.setConstraints(30, 85)),

src/main/java/frc/robot/RobotMap.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ public static class ElevatorIDs {
1616
// public static final int RIGHT = 9;
1717
public static final int LEFT = 8;
1818
public static final int RIGHT = 9;
19+
public static final int BAR = 18;
1920
}
2021

2122
public static class PivotIDs {
2223
public static final int GYRO = 10;
2324
// public static final int LEFT = 14;
2425
// public static final int RIGHT = 15;
2526
public static final int LEFT = 14;
27+
2628
public static final int RIGHT = 15;
2729
}
2830

src/main/java/frc/robot/commands/ScoreAmp.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package frc.robot.commands;
66

77
import edu.wpi.first.wpilibj2.command.InstantCommand;
8+
import edu.wpi.first.wpilibj2.command.ParallelCommandGroup;
89
import edu.wpi.first.wpilibj2.command.SequentialCommandGroup;
910
import frc.robot.Constants;
1011
import frc.robot.subsystems.drive.Drive;
@@ -19,10 +20,15 @@ public class ScoreAmp extends SequentialCommandGroup {
1920
/** Creates a new ScoreAmp. */
2021
public ScoreAmp(Elevator elevator, Pivot pivot, Shooter shooter, Drive drive) {
2122
addCommands(
22-
new InstantCommand(() -> elevator.setConstraints(100, 640)),
23-
new InstantCommand(() -> shooter.setFlywheelRPMs(650, 650), shooter),
24-
new SetPivotTarget(Constants.PivotConstants.AMP_SETPOINT_DEG, pivot),
23+
amp-bar
24+
new ParallelCommandGroup(
25+
new InstantCommand(() -> elevator.setConstraints(100, 640), elevator),
26+
new InstantCommand(() -> shooter.setFlywheelRPMs(2400, 2400), shooter),
27+
new SetPivotTarget(Constants.PivotConstants.AMP_SETPOINT_DEG, pivot)),
28+
new SetAmpBarTarget(195, 0, elevator),
29+
2530
new SetElevatorTarget(6, 1, elevator));
31+
2632
// addCommands(
2733
// new ParallelCommandGroup(
2834
// // new AlignToAmp(drive),
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Copyright (c) FIRST and other WPILib contributors.
2+
// Open Source Software; you can modify and/or share it under the terms of
3+
// the WPILib BSD license file in the root directory of this project.
4+
5+
package frc.robot.commands;
6+
7+
import edu.wpi.first.wpilibj2.command.Command;
8+
import frc.robot.subsystems.elevator.Elevator;
9+
import org.littletonrobotics.junction.Logger;
10+
11+
public class SetAmpBarTarget extends Command {
12+
/** Creates a new SetAmpBarTarget. */
13+
private final Elevator elevator;
14+
15+
private double threshold;
16+
private double setPoint;
17+
18+
public SetAmpBarTarget(double setpoint, double threshold, Elevator elevator) {
19+
// Use addRequirements() here to declare subsystem dependencies.
20+
this.setPoint = setpoint;
21+
this.threshold = threshold;
22+
this.elevator = elevator;
23+
24+
addRequirements(elevator);
25+
}
26+
27+
// Called when the command is initially scheduled.
28+
@Override
29+
public void initialize() {
30+
elevator.setBarGoal(setPoint);
31+
}
32+
33+
// Called every time the scheduler runs while the command is scheduled.
34+
@Override
35+
public void execute() {}
36+
37+
// Called once the command ends or is interrupted.
38+
@Override
39+
public void end(boolean interrupted) {
40+
// elevator.stopAmpBar();
41+
}
42+
43+
// Returns true when the command should end.
44+
@Override
45+
public boolean isFinished() {
46+
Logger.recordOutput("bar command ", elevator.ampBarAtGoal());
47+
return true;
48+
}
49+
}

0 commit comments

Comments
 (0)