diff --git a/bin/main/frc/robot/shooter/ShooterSubSystem b/bin/main/frc/robot/shooter/ShooterSubSystem new file mode 100644 index 0000000..1c06167 --- /dev/null +++ b/bin/main/frc/robot/shooter/ShooterSubSystem @@ -0,0 +1,40 @@ +package frc.robot.shooter; + +import com.revrobotics.CANSparkMax; + +import frc.robot.util.scheduling.LifecycleSubsystem; +import frc.robot.util.scheduling.SubsystemPriority; + +public class ShooterSubSystem extends LifecycleSubsystem{ + private final CANSparkMax motor; + + private boolean intaking = false; + private boolean shooting = false; + + public ShooterSubSystem(CANSparkMax motor) { + super(SubsystemPriority.SHOOTER); + this.motor = motor; + } + + @Override + public void robotPeriodic() { + if (intaking) { + motor.set(0.3); + } else if (shooting){ + motor.set(-0.5); + } + else { + motor.set(0.0); + } + } + + public void setIntakeMode (boolean intake) { + this.intaking = intake; + } + + public void setShootingMode (boolean shoot) { + this.shooting = shoot; + } + + +} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index d64cd49..2c35211 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/src/main/java/frc/robot/Robot.java b/src/main/java/frc/robot/Robot.java index 5cf3aae..2879120 100644 --- a/src/main/java/frc/robot/Robot.java +++ b/src/main/java/frc/robot/Robot.java @@ -6,11 +6,15 @@ import com.revrobotics.CANSparkLowLevel; import com.revrobotics.CANSparkMax; + +import edu.wpi.first.math.proto.Controller; import edu.wpi.first.wpilibj.TimedRobot; import edu.wpi.first.wpilibj.XboxController; import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; import edu.wpi.first.wpilibj2.command.CommandScheduler; +import edu.wpi.first.wpilibj2.command.Commands; import frc.robot.Queuer.QueuerSubsystem; +import frc.robot.shooter.ShooterSubSystem; import frc.robot.util.scheduling.LifecycleSubsystemManager; public class Robot extends TimedRobot { @@ -32,6 +36,8 @@ public void robotInit() {} private CANSparkMax motor = new CANSparkMax(10, CANSparkLowLevel.MotorType.kBrushless); private XboxController driver = new XboxController(0); + private QueuerSubsystem queuer = new QueuerSubsystem(motor); + private ShooterSubSystem shooter = new ShooterSubSystem(motor); // TODO: Create an xbox controller for id 0 @Override @@ -48,15 +54,32 @@ public void robotPeriodic() { if (driver.getLeftTriggerAxis() > 0.5) { queuer.setIntakeMode(true); } - + else if (driver.getLeftTriggerAxis() < 0.5) { + queuer.setIntakeMode(false); + } if (driver.getRightTriggerAxis() > 0.5) { - queuer.setShootingMode(true); + shooter.setShootingMode(true); + } + else if (driver.getRightTriggerAxis() < 0.5) { + shooter.setShootingMode(false); } - - } - private QueuerSubsystem queuer = new QueuerSubsystem(motor); + Controller + .leftTrigger() + .onTrue{shooter.setIntakeCommand(true) + .with(queuer.setIntakeCommand(true))}; + .onFalse{shooter.setIntakeCommand(false) + .with(queuer.setIntakeCommand(false))}; + + Controller + .rightTrigger() + .onTrue{shooter.setShootingCommand(true) + .then(Commands.waitSeconds(1)) + .with(queuer.setShootingCommand(true)) + .then(Commands.waitSeconds(3)) + .with(shooter.setShootingCommand(false)) + .with(queuer.setShootingCommand(false))}; @Override diff --git a/src/main/java/frc/robot/shooter/ShooterSubSystem b/src/main/java/frc/robot/shooter/ShooterSubSystem new file mode 100644 index 0000000..1c06167 --- /dev/null +++ b/src/main/java/frc/robot/shooter/ShooterSubSystem @@ -0,0 +1,40 @@ +package frc.robot.shooter; + +import com.revrobotics.CANSparkMax; + +import frc.robot.util.scheduling.LifecycleSubsystem; +import frc.robot.util.scheduling.SubsystemPriority; + +public class ShooterSubSystem extends LifecycleSubsystem{ + private final CANSparkMax motor; + + private boolean intaking = false; + private boolean shooting = false; + + public ShooterSubSystem(CANSparkMax motor) { + super(SubsystemPriority.SHOOTER); + this.motor = motor; + } + + @Override + public void robotPeriodic() { + if (intaking) { + motor.set(0.3); + } else if (shooting){ + motor.set(-0.5); + } + else { + motor.set(0.0); + } + } + + public void setIntakeMode (boolean intake) { + this.intaking = intake; + } + + public void setShootingMode (boolean shoot) { + this.shooting = shoot; + } + + +} diff --git a/src/main/java/frc/robot/shooter/ShooterSubSystem.java b/src/main/java/frc/robot/shooter/ShooterSubSystem.java new file mode 100644 index 0000000..e65af0c --- /dev/null +++ b/src/main/java/frc/robot/shooter/ShooterSubSystem.java @@ -0,0 +1,29 @@ +package frc.robot.shooter; + +import com.revrobotics.CANSparkMax; + +public class ShooterSubSystem { + + public static final String setIntakeCommand = null; + public final String setShootingCommand = null; + + public ShooterSubSystem(CANSparkMax motor) { + //TODO Auto-generated constructor stub + } + + public void setShootingMode(boolean b) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'setShootingMode'"); + } + + public Object setIntakeCommand(boolean b) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'setIntakeCommand'"); + } + + public void setShootingCommand(boolean b) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'setShootingCommand'"); + } + +}