Skip to content

Commit 2f2d067

Browse files
authored
Merge pull request #17 from strykeforce/proto
Initial Proto Bringup
2 parents 9eb7033 + a56116f commit 2f2d067

19 files changed

+222
-85
lines changed

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

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@
1717
import frc.robot.commands.coral.EnableEjectBeamCommand;
1818
import frc.robot.commands.coral.OpenLoopCoralCommand;
1919
import frc.robot.commands.drive.DriveTeleopCommand;
20+
import frc.robot.commands.drive.ResetGyroCommand;
21+
import frc.robot.commands.elevator.HoldElevatorCommand;
2022
import frc.robot.commands.elevator.JogElevatorCommand;
23+
import frc.robot.commands.elevator.SetElevatorPositionCommand;
2124
import frc.robot.commands.elevator.ZeroElevatorCommand;
2225
import frc.robot.constants.ElevatorConstants;
2326
import frc.robot.constants.RobotConstants;
2427
import frc.robot.controllers.FlyskyJoystick;
28+
import frc.robot.controllers.FlyskyJoystick.Button;
2529
import frc.robot.subsystems.algae.AlgaeIOFX;
2630
import frc.robot.subsystems.algae.AlgaeSubsystem;
2731
import frc.robot.subsystems.coral.CoralIO;
@@ -78,13 +82,17 @@ private void configureTelemetry() {
7882
telemetryService.register(coralSubsystem);
7983
telemetryService.register(algaeSubsystem);
8084
telemetryService.register(elevatorSubsystem);
85+
elevatorIO.registerWith(telemetryService);
8186
telemetryService.start();
8287
}
8388

8489
private void configureDriverBindings() {
8590
driveSubsystem.setDefaultCommand(
8691
new DriveTeleopCommand(
8792
() -> flysky.getFwd(), () -> flysky.getStr(), () -> flysky.getYaw(), driveSubsystem));
93+
94+
// Reset Gyro Command
95+
new JoystickButton(driveJoystick, Button.M_SWC.id).onTrue(new ResetGyroCommand(driveSubsystem));
8896
}
8997

9098
private void configureOperatorBindings() {
@@ -94,23 +102,25 @@ private void configureOperatorBindings() {
94102

95103
// Intake Coral
96104
new JoystickButton(xboxController, XboxController.Button.kY.value)
97-
.onTrue(new OpenLoopCoralCommand(coralSubsystem, -0.5))
98-
.onTrue(new EnableEjectBeamCommand(false, coralSubsystem));
105+
.onTrue(new OpenLoopCoralCommand(coralSubsystem, 0.5))
106+
.onTrue(new EnableEjectBeamCommand(true, coralSubsystem));
99107

100108
// Eject Coral
101109
new JoystickButton(xboxController, XboxController.Button.kA.value)
102-
.onTrue(new OpenLoopCoralCommand(coralSubsystem, -0.5))
103-
.onTrue(new EnableEjectBeamCommand(true, coralSubsystem));
110+
.onTrue(new OpenLoopCoralCommand(coralSubsystem, 1))
111+
.onTrue(new EnableEjectBeamCommand(false, coralSubsystem));
104112

105113
// Move Elevator
106-
new Trigger((() -> xboxController.getRightY() > RobotConstants.kJoystickDeadband))
114+
new Trigger((() -> xboxController.getRightY() < -RobotConstants.kTestingDeadband))
107115
.onTrue(
108116
new JogElevatorCommand(
109-
elevatorSubsystem, Angle.ofBaseUnits(ElevatorConstants.kJogAmount, Rotations)));
110-
new Trigger((() -> xboxController.getRightY() < -RobotConstants.kJoystickDeadband))
117+
elevatorSubsystem, Angle.ofBaseUnits(ElevatorConstants.kJogAmountUp, Rotations)))
118+
.onFalse(new HoldElevatorCommand(elevatorSubsystem));
119+
new Trigger((() -> xboxController.getRightY() > RobotConstants.kTestingDeadband))
111120
.onTrue(
112121
new JogElevatorCommand(
113-
elevatorSubsystem, Angle.ofBaseUnits(-ElevatorConstants.kJogAmount, Rotations)));
122+
elevatorSubsystem, Angle.ofBaseUnits(ElevatorConstants.kJogAmountDown, Rotations)))
123+
.onFalse(new HoldElevatorCommand(elevatorSubsystem));
114124

115125
// Zero Elevator
116126
new JoystickButton(xboxController, XboxController.Button.kX.value)
@@ -121,6 +131,25 @@ private void configureOperatorBindings() {
121131
.onTrue(new OpenLoopAlgaeCommand(algaeSubsystem, 0.5));
122132
new JoystickButton(xboxController, XboxController.Button.kRightBumper.value)
123133
.onTrue(new OpenLoopAlgaeCommand(algaeSubsystem, -0.5));
134+
135+
// Elevator setpoint testing
136+
new JoystickButton(xboxController, XboxController.Button.kStart.value)
137+
.onTrue(
138+
new SetElevatorPositionCommand(elevatorSubsystem, ElevatorConstants.kFunnelSetpoint));
139+
new JoystickButton(xboxController, XboxController.Button.kBack.value)
140+
.onTrue(new SetElevatorPositionCommand(elevatorSubsystem, ElevatorConstants.kStowSetpoint));
141+
(new Trigger(() -> xboxController.getPOV() == 0))
142+
.onTrue(
143+
new SetElevatorPositionCommand(elevatorSubsystem, ElevatorConstants.kL1CoralSetpoint));
144+
(new Trigger(() -> xboxController.getPOV() == 90))
145+
.onTrue(
146+
new SetElevatorPositionCommand(elevatorSubsystem, ElevatorConstants.kL2CoralSetpoint));
147+
(new Trigger(() -> xboxController.getPOV() == 180))
148+
.onTrue(
149+
new SetElevatorPositionCommand(elevatorSubsystem, ElevatorConstants.kL3CoralSetpoint));
150+
(new Trigger(() -> xboxController.getPOV() == 270))
151+
.onTrue(
152+
new SetElevatorPositionCommand(elevatorSubsystem, ElevatorConstants.kL4CoralSetpoint));
124153
}
125154

126155
public Command getAutonomousCommand() {

src/main/java/frc/robot/commands/algae/OpenLoopAlgaeCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public class OpenLoopAlgaeCommand extends InstantCommand {
1010
public OpenLoopAlgaeCommand(AlgaeSubsystem algaeSubsystem, double pct) {
1111
this.algaeSubsystem = algaeSubsystem;
1212
this.pct = pct;
13+
addRequirements(algaeSubsystem);
1314
}
1415

1516
@Override

src/main/java/frc/robot/commands/coral/EnableEjectBeamCommand.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
public class EnableEjectBeamCommand extends InstantCommand {
77
private CoralSubsystem coralSubsystem;
8-
private Boolean enable;
8+
private boolean enable;
99

10-
public EnableEjectBeamCommand(Boolean enable, CoralSubsystem coralSubsystem) {
10+
public EnableEjectBeamCommand(boolean enable, CoralSubsystem coralSubsystem) {
1111
this.coralSubsystem = coralSubsystem;
1212
this.enable = enable;
1313
}

src/main/java/frc/robot/commands/coral/OpenLoopCoralCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public class OpenLoopCoralCommand extends InstantCommand {
1010
public OpenLoopCoralCommand(CoralSubsystem coralSubsystem, double pct) {
1111
this.coralSubsystem = coralSubsystem;
1212
this.pct = pct;
13+
addRequirements(coralSubsystem);
1314
}
1415

1516
@Override
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package frc.robot.commands.drive;
2+
3+
import edu.wpi.first.wpilibj2.command.InstantCommand;
4+
import frc.robot.subsystems.drive.DriveSubsystem;
5+
6+
public class ResetGyroCommand extends InstantCommand {
7+
DriveSubsystem driveSubsystem;
8+
9+
public ResetGyroCommand(DriveSubsystem driveSubsystem) {
10+
this.driveSubsystem = driveSubsystem;
11+
addRequirements(driveSubsystem);
12+
}
13+
14+
@Override
15+
public void initialize() {
16+
driveSubsystem.teleResetGyro();
17+
}
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package frc.robot.commands.elevator;
2+
3+
import edu.wpi.first.wpilibj2.command.InstantCommand;
4+
import frc.robot.subsystems.elevator.ElevatorSubsystem;
5+
6+
public class HoldElevatorCommand extends InstantCommand {
7+
private ElevatorSubsystem elevatorSubsystem;
8+
9+
public HoldElevatorCommand(ElevatorSubsystem elevatorSubsystem) {
10+
this.elevatorSubsystem = elevatorSubsystem;
11+
addRequirements(elevatorSubsystem);
12+
}
13+
14+
@Override
15+
public void initialize() {
16+
elevatorSubsystem.setPosition(elevatorSubsystem.getPosition());
17+
}
18+
}

src/main/java/frc/robot/commands/elevator/JogElevatorCommand.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,21 @@ public class JogElevatorCommand extends Command {
1212
public JogElevatorCommand(ElevatorSubsystem elevatorSubsystem, Angle positionChange) {
1313
this.elevatorSubsystem = elevatorSubsystem;
1414
this.positionChange = positionChange;
15+
addRequirements(elevatorSubsystem);
1516
}
1617

1718
@Override
1819
public void initialize() {
1920
elevatorSubsystem.setPosition(elevatorSubsystem.getPosition().plus(positionChange));
2021
}
2122

23+
@Override
24+
public void execute() {
25+
elevatorSubsystem.setPosition(elevatorSubsystem.getPosition().plus(positionChange));
26+
}
27+
2228
@Override
2329
public boolean isFinished() {
24-
return elevatorSubsystem.isFinished();
30+
return false;
2531
}
2632
}

src/main/java/frc/robot/commands/elevator/SetElevatorPositionCommand.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class SetElevatorPositionCommand extends Command {
1212
public SetElevatorPositionCommand(ElevatorSubsystem elevatorSubsystem, Angle position) {
1313
this.elevatorSubsystem = elevatorSubsystem;
1414
this.position = position;
15+
addRequirements(elevatorSubsystem);
1516
}
1617

1718
@Override

src/main/java/frc/robot/commands/elevator/ZeroElevatorCommand.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,24 @@
22

33
import edu.wpi.first.wpilibj2.command.Command;
44
import frc.robot.subsystems.elevator.ElevatorSubsystem;
5+
import frc.robot.subsystems.elevator.ElevatorSubsystem.ElevatorStates;
56

67
public class ZeroElevatorCommand extends Command {
78

89
private ElevatorSubsystem elevatorSubsystem;
910

1011
public ZeroElevatorCommand(ElevatorSubsystem elevatorSubsystem) {
1112
this.elevatorSubsystem = elevatorSubsystem;
13+
addRequirements(elevatorSubsystem);
1214
}
1315

1416
@Override
1517
public void initialize() {
1618
elevatorSubsystem.zero();
1719
}
20+
21+
@Override
22+
public boolean isFinished() {
23+
return elevatorSubsystem.getState() == ElevatorStates.ZEROED;
24+
}
1825
}

src/main/java/frc/robot/constants/BiscuitConstants.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ public class BiscuitConstants {
2222
// These are all wrong right now because we don't have any actual info
2323

2424
public static Angle kZero = Rotations.of(42); // Will need to be experimentally determined
25-
public static int talonID = 3;
26-
public static double kCloseEnough = 2137473647; // This is a little out of wack.
25+
public static int talonID = 25;
26+
public static double kCloseEnough = 0.05; // This was a little out of wack.
2727
public static final Angle kMaxFwd = Rotations.of(100);
2828
public static final Angle kMaxRev = Rotations.of(-100);
2929

0 commit comments

Comments
 (0)