Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test shooter subsystem #2

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
7 changes: 5 additions & 2 deletions src/main/java/org/wildstang/year2024/robot/CANConstants.java
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ public final class CANConstants {
//Gyro and CAN sensor values
public static final int GYRO = 31;

//swerve constants
// swerve constants
public static final int DRIVE1 = 11;
public static final int ANGLE1 = 12;
public static final int DRIVE2 = 13;
@@ -26,5 +26,8 @@ public final class CANConstants {
public static final int ANGLE3 = 16;
public static final int DRIVE4 = 17;
public static final int ANGLE4 = 18;


// shooter constants
public static final int SHOOTER1 = 23;
public static final int SHOOTER2 = 24;
}
4 changes: 3 additions & 1 deletion src/main/java/org/wildstang/year2024/robot/WsOutputs.java
Original file line number Diff line number Diff line change
@@ -26,7 +26,9 @@ public enum WsOutputs implements Outputs {
ANGLE3("Module 3 Angle Motor", new WsSparkConfig(CANConstants.ANGLE3, WsMotorControllers.SPARK_MAX_BRUSHLESS)),
DRIVE4("Module 4 Drive Motor", new WsSparkConfig(CANConstants.DRIVE4, WsMotorControllers.SPARK_FLEX_BRUSHLESS)),
ANGLE4("Module 4 Angle Motor", new WsSparkConfig(CANConstants.ANGLE4, WsMotorControllers.SPARK_MAX_BRUSHLESS)),

//these two shooters should be a SPARK_FLEX_BRUSHLESS instead of a MAX
SHOOTER1("First shooter motor", new WsSparkConfig(CANConstants.SHOOTER1, WsMotorControllers.SPARK_FLEX_BRUSHLESS)),
SHOOTER2("Second shooter motor", new WsSparkConfig(CANConstants.SHOOTER2, WsMotorControllers.SPARK_FLEX_BRUSHLESS))
// ---------------------------------
// Other Motors
// ---------------------------------
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package org.wildstang.year2024.subsystems.shooter;
import org.wildstang.framework.core.Core;
import org.wildstang.framework.io.inputs.DigitalInput;
import org.wildstang.framework.io.inputs.Input;
import org.wildstang.framework.subsystems.Subsystem;
import org.wildstang.hardware.roborio.outputs.WsSpark;
import org.wildstang.year2024.robot.WsInputs;
import org.wildstang.year2024.robot.WsOutputs;

import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;

public class Shooter implements Subsystem {
private WsSpark shooterMotor1;
private WsSpark shooterMotor2;
private double shooterSpeed = 0.5;
private DigitalInput leftBumper;
private DigitalInput dpadRight;
private DigitalInput dpadLeft;
private boolean leftBumperPressed = false;

@Override
public void inputUpdate(Input source) {
if (source == leftBumper && leftBumper.getValue()){
leftBumperPressed = true;
}
else{
leftBumperPressed = false;
}
if (source == dpadRight && dpadRight.getValue()){
shooterSpeed += 0.05;
}
if (source == dpadLeft && dpadLeft.getValue()){
shooterSpeed -= 0.05;
}
}

@Override
public void init() {
shooterMotor1 = (WsSpark) Core.getOutputManager().getOutput(WsOutputs.SHOOTER1);
shooterMotor2 = (WsSpark) Core.getOutputManager().getOutput(WsOutputs.SHOOTER2);
leftBumper = (DigitalInput) Core.getInputManager().getInput(WsInputs.DRIVER_LEFT_SHOULDER);
leftBumper.addInputListener(this);
//remember to add .addInputListener(this) for all inputs (including dpadUp and dpadDown)
dpadRight = (DigitalInput) Core.getInputManager().getInput(WsInputs.OPERATOR_DPAD_UP);
dpadRight.addInputListener(this);
dpadLeft = (DigitalInput) Core.getInputManager().getInput(WsInputs.OPERATOR_DPAD_DOWN);
dpadLeft.addInputListener(this);


}

@Override
public void selfTest() {
}

@Override
public void update() {
if (leftBumperPressed){
shooterMotor1.setSpeed(shooterSpeed);
shooterMotor2.setSpeed(shooterSpeed);
}
//you can use else instead of this
else{
shooterMotor1.setSpeed(0);
shooterMotor2.setSpeed(0);
}
SmartDashboard.putNumber("shooter speed", shooterSpeed);

}

public void setShooterSpeed(double speed){
shooterSpeed = speed;
leftBumperPressed = true;
}

@Override
public void resetState() {
}

@Override
public String getName() {
//make sure to include a name in this file
return "shooter";
}

}