diff --git a/src/main/java/frc4388/robot/Constants.java b/src/main/java/frc4388/robot/Constants.java index 3c0d27c..525b6a7 100644 --- a/src/main/java/frc4388/robot/Constants.java +++ b/src/main/java/frc4388/robot/Constants.java @@ -34,7 +34,7 @@ public final class Constants { public static final double CORRECTION_MIN = 10; public static final double CORRECTION_MAX = 50; - public static final double[] GEARS = {0.25, 0.5, 1.0}; + public static final double[] GEARS = {0.05, 0.25, 0.5, 1.0}; public static final double SLOW_SPEED = 0.25; public static final double FAST_SPEED = 0.5; @@ -146,7 +146,6 @@ public final class Constants { public static final double LEFT_AXIS_DEADBAND = 0.1; } - public static final class IntakeConstants { public static final class IDs{ public static final int PIVOTMOTOR_ID = 17; @@ -158,4 +157,10 @@ public final class Constants { public static final double INTAKE_SPEED= 0.0; public static final double OUTTAKE_SPEED= 0.0; } + public static final class ShooterConstants + { + public static final int LEFT_SHOOTER_ID = 15; + public static final int RIGHT_SHOOTER_ID = 16; + public static final double SHOOTER_SPEED = 0.50; + } } diff --git a/src/main/java/frc4388/robot/RobotContainer.java b/src/main/java/frc4388/robot/RobotContainer.java index 55e1c47..262f48c 100644 --- a/src/main/java/frc4388/robot/RobotContainer.java +++ b/src/main/java/frc4388/robot/RobotContainer.java @@ -28,6 +28,8 @@ import frc4388.robot.commands.Swerve.neoJoystickPlayback; import frc4388.robot.commands.Swerve.neoJoystickRecorder; import frc4388.robot.subsystems.Intake; // Subsystems +import frc4388.robot.subsystems.Shooter; + // import frc4388.robot.subsystems.LED; import frc4388.robot.subsystems.SwerveDrive; @@ -47,6 +49,7 @@ public class RobotContainer { public final RobotMap m_robotMap = new RobotMap(); /* Subsystems */ + public final Shooter m_robotShooter = new Shooter(m_robotMap.leftShooter, m_robotMap.rightShooter); // private final LED m_robotLED = new LED(); public final Intake m_robotIntake= new Intake(m_robotMap.pivotArm, m_robotMap.intakeWheel); public final SwerveDrive m_robotSwerveDrive = new SwerveDrive(m_robotMap.leftFront, @@ -152,7 +155,7 @@ public class RobotContainer { .onTrue(new InstantCommand(() -> m_robotSwerveDrive.shiftUpRot())); // ? /* Operator Buttons */ - + /*Intake */ DualJoystickButton(getDeadbandedDriverController(), getVirtualOperatorController(), XboxController.RIGHT_BUMPER_BUTTON) .onTrue(new SequentialCommandGroup( @@ -167,6 +170,13 @@ public class RobotContainer { DualJoystickButton(getDeadbandedOperatorController(), getVirtualOperatorController(), XboxController.A_BUTTON) .onTrue(new InstantCommand(()->m_robotIntake.handoff())) .onFalse(new InstantCommand(()-> m_robotIntake.stopIntakeMotor())); + + /*Shooter*/ + + new JoystickButton(getDeadbandedOperatorController(), XboxController.LEFT_BUMPER_BUTTON) + .onTrue(new InstantCommand(() -> m_robotShooter.spin())) + .onFalse(new InstantCommand(() -> m_robotShooter.stop())); + // ? /* Programer Buttons (Controller 3)*/ // * /* Auto Recording */ diff --git a/src/main/java/frc4388/robot/RobotMap.java b/src/main/java/frc4388/robot/RobotMap.java index 143d77c..a3d9e45 100644 --- a/src/main/java/frc4388/robot/RobotMap.java +++ b/src/main/java/frc4388/robot/RobotMap.java @@ -12,6 +12,7 @@ import com.ctre.phoenix6.hardware.CANcoder; import com.ctre.phoenix6.hardware.Pigeon2; import frc4388.robot.Constants.IntakeConstants; +import frc4388.robot.Constants.ShooterConstants; // import edu.wpi.first.wpilibj.motorcontrol.Spark; // import frc4388.robot.Constants.LEDConstants; import frc4388.robot.Constants.SwerveDriveConstants; @@ -59,6 +60,11 @@ public class RobotMap { public final TalonFX pivotArm = new TalonFX(IntakeConstants.IDs.PIVOTMOTOR_ID); public final TalonFX intakeWheel = new TalonFX(IntakeConstants.IDs.INTAKEMOTOR_ID); + /* Shooter Subsystem */ + public final TalonFX leftShooter = new TalonFX(ShooterConstants.LEFT_SHOOTER_ID); + public final TalonFX rightShooter = new TalonFX(ShooterConstants.RIGHT_SHOOTER_ID); + + void configureDriveMotorControllers() { // initialize SwerveModules this.rightFront = new SwerveModule(rightFrontWheel, rightFrontSteer, rightFrontEncoder, SwerveDriveConstants.DefaultSwerveRotOffsets.FRONT_RIGHT_ROT_OFFSET); diff --git a/src/main/java/frc4388/robot/subsystems/Shooter.java b/src/main/java/frc4388/robot/subsystems/Shooter.java new file mode 100644 index 0000000..98d39a0 --- /dev/null +++ b/src/main/java/frc4388/robot/subsystems/Shooter.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 frc4388.robot.subsystems; + +import edu.wpi.first.wpilibj2.command.SubsystemBase; +import frc4388.robot.Constants.ShooterConstants; + +import com.ctre.phoenix6.hardware.TalonFX; +import com.ctre.phoenix6.signals.NeutralModeValue; + +public class Shooter extends SubsystemBase { + private TalonFX leftShooter; + private TalonFX rightShooter; + /** Creates a new Shooter. */ + public Shooter(TalonFX leftShooterMotor, TalonFX rightShooterMotor) { + leftShooter = leftShooterMotor; + rightShooter = rightShooterMotor; + + leftShooter.setNeutralMode(NeutralModeValue.Coast); + rightShooter.setNeutralMode(NeutralModeValue.Coast); + } + + public void spin(double speed) { + leftShooter.set(speed); + rightShooter.set(speed); + } + + public void spin() { + spin(ShooterConstants.SHOOTER_SPEED); + } + + public void stop() { + spin(0); + } + + + @Override + public void periodic() { + // This method will be called once per scheduler run + } +}