diff --git a/src/main/java/org/wildstang/year2023/robot/CANConstants.java b/src/main/java/org/wildstang/year2023/robot/CANConstants.java index 6dbf8c98..3dff33ca 100644 --- a/src/main/java/org/wildstang/year2023/robot/CANConstants.java +++ b/src/main/java/org/wildstang/year2023/robot/CANConstants.java @@ -30,6 +30,8 @@ public final class CANConstants { public static final int ANGLE3 = 16; public static final int DRIVE4 = 17; public static final int ANGLE4 = 18; + public static final int EVERYBOT1 = 0; + public static final int EBOT2 = 0; } \ No newline at end of file diff --git a/src/main/java/org/wildstang/year2023/robot/WSOutputs.java b/src/main/java/org/wildstang/year2023/robot/WSOutputs.java index ae05c776..a35bb178 100644 --- a/src/main/java/org/wildstang/year2023/robot/WSOutputs.java +++ b/src/main/java/org/wildstang/year2023/robot/WSOutputs.java @@ -41,6 +41,8 @@ public enum WSOutputs implements Outputs { ANGLE3("Module 3 Angle Motor", new WsSparkMaxConfig(CANConstants.ANGLE3, true)), DRIVE4("Module 4 Drive Motor", new WsSparkMaxConfig(CANConstants.DRIVE4, true)), ANGLE4("Module 4 Angle Motor", new WsSparkMaxConfig(CANConstants.ANGLE4, true)), + EVERYBOT1("Module 4 Angle Motor", new WsSparkMaxConfig(CANConstants.EVERYBOT1, true)), + EBOT2("Module 4 Angle Motor", new WsSparkMaxConfig(CANConstants.EBOT2, true)), // --------------------------------- diff --git a/src/main/java/org/wildstang/year2023/robot/WSSubsystems.java b/src/main/java/org/wildstang/year2023/robot/WSSubsystems.java index 8c9f3ec4..3d7e71ba 100644 --- a/src/main/java/org/wildstang/year2023/robot/WSSubsystems.java +++ b/src/main/java/org/wildstang/year2023/robot/WSSubsystems.java @@ -1,6 +1,7 @@ package org.wildstang.year2023.robot; import org.wildstang.framework.core.Subsystems; +import org.wildstang.year2023.subsystems.Claw; import org.wildstang.year2023.subsystems.SampleSubsystem; import org.wildstang.year2023.subsystems.swerve.SwerveDrive; import org.wildstang.year2023.subsystems.targeting.AimHelper; @@ -13,6 +14,7 @@ public enum WSSubsystems implements Subsystems { // enumerate subsystems SWERVE_DRIVE("Swerve Drive", SwerveDrive.class), + CLAW("Claw", Claw.class), //AIM_HELPER("Aim Helper", AimHelper.class), //SAMPLE("Sample", SampleSubsystem.class) ; diff --git a/src/main/java/org/wildstang/year2023/subsystems/ArmEverybot.java b/src/main/java/org/wildstang/year2023/subsystems/ArmEverybot.java new file mode 100644 index 00000000..eb1d4fb8 --- /dev/null +++ b/src/main/java/org/wildstang/year2023/subsystems/ArmEverybot.java @@ -0,0 +1,121 @@ +package org.wildstang.year2023.subsystems; + +import org.apache.commons.math3.ml.neuralnet.twod.NeuronSquareMesh2D.VerticalDirection; +import org.wildstang.framework.io.inputs.Input; +import org.wildstang.framework.subsystems.Subsystem; +import org.wildstang.hardware.roborio.inputs.WsDPadButton; +import org.wildstang.hardware.roborio.inputs.WsJoystickAxis; +import org.wildstang.hardware.roborio.outputs.WsSparkMax; +import org.wildstang.year2023.robot.WSAutoPrograms; +import org.wildstang.year2023.robot.WSInputs; +import org.wildstang.year2023.robot.WSOutputs; + +public class ArmEverybot implements Subsystem +{ + WsSparkMax m1; + WsSparkMax m2; + WsJoystickAxis lefttrigger; + WsJoystickAxis righttrigger; + WsDPadButton dPadButton1; + WsDPadButton dPadButton2; + double mSpeed; + double mSpeed2; + + + @Override + public void inputUpdate(Input sourceInput) { + if (sourceInput == lefttrigger || sourceInput == righttrigger){ + if (sourceInput == lefttrigger) { + if (Math.abs(lefttrigger.getValue()) > 0.3){ + mSpeed = -0.8; + } + else { + mSpeed = 0; + } + } + else if (sourceInput == righttrigger) +{ + if (Math.abs(righttrigger.getValue()) > 0.3){ + mSpeed = 0.8; + } + else { + mSpeed = 0; + }; + if (sourceInput == dPadButton1){ + if (dPadButton1.getValue()){ + mSpeed2 = 0.8; + } + if (sourceInput == dPadButton2){ + if (dPadButton2.getValue()){ + mSpeed2 = 0.8; + } + } + } + else { + + } + + } + } +} // TODO Auto-generated method stub + + + + @Override + public void init() { + // TODO Auto-generated method stub + lefttrigger = (WsJoystickAxis) WSInputs.MANIPULATOR_LEFT_JOYSTICK_BUTTON.get(); + righttrigger = (WsJoystickAxis) WSInputs.MANIPULATOR_RIGHT_JOYSTICK_BUTTON.get(); + lefttrigger.addInputListener(this); + righttrigger.addInputListener(this); + m1 = (WsSparkMax) WSOutputs.TEST_MOTOR.get(); + m2 = (WsSparkMax) WSOutputs.TEST_MOTOR2.get(); + mSpeed = 0; + dPadButton1 = (WsDPadButton) WSInputs.MANIPULATOR_DPAD_UP.get(); + dPadButton2 = (WsDPadButton) WSInputs.MANIPULATOR_DPAD_DOWN.get(); + dPadButton1.addInputListener(this); + dPadButton2.addInputListener(this); + mSpeed2 = 0; + } + + @Override + public void selfTest() { + // TODO Auto-generated method stub + + }; + @Override + public void update() { + // TODO Auto-generated method stub + m1.setValue(mSpeed); + if (mSpeed == 0){ + m1.setBrake(); + } + else { + m1.setCoast(); + } + m2.setValue(mSpeed2); + if (mSpeed2 == 0) { + m2.setBrake(); + } + else { + m2.setCoast(); + } + }; + + + @Override + public void resetState() { + // TODO Auto-generated method stub + + } + + @Override + public String getName() { + // TODO Auto-generated method stub + return null; + }; + //The controls would be LT to intake cargo, RT to score cargo, LB to intake + + //cones, RB to score cones, and Dpad up and down to raise and lower the arm +} + diff --git a/src/main/java/org/wildstang/year2023/subsystems/Claw.java b/src/main/java/org/wildstang/year2023/subsystems/Claw.java new file mode 100644 index 00000000..9bd2163d --- /dev/null +++ b/src/main/java/org/wildstang/year2023/subsystems/Claw.java @@ -0,0 +1,61 @@ +package org.wildstang.year2023.subsystems; +import org.wildstang.framework.io.inputs.Input; +import org.wildstang.framework.subsystems.Subsystem; +import org.wildstang.hardware.roborio.inputs.WsJoystickAxis; +import org.wildstang.hardware.roborio.outputs.WsSparkMax; +import org.wildstang.year2023.robot.WSInputs; +import org.wildstang.year2023.robot.WSOutputs; + +public class Claw implements Subsystem +{ + WsSparkMax motor; + WsJoystickAxis forwardButton; + WsJoystickAxis reverseButton; + double motorSpeed; + + + @Override + public void init(){ + forwardButton = (WsJoystickAxis) WSInputs.MANIPULATOR_LEFT_TRIGGER.get(); + reverseButton = (WsJoystickAxis) WSInputs.MANIPULATOR_RIGHT_TRIGGER.get(); + forwardButton.addInputListener(this); + reverseButton.addInputListener(this); + motor = (WsSparkMax) WSOutputs.TEST_MOTOR.get(); + motorSpeed = 0; + }; + @Override + public void resetState(){}; + @Override + public void update(){ + motor.setValue(motorSpeed); + if (motorSpeed == 0){ + motor.setBrake(); + } + else { + motor.setCoast(); + } + }; + @Override + public void inputUpdate(Input sourceInput){ + if (sourceInput == forwardButton){ + if (Math.abs(forwardButton.getValue())> 0.3){ + motorSpeed = 0.8; + } + else { + motorSpeed = 0; + } + } + else if (sourceInput == reverseButton){ + if (Math.abs(reverseButton.getValue()) < 0.3){ + motorSpeed = -0.8; + } + else { + motorSpeed = 0; + } + } + } + @Override + public void selfTest(){}; + @Override + public String getName(){return "Claw";}; +} \ No newline at end of file diff --git a/src/main/java/org/wildstang/year2023/subsystems/TankDriveEverybot.java b/src/main/java/org/wildstang/year2023/subsystems/TankDriveEverybot.java new file mode 100644 index 00000000..735aaa04 --- /dev/null +++ b/src/main/java/org/wildstang/year2023/subsystems/TankDriveEverybot.java @@ -0,0 +1,84 @@ +package org.wildstang.year2023.subsystems; +import org.wildstang.framework.io.inputs.Input; +import org.wildstang.framework.subsystems.Subsystem; +import org.wildstang.hardware.roborio.inputs.WsJoystickAxis; +import org.wildstang.hardware.roborio.outputs.WsSparkMax; +import org.wildstang.year2023.robot.WSInputs; +import org.wildstang.year2023.robot.WSOutputs; + +public class TankDriveEverybot implements Subsystem +{ + WsSparkMax motor; + WsSparkMax motor2; + WsJoystickAxis forwardTrigger; + WsJoystickAxis backTrigger; + double motorSpeed; + @Override + public void inputUpdate(Input sourceInput) { + // TODO Auto-generated method stub + if (sourceInput == forwardTrigger || sourceInput == backTrigger){ + if (sourceInput == forwardTrigger){ + if (Math.abs(forwardTrigger.getValue()) > 0.2){ + motorSpeed = 0.8; + } + else { + motorSpeed = 0; + }} + + else if (sourceInput == backTrigger){ + if (Math.abs(backTrigger.getValue()) > 0.2){ + motorSpeed = -0.8; + } + else { + motorSpeed = 0; + } + } + } + } + @Override + public void init() { + // TODO Auto-generated method stub + forwardTrigger = (WsJoystickAxis) WSInputs.MANIPULATOR_RIGHT_TRIGGER.get(); + backTrigger = (WsJoystickAxis) WSInputs.MANIPULATOR_LEFT_TRIGGER.get(); + forwardTrigger.addInputListener(this); + backTrigger.addInputListener(this); + motor = (WsSparkMax) WSOutputs.TEST_MOTOR.get(); + motor2 = (WsSparkMax) WSOutputs.TEST_MOTOR2.get(); + motorSpeed = 0; + } + @Override + public void selfTest() { + // TODO Auto-generated method stub + + } + @Override + public void update() { + // TODO Auto-generated method stub + motor.setValue(motorSpeed); + if (motorSpeed == motor.getValue() || motorSpeed == motor2.getValue()){ + if (motorSpeed == 0){ + motor.setBrake(); + } + else { + motor.setCoast(); + } + if (motorSpeed == 0){ + motor2.setBrake(); + } + else { + motor.setCoast(); + } + } + }; + @Override + public void resetState() { + // TODO Auto-generated method stub + + } + @Override + public String getName() { + // TODO Auto-generated method stub + return null; + } + +}