diff --git a/src/main/java/frc/robot/Constants.java b/src/main/java/frc/robot/Constants.java index 6263822..d856cd2 100644 --- a/src/main/java/frc/robot/Constants.java +++ b/src/main/java/frc/robot/Constants.java @@ -304,4 +304,10 @@ public static class CollectingConstants{ public static final int SwitchID=1; public static final int CollectingMotorID=10; } + public static class FeederConstants{ + + public static final int FeederMotorId = 3; + public static final double FeederMotorSpeed = 0.8; + + } } diff --git a/src/main/java/frc/robot/commands/CollectingCommands/setSpeedUntilFeedCommand.java b/src/main/java/frc/robot/commands/CollectingCommands/setSpeedUntilFeedCommand.java index c4e2b31..8cc99fc 100644 --- a/src/main/java/frc/robot/commands/CollectingCommands/setSpeedUntilFeedCommand.java +++ b/src/main/java/frc/robot/commands/CollectingCommands/setSpeedUntilFeedCommand.java @@ -5,7 +5,6 @@ package frc.robot.commands.CollectingCommands; import edu.wpi.first.wpilibj2.command.Command; -import frc.robot.Constants.CollectingConstants; import frc.robot.subsystems.CollectingSubsystem; public class setSpeedUntilFeedCommand extends Command { diff --git a/src/main/java/frc/robot/commands/feederCommands/FeedShooter.java b/src/main/java/frc/robot/commands/feederCommands/FeedShooter.java new file mode 100644 index 0000000..072a251 --- /dev/null +++ b/src/main/java/frc/robot/commands/feederCommands/FeedShooter.java @@ -0,0 +1,30 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package frc.robot.commands.feederCommands; + +import edu.wpi.first.wpilibj2.command.InstantCommand; + +import frc.robot.subsystems.FeederSubsystem; + +import frc.robot.Constants.FeederConstants;; + +public class FeedShooter extends InstantCommand { + + // feeder subsystem + private FeederSubsystem feeder = FeederSubsystem.getInstance(); + + // constructor + public FeedShooter() { + addRequirements(feeder); + } + + // Called when the command is initially scheduled. + @Override + public void initialize() { + // set speed to motor + feeder.setSpeed(FeederConstants.FeederMotorSpeed); + + } +} diff --git a/src/main/java/frc/robot/commands/feederCommands/FeederSetSpeed.java b/src/main/java/frc/robot/commands/feederCommands/FeederSetSpeed.java new file mode 100644 index 0000000..ef165fd --- /dev/null +++ b/src/main/java/frc/robot/commands/feederCommands/FeederSetSpeed.java @@ -0,0 +1,27 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package frc.robot.commands.feederCommands; + +import edu.wpi.first.wpilibj2.command.InstantCommand; +import frc.robot.subsystems.FeederSubsystem; + +public class FeederSetSpeed extends InstantCommand { + // variables + private FeederSubsystem feeder = FeederSubsystem.getInstance();// feeder subsystem + double speed; + + // constructor + public FeederSetSpeed(double speed) { + addRequirements(feeder); + this.speed = speed; + } + + // Called when the command is initially scheduled. + @Override + public void initialize() { + // set speed to motor + feeder.setSpeed(speed); + } +} diff --git a/src/main/java/frc/robot/subsystems/CollectingSubsystem.java b/src/main/java/frc/robot/subsystems/CollectingSubsystem.java index 47c5091..cbc788b 100644 --- a/src/main/java/frc/robot/subsystems/CollectingSubsystem.java +++ b/src/main/java/frc/robot/subsystems/CollectingSubsystem.java @@ -6,8 +6,6 @@ import com.ctre.phoenix.motorcontrol.ControlMode; import com.ctre.phoenix.motorcontrol.can.TalonSRX; -import com.ctre.phoenix6.hardware.TalonFX; - import edu.wpi.first.wpilibj.DigitalInput; import edu.wpi.first.wpilibj2.command.SubsystemBase; diff --git a/src/main/java/frc/robot/subsystems/FeederSubsystem.java b/src/main/java/frc/robot/subsystems/FeederSubsystem.java new file mode 100644 index 0000000..2e04c7f --- /dev/null +++ b/src/main/java/frc/robot/subsystems/FeederSubsystem.java @@ -0,0 +1,43 @@ +// Copyright (c) FIRST and other WPILib contributors. +// Open Source Software; you can modify and/or share it under the terms of +// the WPILib BSD license file in the root directory of this project. + +package frc.robot.subsystems; + +import com.ctre.phoenix.motorcontrol.ControlMode; +import com.ctre.phoenix.motorcontrol.can.TalonSRX; +import edu.wpi.first.wpilibj2.command.SubsystemBase; + +import static frc.robot.Constants.FeederConstants.*; + +public class FeederSubsystem extends SubsystemBase { + /** Creates a new FeederSubsystem. */ + + //the feeder's motor + TalonSRX m_Feeder; + + //constructor + private FeederSubsystem(){ + m_Feeder = new TalonSRX(FeederMotorId); + } + + // singelton + private static FeederSubsystem instance; + + public static FeederSubsystem getInstance() { + if (instance == null) { + instance = new FeederSubsystem(); + } + return instance; + } + + // set speed function + public void setSpeed(double motorSpeed){ + m_Feeder.set(ControlMode.PercentOutput, motorSpeed); + } + + @Override + public void periodic() { + // This method will be called once per scheduler run + } +}