Skip to content

Commit 565d441

Browse files
committed
open loop buttons
1 parent 1b35ebb commit 565d441

File tree

6 files changed

+35
-19
lines changed

6 files changed

+35
-19
lines changed

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,23 @@
88
import edu.wpi.first.wpilibj.XboxController;
99
import edu.wpi.first.wpilibj2.command.Command;
1010
import edu.wpi.first.wpilibj2.command.Commands;
11+
import edu.wpi.first.wpilibj2.command.button.JoystickButton;
12+
import frc.robot.commands.algae.OpenLoopAlgaeCommand;
1113
import frc.robot.commands.drive.DriveTeleopCommand;
1214
import frc.robot.controllers.FlyskyJoystick;
15+
import frc.robot.subsystems.algae.AlgaeIOFX;
16+
import frc.robot.subsystems.algae.AlgaeSubsystem;
1317
import frc.robot.subsystems.drive.DriveSubsystem;
1418
import frc.robot.subsystems.drive.Swerve;
1519
import org.strykeforce.telemetry.TelemetryController;
1620
import org.strykeforce.telemetry.TelemetryService;
1721

1822
public class RobotContainer {
19-
private Swerve swerve;
2023
private DriveSubsystem driveSubsystem;
24+
private AlgaeSubsystem algaeSubsystem;
25+
26+
private Swerve swerve;
27+
private AlgaeIOFX algaeIO;
2128

2229
private final XboxController xboxController = new XboxController(1);
2330
private final Joystick driveJoystick = new Joystick(0);
@@ -26,6 +33,9 @@ public class RobotContainer {
2633

2734
public RobotContainer() {
2835
swerve = new Swerve();
36+
algaeIO = new AlgaeIOFX();
37+
38+
algaeSubsystem = new AlgaeSubsystem(algaeIO);
2939
driveSubsystem = new DriveSubsystem(swerve);
3040

3141
configureBindings();
@@ -40,6 +50,13 @@ private void configureDriverBindings() {
4050
() -> flysky.getFwd(), () -> flysky.getStr(), () -> flysky.getYaw(), driveSubsystem));
4151
}
4252

53+
private void configureOperatorBindings() {
54+
new JoystickButton(xboxController, XboxController.Button.kLeftBumper.value)
55+
.onTrue(new OpenLoopAlgaeCommand(algaeSubsystem, 0.5));
56+
new JoystickButton(xboxController, XboxController.Button.kRightBumper.value)
57+
.onTrue(new OpenLoopAlgaeCommand(algaeSubsystem, -0.5));
58+
}
59+
4360
public Command getAutonomousCommand() {
4461
return Commands.print("No autonomous command configured");
4562
}

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
import frc.robot.subsystems.algae.AlgaeSubsystem;
55

66
public class OpenLoopAlgaeCommand extends InstantCommand {
7-
private AlgaeSubsystem algaeSubsystem;
8-
private double pct;
7+
private AlgaeSubsystem algaeSubsystem;
8+
private double pct;
99

10-
public OpenLoopAlgaeCommand(AlgaeSubsystem algaeSubsystem, double pct) {
11-
this.algaeSubsystem = algaeSubsystem;
12-
this.pct = pct;
13-
}
10+
public OpenLoopAlgaeCommand(AlgaeSubsystem algaeSubsystem, double pct) {
11+
this.algaeSubsystem = algaeSubsystem;
12+
this.pct = pct;
13+
}
1414

15-
@Override
16-
public void initialize() {
17-
algaeSubsystem.setPct(pct);
18-
}
15+
@Override
16+
public void initialize() {
17+
algaeSubsystem.setPct(pct);
18+
}
1919
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import com.ctre.phoenix6.signals.ReverseLimitTypeValue;
1818
import edu.wpi.first.units.measure.AngularVelocity;
1919

20-
2120
public class AlgaeConstants {
2221
public static int kFxId = 30;
2322

src/main/java/frc/robot/subsystems/algae/AlgaeSubsystem.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import edu.wpi.first.units.measure.AngularVelocity;
66
import frc.robot.constants.AlgaeConstants;
77
import frc.robot.standards.ClosedLoopSpeedSubsystem;
8-
import frc.robot.subsystems.algae.algaeIO.AlgaeIOInputs;
8+
import frc.robot.subsystems.algae.AlgaeIO.AlgaeIOInputs;
99
import java.util.Set;
1010
import org.littletonrobotics.junction.Logger;
1111
import org.slf4j.LoggerFactory;
@@ -16,13 +16,13 @@
1616
public class AlgaeSubsystem extends MeasurableSubsystem implements ClosedLoopSpeedSubsystem {
1717
private org.slf4j.Logger logger = LoggerFactory.getLogger(AlgaeSubsystem.class);
1818

19-
private final algaeIO io;
19+
private final AlgaeIO io;
2020
private final AlgaeIOInputs inputs = new AlgaeIOInputs();
2121
private AngularVelocity desiredSpeed;
2222

2323
private AlgaeStates curState = AlgaeStates.IDLE;
2424

25-
public AlgaeSubsystem(algaeIO io) {
25+
public AlgaeSubsystem(AlgaeIO io) {
2626
this.io = io;
2727
}
2828

src/main/java/frc/robot/subsystems/algae/algaeIO.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import org.littletonrobotics.junction.AutoLog;
55
import org.strykeforce.telemetry.TelemetryService;
66

7-
public interface algaeIO {
7+
public interface AlgaeIO {
88
@AutoLog
99
public static class AlgaeIOInputs {
1010
public AngularVelocity velocity;

src/main/java/frc/robot/subsystems/algae/algaeIOFX.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import org.slf4j.LoggerFactory;
1414
import org.strykeforce.telemetry.TelemetryService;
1515

16-
public class algaeIOFX implements algaeIO {
16+
public class AlgaeIOFX implements AlgaeIO {
1717
private Logger logger;
1818
private TalonFX talonFX;
1919
private AlgaeIOInputs inputs;
@@ -25,12 +25,12 @@ public class algaeIOFX implements algaeIO {
2525
private VelocityVoltage speedRequest = new VelocityVoltage(0).withEnableFOC(false).withSlot(0);
2626
private DutyCycleOut dutyCycleRequest = new DutyCycleOut(0).withEnableFOC(false);
2727

28-
public algaeIOFX() {
28+
public AlgaeIOFX() {
2929
logger = LoggerFactory.getLogger(this.getClass());
3030
talonFX = new TalonFX(AlgaeConstants.kFxId);
31+
fwdLimitSwitch = talonFX.getForwardLimit();
3132
revLimitSwitch = talonFX.getReverseLimit();
3233
curVelocity = talonFX.getVelocity();
33-
fwdLimitSwitch = talonFX.getForwardLimit();
3434
}
3535

3636
@Override

0 commit comments

Comments
 (0)