Added notes for flicker

This commit is contained in:
Cayden 2024-10-24 14:42:01 -04:00
parent 6e22eac86c
commit 030a9b9773
6 changed files with 87 additions and 4 deletions

View File

@ -6,4 +6,4 @@ public class DrivetrainConstants {
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

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

View File

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

View File

@ -2,10 +2,7 @@ package frc.robot.subsystems;
import java.util.function.DoubleSupplier; import java.util.function.DoubleSupplier;
import com.fasterxml.jackson.databind.ser.std.NumberSerializers.DoubleSerializer;
import edu.wpi.first.wpilibj.drive.DifferentialDrive; import edu.wpi.first.wpilibj.drive.DifferentialDrive;
import edu.wpi.first.wpilibj.motorcontrol.Victor;
import edu.wpi.first.wpilibj.motorcontrol.VictorSP; import edu.wpi.first.wpilibj.motorcontrol.VictorSP;
import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.SubsystemBase; import edu.wpi.first.wpilibj2.command.SubsystemBase;

View File

@ -0,0 +1,43 @@
package frc.robot.subsystems;
import java.util.function.DoubleSupplier;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.motorcontrol.VictorSP;
import edu.wpi.first.wpilibj2.command.Command;
import frc.robot.constants.FlickerConstants;
public class Flicker extends SubsystemBase {
private VictorSP motor;
private DigitalInput photoswitch;
public Flicker() {
motor = new VictorSP(FlickerConstants.K3motorPWM);
photoswitch = new DigitalInput(FlickerConstants.Photoswitch);
} //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 Command stop() {
return setSpeed(() -> 0);
} // stops the motor manually.
}

View File

@ -0,0 +1,30 @@
package frc.robot.subsystems;
import java.util.function.DoubleSupplier;
import edu.wpi.first.wpilibj.motorcontrol.VictorSP;
import edu.wpi.first.wpilibj2.command.Command;
import edu.wpi.first.wpilibj2.command.SubsystemBase;
import frc.robot.constants.ShooterConstants;
public class Shooter extends SubsystemBase{
private VictorSP motor1;
private VictorSP motor2; //makes the motors varables
public Shooter() {
motor1 = new VictorSP(ShooterConstants.K1motorPWM);
motor2 = new VictorSP(ShooterConstants.K2motorPWM);
motor1.addFollower(motor2); //sets motors
}
public Command setSpeed(DoubleSupplier speed) {
return run(() -> {
motor1.set(speed.getAsDouble());
}); //sets the motors speed
}
public Command stop() {
return setSpeed(() -> 0);
}
} //stops the motors