fixed the formatting in all files

This commit is contained in:
Cayden Brackett 2024-12-03 17:14:42 -05:00
parent b084ae7f16
commit 2c4c1f24ea
7 changed files with 55 additions and 46 deletions

View File

@ -21,45 +21,48 @@ public class RobotContainer {
private Drivetrain drivetrain; private Drivetrain drivetrain;
private CommandXboxController driver; private CommandXboxController driver;
public RobotContainer() { public RobotContainer() {
//sets up controlers
drivetrain = new Drivetrain(); drivetrain = new Drivetrain();
flicker = new Flicker(); flicker = new Flicker();
driver = new CommandXboxController(OIConstants.kDriverUSB); //sets up controlers driver = new CommandXboxController(OIConstants.kDriverUSB);
configureBindings(); configureBindings();
configureShuffleboard(); configureShuffleboard();
} }
private void configureBindings() { private void configureBindings() {
//manual controls for driveing
drivetrain.setDefaultCommand( drivetrain.setDefaultCommand(
drivetrain.driveArcade( drivetrain.driveArcade(
driver::getLeftY, driver::getLeftY,
driver::getLeftX //manual controls for driveing driver::getLeftX
) )
); );
flicker.setDefaultCommand(flicker.stop()); flicker.setDefaultCommand(flicker.stop());
//manual controls for shooter and flicker
driver.a().onTrue(flicker.setSpeed(() ->1)); driver.a().onTrue(flicker.setSpeed(() ->1));
shooter.setDefaultCommand(shooter.stop()); shooter.setDefaultCommand(shooter.stop());
driver.rightBumper().onTrue(shooter.setSpeed(()->1)); //manual controls for shooter and flicker driver.rightBumper().onTrue(shooter.setSpeed(()->1));
} }
private void configureShuffleboard() { private void configureShuffleboard() {
//sets up the wiget
ShuffleboardTab robotIndicatorTab = Shuffleboard.getTab(OIConstants.kRobotIndicatorsTabName); ShuffleboardTab robotIndicatorTab = Shuffleboard.getTab(OIConstants.kRobotIndicatorsTabName);
robotIndicatorTab.addBoolean("Sensors", flicker::frisbySensor)
robotIndicatorTab.addBoolean("Sensors", flicker::photoswich)
.withPosition(0, 0). .withPosition(0, 0).
withSize(2, 1). withSize(2, 1).
withWidget(BuiltInWidgets.kBooleanBox); //sets up the wiget withWidget(BuiltInWidgets.kBooleanBox);
} }
public Command getAutonomousCommand() { public Command getAutonomousCommand() {
//sets up the anumus command, it drives forward for 2 seconds, spins the shooter mototrs for 1 second, and both shooter and flicker for 3 seconds.
return drivetrain.driveTank(() -> .5,() -> .5).withTimeout(2). andThen( return drivetrain.driveTank(() -> .5,() -> .5).withTimeout(2). andThen(
shooter.setSpeed(()-> 1)).withTimeout(1).andThen( shooter.setSpeed(()-> 1)).withTimeout(1).andThen(
shooter.setSpeed(()->1)).alongWith( shooter.setSpeed(()->1)).alongWith(
flicker.setSpeed(()->1)); //sets up the anumus command, it drives forward for 2 seconds, spins the shooter mototrs for 1 second, and both shooter and flicker for 3 seconds. flicker.setSpeed(()->1));
} }
} }

View File

@ -3,7 +3,7 @@ package frc.robot.constants;
public class DrivetrainConstants { public class DrivetrainConstants {
public static final int kleftFrontPWN = 0; public static final int kleftFrontPWN = 0;
public static final int kleftRearPWN = 1; public static final int kleftRearPWN = 1;
public static final int kRightfrontPWM = 2; public static final int kRightFrontPWM = 2;
public static final int kRightRearPWM = 3; public static final int kRightRearPWM = 3;
} }

View File

@ -1,7 +1,7 @@
package frc.robot.constants; package frc.robot.constants;
public class FlickerConstants { public class FlickerConstants {
public static final int K3motorPWM = 1; public static final int k3motorPWM = 1;
public static int Photoswitch = 1; public static int kPhotoSwitch = 1;
} }

View File

@ -1,6 +1,6 @@
package frc.robot.constants; package frc.robot.constants;
public class ShooterConstants { public class ShooterConstants {
public static final int K1motorPWM = 0; public static final int K1MotorPWM = 0;
public static final int K2motorPWM = 0; public static final int K2MotorPWM = 0;
} }

View File

@ -9,7 +9,8 @@ import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.constants.DrivetrainConstants; import frc.robot.constants.DrivetrainConstants;
public class Drivetrain extends SubsystemBase { public class Drivetrain extends SubsystemBase {
private VictorSP leftFront; // tells the motors how much power they use // tells the motors how much power they use
private VictorSP leftFront;
private VictorSP leftRear; private VictorSP leftRear;
private VictorSP rightFront; private VictorSP rightFront;
private VictorSP rightRear; private VictorSP rightRear;
@ -17,9 +18,10 @@ public class Drivetrain extends SubsystemBase {
private DifferentialDrive drive; private DifferentialDrive drive;
public Drivetrain() { public Drivetrain() {
leftFront = new VictorSP(DrivetrainConstants.kleftFrontPWN); //turns the code inputs (like how fast or how to turn) and make it a way that the motors will understand. //turns the code inputs (like how fast or how to turn) and make it a way that the motors will understand.
leftFront = new VictorSP(DrivetrainConstants.kleftFrontPWN);
leftRear = new VictorSP(DrivetrainConstants.kleftRearPWN); leftRear = new VictorSP(DrivetrainConstants.kleftRearPWN);
rightFront = new VictorSP(DrivetrainConstants.kRightfrontPWM); rightFront = new VictorSP(DrivetrainConstants.kRightFrontPWM);
rightRear = new VictorSP(DrivetrainConstants.kRightRearPWM); rightRear = new VictorSP(DrivetrainConstants.kRightRearPWM);
leftFront.addFollower(leftRear); leftFront.addFollower(leftRear);
@ -27,18 +29,18 @@ public class Drivetrain extends SubsystemBase {
rightFront.setInverted(true); rightFront.setInverted(true);
drive = new DifferentialDrive(leftFront, rightFront); drive = new DifferentialDrive(leftFront, rightFront);
} }
public Command driveArcade(DoubleSupplier xSpeed, DoubleSupplier zRotation) { public Command driveArcade(DoubleSupplier xSpeed, DoubleSupplier zRotation) {
return run(() -> { return run(() -> {
drive.arcadeDrive(xSpeed.getAsDouble(), zRotation.getAsDouble()); //makes car like steering possible //makes car like steering possible
drive.arcadeDrive(xSpeed.getAsDouble(), zRotation.getAsDouble());
}); });
} }
public Command driveTank(DoubleSupplier leftspeed, DoubleSupplier rightspeed) { public Command driveTank(DoubleSupplier leftspeed, DoubleSupplier rightspeed) {
return run (() -> { return run(() -> {
drive.tankDrive(leftspeed.getAsDouble(), rightspeed.getAsDouble()); //makes tank steering possible //makes tank steering possible
drive.tankDrive(leftspeed.getAsDouble(), rightspeed.getAsDouble());
}); });
} }

View File

@ -11,33 +11,33 @@ import frc.robot.constants.FlickerConstants;
public class Flicker extends SubsystemBase { public class Flicker extends SubsystemBase {
private VictorSP motor; private VictorSP motor;
private DigitalInput photoswitch; private DigitalInput frisbySensor;
public Flicker() { public Flicker() {
motor = new VictorSP(FlickerConstants.K3motorPWM); //sets motors and the photo switch
motor = new VictorSP(FlickerConstants.k3motorPWM);
photoswitch = new DigitalInput(FlickerConstants.Photoswitch); frisbySensor = new DigitalInput(FlickerConstants.kPhotoSwitch);
} //sets motors and the photo switch
public boolean photoswich() {
return photoswitch.get();
} //makes the photoswitch useable for the if statment
//so the code will know if the photoswitch was blocked.
public Command setSpeed(DoubleSupplier speed){
return run(() -> {
if (photoswitch.get()) {
motor.set(speed.getAsDouble());
} else {
motor.set(0);
}
//makes it so the motor will run but if the photoswitch can't see the frisby it will stop.
});
} }
public boolean frisbySensor() {
//makes the photoswitch useable for the if statment so the code will know if the photoswitch was blocked.
return frisbySensor.get();
}
public Command setSpeed(DoubleSupplier speed){
//makes it so the motor will run but if the photoswitch can't see the frisby it will stop.
return run(() -> {
if (frisbySensor.get()) {
motor.set(speed.getAsDouble());
} else {
motor.set(0);
}
});
}
public Command stop() { public Command stop() {
// stops the motor manually.
return setSpeed(() -> 0); return setSpeed(() -> 0);
} // stops the motor manually. }
} }

View File

@ -8,23 +8,27 @@ import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.constants.ShooterConstants; import frc.robot.constants.ShooterConstants;
public class Shooter extends SubsystemBase{ public class Shooter extends SubsystemBase{
//makes the motors varables
private VictorSP motor1; private VictorSP motor1;
private VictorSP motor2; //makes the motors varables private VictorSP motor2;
public Shooter() { public Shooter() {
motor1 = new VictorSP(ShooterConstants.K1motorPWM); //sets up the motors to be used in the code
motor2 = new VictorSP(ShooterConstants.K2motorPWM); motor1 = new VictorSP(ShooterConstants.K1MotorPWM);
motor2 = new VictorSP(ShooterConstants.K2MotorPWM);
motor1.addFollower(motor2); //sets motors motor1.addFollower(motor2);
} }
public Command setSpeed(DoubleSupplier speed) { public Command setSpeed(DoubleSupplier speed) {
return run(() -> { //sets the motors speed
return run(() -> {
motor1.set(speed.getAsDouble()); motor1.set(speed.getAsDouble());
}); //sets the motors speed });
} }
public Command stop() { public Command stop() {
//stops the motors
return setSpeed(() -> 0); return setSpeed(() -> 0);
} }
} //stops the motors }