fixed the formatting in all files
This commit is contained in:
parent
b084ae7f16
commit
2c4c1f24ea
@ -21,45 +21,48 @@ public class RobotContainer {
|
||||
private Drivetrain drivetrain;
|
||||
private CommandXboxController driver;
|
||||
public RobotContainer() {
|
||||
//sets up controlers
|
||||
drivetrain = new Drivetrain();
|
||||
flicker = new Flicker();
|
||||
driver = new CommandXboxController(OIConstants.kDriverUSB); //sets up controlers
|
||||
driver = new CommandXboxController(OIConstants.kDriverUSB);
|
||||
|
||||
configureBindings();
|
||||
configureShuffleboard();
|
||||
}
|
||||
|
||||
private void configureBindings() {
|
||||
//manual controls for driveing
|
||||
drivetrain.setDefaultCommand(
|
||||
drivetrain.driveArcade(
|
||||
driver::getLeftY,
|
||||
driver::getLeftX //manual controls for driveing
|
||||
driver::getLeftX
|
||||
)
|
||||
);
|
||||
flicker.setDefaultCommand(flicker.stop());
|
||||
//manual controls for shooter and flicker
|
||||
driver.a().onTrue(flicker.setSpeed(() ->1));
|
||||
|
||||
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() {
|
||||
//sets up the wiget
|
||||
ShuffleboardTab robotIndicatorTab = Shuffleboard.getTab(OIConstants.kRobotIndicatorsTabName);
|
||||
|
||||
robotIndicatorTab.addBoolean("Sensors", flicker::photoswich)
|
||||
robotIndicatorTab.addBoolean("Sensors", flicker::frisbySensor)
|
||||
.withPosition(0, 0).
|
||||
withSize(2, 1).
|
||||
withWidget(BuiltInWidgets.kBooleanBox); //sets up the wiget
|
||||
withWidget(BuiltInWidgets.kBooleanBox);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
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(
|
||||
shooter.setSpeed(()-> 1)).withTimeout(1).andThen(
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package frc.robot.constants;
|
||||
public class DrivetrainConstants {
|
||||
public static final int kleftFrontPWN = 0;
|
||||
public static final int kleftRearPWN = 1;
|
||||
public static final int kRightfrontPWM = 2;
|
||||
public static final int kRightFrontPWM = 2;
|
||||
public static final int kRightRearPWM = 3;
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package frc.robot.constants;
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package frc.robot.constants;
|
||||
|
||||
public class ShooterConstants {
|
||||
public static final int K1motorPWM = 0;
|
||||
public static final int K2motorPWM = 0;
|
||||
public static final int K1MotorPWM = 0;
|
||||
public static final int K2MotorPWM = 0;
|
||||
}
|
||||
|
@ -9,7 +9,8 @@ import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
||||
import frc.robot.constants.DrivetrainConstants;
|
||||
|
||||
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 rightFront;
|
||||
private VictorSP rightRear;
|
||||
@ -17,9 +18,10 @@ public class Drivetrain extends SubsystemBase {
|
||||
private DifferentialDrive drive;
|
||||
|
||||
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);
|
||||
rightFront = new VictorSP(DrivetrainConstants.kRightfrontPWM);
|
||||
rightFront = new VictorSP(DrivetrainConstants.kRightFrontPWM);
|
||||
rightRear = new VictorSP(DrivetrainConstants.kRightRearPWM);
|
||||
|
||||
leftFront.addFollower(leftRear);
|
||||
@ -27,18 +29,18 @@ public class Drivetrain extends SubsystemBase {
|
||||
rightFront.setInverted(true);
|
||||
|
||||
drive = new DifferentialDrive(leftFront, rightFront);
|
||||
|
||||
}
|
||||
|
||||
public Command driveArcade(DoubleSupplier xSpeed, DoubleSupplier zRotation) {
|
||||
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) {
|
||||
return run(() -> {
|
||||
drive.tankDrive(leftspeed.getAsDouble(), rightspeed.getAsDouble()); //makes tank steering possible
|
||||
//makes tank steering possible
|
||||
drive.tankDrive(leftspeed.getAsDouble(), rightspeed.getAsDouble());
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -11,33 +11,33 @@ import frc.robot.constants.FlickerConstants;
|
||||
public class Flicker extends SubsystemBase {
|
||||
private VictorSP motor;
|
||||
|
||||
private DigitalInput photoswitch;
|
||||
private DigitalInput frisbySensor;
|
||||
|
||||
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 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 (photoswitch.get()) {
|
||||
if (frisbySensor.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 Command stop() {
|
||||
// stops the motor manually.
|
||||
return setSpeed(() -> 0);
|
||||
} // stops the motor manually.
|
||||
}
|
||||
}
|
||||
|
@ -8,23 +8,27 @@ import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
||||
import frc.robot.constants.ShooterConstants;
|
||||
|
||||
public class Shooter extends SubsystemBase{
|
||||
//makes the motors varables
|
||||
private VictorSP motor1;
|
||||
private VictorSP motor2; //makes the motors varables
|
||||
private VictorSP motor2;
|
||||
|
||||
public Shooter() {
|
||||
motor1 = new VictorSP(ShooterConstants.K1motorPWM);
|
||||
motor2 = new VictorSP(ShooterConstants.K2motorPWM);
|
||||
//sets up the motors to be used in the code
|
||||
motor1 = new VictorSP(ShooterConstants.K1MotorPWM);
|
||||
motor2 = new VictorSP(ShooterConstants.K2MotorPWM);
|
||||
|
||||
motor1.addFollower(motor2); //sets motors
|
||||
motor1.addFollower(motor2);
|
||||
}
|
||||
|
||||
public Command setSpeed(DoubleSupplier speed) {
|
||||
//sets the motors speed
|
||||
return run(() -> {
|
||||
motor1.set(speed.getAsDouble());
|
||||
}); //sets the motors speed
|
||||
});
|
||||
}
|
||||
public Command stop() {
|
||||
//stops the motors
|
||||
return setSpeed(() -> 0);
|
||||
}
|
||||
} //stops the motors
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user