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

Arms_Deployable #3

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/main/java/org/wildstang/year2023/robot/CANConstants.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.wildstang.year2023.robot;

import edu.wpi.first.wpilibj.PneumaticsModuleType;

/**
* CAN Constants are stored here.
* We primarily use CAN to communicate with Talon motor controllers.
Expand Down Expand Up @@ -30,6 +32,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 INTAKE1 = 0;



}
2 changes: 1 addition & 1 deletion src/main/java/org/wildstang/year2023/robot/WSInputs.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public enum WSInputs implements Inputs {
// ---------------------------------
// Manipulator DPAD Buttons
// ---------------------------------
MANIPULATOR_DPAD_DOWN ("Manipulator dpad down", new WsDPadButtonInputConfig(1, JoystickConstants.DPAD_Y_DOWN)),
MANIPULATOR_DPAD_DOWN ("Toggle deploy and rev intake", new WsDPadButtonInputConfig(1, JoystickConstants.DPAD_Y_DOWN)),
MANIPULATOR_DPAD_LEFT ("Manipulator dpad left", new WsDPadButtonInputConfig(1, JoystickConstants.DPAD_X_LEFT)),
MANIPULATOR_DPAD_RIGHT ("Manipulator dpad right", new WsDPadButtonInputConfig(1, JoystickConstants.DPAD_X_RIGHT)),
MANIPULATOR_DPAD_UP ("Manipulator dpad up", new WsDPadButtonInputConfig(1, JoystickConstants.DPAD_Y_UP)),
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/org/wildstang/year2023/robot/WSOutputs.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ 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)),

INTAKE1("Intake 1 Motor", new WsSparkMaxConfig(CANConstants.INTAKE1, true)),

// ---------------------------------
// Servos
Expand All @@ -57,6 +57,9 @@ public enum WSOutputs implements Outputs {
// Solenoids
// ********************************
TEST_SOLENOID("Test Solenoid", new WsSolenoidConfig(PneumaticsModuleType.REVPH, 0, false)),

DEPLOYABLE1("Deployable 1 Solenoid", new WsSolenoidConfig(PneumaticsModuleType.REVPH, 0, false)),
DEPLOYABLE2("Deployable 2 Solenoid", new WsSolenoidConfig(PneumaticsModuleType.REVPH, 0, false)),

// ********************************
// Relays
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/wildstang/year2023/robot/WSSubsystems.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.wildstang.framework.core.Subsystems;
import org.wildstang.year2023.subsystems.SampleSubsystem;
import org.wildstang.year2023.subsystems.Intake.Intake;
import org.wildstang.year2023.subsystems.swerve.SwerveDrive;
import org.wildstang.year2023.subsystems.targeting.AimHelper;

Expand All @@ -13,6 +14,7 @@ public enum WSSubsystems implements Subsystems {

// enumerate subsystems
SWERVE_DRIVE("Swerve Drive", SwerveDrive.class),
INTAKE("Intake", Intake.class),
//AIM_HELPER("Aim Helper", AimHelper.class),
//SAMPLE("Sample", SampleSubsystem.class)
;
Expand Down
104 changes: 104 additions & 0 deletions src/main/java/org/wildstang/year2023/subsystems/Intake/Intake.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package org.wildstang.year2023.subsystems.Intake;

import org.wildstang.framework.io.inputs.Input;
import org.wildstang.framework.subsystems.Subsystem;
import org.wildstang.hardware.roborio.inputs.WsJoystickButton;
import org.wildstang.hardware.roborio.outputs.WsSolenoid;
import org.wildstang.hardware.roborio.outputs.WsSparkMax;
import org.wildstang.year2023.robot.WSInputs;
import org.wildstang.year2023.robot.WSOutputs;

public class Intake implements Subsystem {

private WsSparkMax intake1;
private WsJoystickButton deployRevIntake;
private WsJoystickButton backwards;

private WsSolenoid deployable1;
private WsSolenoid deployable2;

//All variables used
private boolean intakeCall;
private boolean backCall;




@Override
public void inputUpdate(Input source) {
// TODO Auto-generated method stub

if (source == deployRevIntake){
intakeCall = !(intakeCall);

}

if (source == backwards){
backCall = !(backCall);
}
}

@Override
public void init() {
// TODO Auto-generated method stub
intake1 = (WsSparkMax) WSOutputs.INTAKE1.get();

deployRevIntake = (WsJoystickButton) WSInputs.MANIPULATOR_DPAD_DOWN.get();
deployRevIntake.addInputListener(this);
backwards = (WsJoystickButton) WSInputs.MANIPULATOR_DPAD_UP.get();

deployable1 = (WsSolenoid) WSOutputs.DEPLOYABLE1.get();
deployable2 = (WsSolenoid) WSOutputs.DEPLOYABLE2.get();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ended up being just 1 solenoid, but we can leave this for now


intakeCall = false;
backCall = false;


}

@Override
public void selfTest() {
// TODO Auto-generated method stub

}

@Override
public void update() {
// TODO Auto-generated method stub
if (intakeCall){
intake1.setValue(1);
deployable1.setValue(true);
deployable2.setValue(true);
} else {
intake1.setValue(0);
deployable1.setValue(false);
deployable2.setValue(false);
}

if (backCall){
intake1.setValue(-1);
deployable1.setValue(true);
deployable2.setValue(true);
} else {
intake1.setValue(0);
deployable1.setValue(false);
deployable2.setValue(false);
}
Comment on lines +68 to +86
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what happens when both buttons have been pressed? Should backCall always take precedent or should the last one pressed take precedent? If its the last one pressed you could use an int to store -1, 0, or 1 instead of intakeCall and backCall then having to decide which is more important

}

@Override
public void resetState() {
// TODO Auto-generated method stub
intakeCall = false;

}

@Override
public String getName() {
// TODO Auto-generated method stub
return "Intake";
}



}