Added notes for flicker
This commit is contained in:
parent
6e22eac86c
commit
030a9b9773
@ -0,0 +1,7 @@
|
|||||||
|
package frc.robot.constants;
|
||||||
|
|
||||||
|
public class FlickerConstants {
|
||||||
|
public static final int K3motorPWM = 1;
|
||||||
|
|
||||||
|
public static int Photoswitch = 1;
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
package frc.robot.constants;
|
||||||
|
|
||||||
|
public class ShooterConstants {
|
||||||
|
public static final int K1motorPWM = 0;
|
||||||
|
public static final int K2motorPWM = 0;
|
||||||
|
}
|
@ -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;
|
||||||
|
@ -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.
|
||||||
|
}
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user