Skip to content
This repository has been archived by the owner on Aug 20, 2024. It is now read-only.

Commit

Permalink
Step 3.2 and step 5
Browse files Browse the repository at this point in the history
  • Loading branch information
MasonJulian committed Aug 6, 2024
1 parent 98613e4 commit 82e55a8
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 5 deletions.
40 changes: 40 additions & 0 deletions bin/main/frc/robot/shooter/ShooterSubSystem
Original file line number Diff line number Diff line change
@@ -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;
}


}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
33 changes: 28 additions & 5 deletions src/main/java/frc/robot/Robot.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand All @@ -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
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/frc/robot/shooter/ShooterSubSystem
Original file line number Diff line number Diff line change
@@ -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;
}


}
29 changes: 29 additions & 0 deletions src/main/java/frc/robot/shooter/ShooterSubSystem.java
Original file line number Diff line number Diff line change
@@ -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'");
}

}

0 comments on commit 82e55a8

Please sign in to comment.