From 030a9b9773c1fa01cac8262e593a92dce7bb96a9 Mon Sep 17 00:00:00 2001 From: Cayden Date: Thu, 24 Oct 2024 14:42:01 -0400 Subject: [PATCH] Added notes for flicker --- .../robot/constants/DrivetrainConstants.java | 2 +- .../frc/robot/constants/FlickerConstants.java | 7 +++ .../frc/robot/constants/ShooterConstants.java | 6 +++ .../java/frc/robot/subsystems/Drivetrain.java | 3 -- .../java/frc/robot/subsystems/Flicker.java | 43 +++++++++++++++++++ .../java/frc/robot/subsystems/Shooter.java | 30 +++++++++++++ 6 files changed, 87 insertions(+), 4 deletions(-) diff --git a/src/main/java/frc/robot/constants/DrivetrainConstants.java b/src/main/java/frc/robot/constants/DrivetrainConstants.java index a17f768..4604d9c 100644 --- a/src/main/java/frc/robot/constants/DrivetrainConstants.java +++ b/src/main/java/frc/robot/constants/DrivetrainConstants.java @@ -6,4 +6,4 @@ public class DrivetrainConstants { public static final int kRightfrontPWM = 2; public static final int kRightRearPWM = 3; -} +} diff --git a/src/main/java/frc/robot/constants/FlickerConstants.java b/src/main/java/frc/robot/constants/FlickerConstants.java index e69de29..73f819c 100644 --- a/src/main/java/frc/robot/constants/FlickerConstants.java +++ b/src/main/java/frc/robot/constants/FlickerConstants.java @@ -0,0 +1,7 @@ +package frc.robot.constants; + +public class FlickerConstants { + public static final int K3motorPWM = 1; + + public static int Photoswitch = 1; +} diff --git a/src/main/java/frc/robot/constants/ShooterConstants.java b/src/main/java/frc/robot/constants/ShooterConstants.java index e69de29..c0a95de 100644 --- a/src/main/java/frc/robot/constants/ShooterConstants.java +++ b/src/main/java/frc/robot/constants/ShooterConstants.java @@ -0,0 +1,6 @@ +package frc.robot.constants; + +public class ShooterConstants { + public static final int K1motorPWM = 0; + public static final int K2motorPWM = 0; +} diff --git a/src/main/java/frc/robot/subsystems/Drivetrain.java b/src/main/java/frc/robot/subsystems/Drivetrain.java index b4fd249..578fd4f 100644 --- a/src/main/java/frc/robot/subsystems/Drivetrain.java +++ b/src/main/java/frc/robot/subsystems/Drivetrain.java @@ -2,10 +2,7 @@ package frc.robot.subsystems; 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.motorcontrol.Victor; import edu.wpi.first.wpilibj.motorcontrol.VictorSP; import edu.wpi.first.wpilibj2.command.Command; import edu.wpi.first.wpilibj2.command.SubsystemBase; diff --git a/src/main/java/frc/robot/subsystems/Flicker.java b/src/main/java/frc/robot/subsystems/Flicker.java index e69de29..2705432 100644 --- a/src/main/java/frc/robot/subsystems/Flicker.java +++ b/src/main/java/frc/robot/subsystems/Flicker.java @@ -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. +} diff --git a/src/main/java/frc/robot/subsystems/Shooter.java b/src/main/java/frc/robot/subsystems/Shooter.java index e69de29..79bf08b 100644 --- a/src/main/java/frc/robot/subsystems/Shooter.java +++ b/src/main/java/frc/robot/subsystems/Shooter.java @@ -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 +