Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions src/main/java/frc/robot/Joysticks.java/DriverJoystick.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package frc.robot;

import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.button.CommandXboxController;
import frc.robot.subsystems.CommandSwerveDrivetrain;
import frc.robot.subsystems.FuelSubsystem;

public class DriverJoystick {
private final CommandXboxController joystick;
private final CommandSwerveDrivetrain drivetrain;
private final FuelSubsystem fuelSubsystem;

public DriverJoystick(CommandXboxController joystick, CommandSwerveDrivetrain drivetrain, FuelSubsystem fuelSubsystem) {

this.joystick = joystick;
this.drivetrain = drivetrain;
this.fuelSubsystem = fuelSubsystem;
}

public void configureButtonBindings() {
joystick.a()
.whileTrue(fuelSubsystem.intake())
.onFalse(
Commands.run(
() -> {
fuelSubsystem.stop();
}
)
);

joystick.b()
.whileTrue(fuelSubsystem.eject())
.onFalse(
Commands.run(
() -> {
fuelSubsystem.stop();
}
)
);

joystick.x()
.onTrue(fuelSubsystem.launch().withTimeout(0.5))
.onFalse(
Commands.run(
() -> {
fuelSubsystem.stop();
}
)
);

joystick.y()
.whileTrue(fuelSubsystem.spinUp().withTimeout(0.5))
.onFalse(
Commands.run(
() -> {
fuelSubsystem.stop();
}
)
);

joystick.rightBumper().onTrue(fuelSubsystem.stop());
}
}
66 changes: 66 additions & 0 deletions src/main/java/frc/robot/subsystems/FuelSubsystem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package frc.robot.subsystems;

import com.ctre.phoenix6.hardware.TalonFX;

import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.Commands;
import edu.wpi.first.wpilibj2.command.SubsystemBase;

public class FuelSubsystem extends SubsystemBase {
public static TalonFX intakeLauncherRoller = new TalonFX(1);
public static TalonFX feederRoller = new TalonFX(2);


double launcherIntakeSpeed = 0.5;
double launcherLaunchSpeed = 0.7;

double rollerIntakeSpeed = 0.4;
double rollerLaunchSpeed = 0.6;
double rollerSpinUpSpeed = 0.5;

//most values are placeholders
public Command intake() {
return Commands.run(
() -> {
intakeLauncherRoller.set(launcherIntakeSpeed);
feederRoller.set(rollerIntakeSpeed);
}
);
}

public Command eject() {
return Commands.run(
() -> {
intakeLauncherRoller.set(-launcherIntakeSpeed);
feederRoller.set(-rollerIntakeSpeed);
}
);
}

public Command stop() {
return Commands.run(
() -> {
intakeLauncherRoller.set(0);
feederRoller.set(0);
}
);
}

public Command launch() {
return Commands.run(
() -> {
intakeLauncherRoller.set(launcherLaunchSpeed);
feederRoller.set(rollerLaunchSpeed);
}
);
}

public Command spinUp() {
return Commands.run(
() -> {
intakeLauncherRoller.set(launcherLaunchSpeed);
feederRoller.set(rollerSpinUpSpeed);
}
);
}
}