Skip to content
This repository was archived by the owner on Sep 14, 2019. It is now read-only.

Commit a22dfc2

Browse files
committed
added indvidual horizontal toggling to left and right intake
1 parent 01fa85b commit a22dfc2

5 files changed

Lines changed: 120 additions & 12 deletions

File tree

Robot2018/src/org/usfirst/frc/team199/Robot2018/OI.java

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88
package org.usfirst.frc.team199.Robot2018;
99

10+
import org.usfirst.frc.team199.Robot2018.commands.CloseIntake;
11+
import org.usfirst.frc.team199.Robot2018.commands.IntakeCube;
12+
import org.usfirst.frc.team199.Robot2018.commands.LowerIntake;
13+
import org.usfirst.frc.team199.Robot2018.commands.OpenIntake;
14+
import org.usfirst.frc.team199.Robot2018.commands.OutakeCube;
1015
import org.usfirst.frc.team199.Robot2018.commands.PIDMove;
1116
import org.usfirst.frc.team199.Robot2018.commands.PIDTurn;
1217
import org.usfirst.frc.team199.Robot2018.commands.ResetEncoders;
@@ -15,6 +20,8 @@
1520
import org.usfirst.frc.team199.Robot2018.commands.ShiftDriveType;
1621
import org.usfirst.frc.team199.Robot2018.commands.ShiftHighGear;
1722
import org.usfirst.frc.team199.Robot2018.commands.ShiftLowGear;
23+
import org.usfirst.frc.team199.Robot2018.commands.ToggleLeftIntake;
24+
import org.usfirst.frc.team199.Robot2018.commands.ToggleRightIntake;
1825
import org.usfirst.frc.team199.Robot2018.commands.UpdatePIDConstants;
1926

2027
import edu.wpi.first.wpilibj.Joystick;
@@ -50,6 +57,8 @@ public class OI {
5057
private JoystickButton lowerIntake;
5158
private JoystickButton intake;
5259
private JoystickButton outake;
60+
private JoystickButton toggleLeftIntake;
61+
private JoystickButton toggleRightIntake;
5362

5463
public int getButton(String key, int def) {
5564
if (!SmartDashboard.containsKey("Button/" + key)) {
@@ -90,22 +99,24 @@ public OI() {
9099
MoveLiftUpButton.whileHeld(new RunLift(Robot.lift, true));
91100
MoveLiftDownButton.whileHeld(new RunLift(Robot.lift, false));
92101

93-
// manipulator = new Joystick(2);
94-
// closeIntake = new JoystickButton(manipulator, getButton("Close Intake
95-
// Button", 1));
96-
// closeIntake.whenPressed(new CloseIntake());
97-
// openIntake = new JoystickButton(manipulator, getButton("Open Intake Button",
98-
// 2));
99-
// openIntake.whenPressed(new OpenIntake());
102+
manipulator = new Joystick(2);
103+
closeIntake = new JoystickButton(manipulator, getButton("Close Intake Button", 1));
104+
closeIntake.whenPressed(new CloseIntake());
105+
openIntake = new JoystickButton(manipulator, getButton("Open Intake Button", 2));
106+
openIntake.whenPressed(new OpenIntake());
100107
// raiseIntake = new JoystickButton(manipulator, getButton("Raise Intake
101108
// Button", 3));
102109
// raiseIntake.whenPressed(new RaiseIntake());
103110
// lowerIntake = new JoystickButton(manipulator, getButton("Lower Intake
104111
// Button", 4));
105-
// lowerIntake.whenPressed(new LowerIntake());
106-
// intake = new JoystickButton(manipulator, getButton("Intake Button", 5));
107-
// intake.whenPressed(new IntakeCube());
108-
// outake = new JoystickButton(manipulator, getButton("Outake Button", 6));
109-
// outake.whenPressed(new OutakeCube());
112+
lowerIntake.whenPressed(new LowerIntake());
113+
intake = new JoystickButton(manipulator, getButton("Intake Button", 5));
114+
intake.whenPressed(new IntakeCube());
115+
outake = new JoystickButton(manipulator, getButton("Outake Button", 6));
116+
outake.whenPressed(new OutakeCube());
117+
toggleLeftIntake = new JoystickButton(manipulator, getButton("Toggle Left Intake Button", 3));
118+
toggleLeftIntake.whenPressed(new ToggleLeftIntake());
119+
toggleRightIntake = new JoystickButton(manipulator, getButton("Toggle Right Intake Button", 4));
120+
toggleRightIntake.whenPressed(new ToggleRightIntake());
110121
}
111122
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.usfirst.frc.team199.Robot2018.commands;
2+
3+
import org.usfirst.frc.team199.Robot2018.Robot;
4+
5+
import edu.wpi.first.wpilibj.command.InstantCommand;
6+
7+
/**
8+
*
9+
*/
10+
public class ToggleLeftIntake extends InstantCommand {
11+
12+
public ToggleLeftIntake() {
13+
super();
14+
// Use requires() here to declare subsystem dependencies
15+
// eg. requires(chassis);
16+
requires(Robot.intakeEject);
17+
}
18+
19+
// Called once when the command executes
20+
protected void initialize() {
21+
Robot.intakeEject.toggleLeftIntake();
22+
}
23+
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package org.usfirst.frc.team199.Robot2018.commands;
2+
3+
import org.usfirst.frc.team199.Robot2018.Robot;
4+
5+
import edu.wpi.first.wpilibj.command.InstantCommand;
6+
7+
/**
8+
*
9+
*/
10+
public class ToggleRightIntake extends InstantCommand {
11+
12+
public ToggleRightIntake() {
13+
super();
14+
// Use requires() here to declare subsystem dependencies
15+
// eg. requires(chassis);
16+
requires(Robot.intakeEject);
17+
}
18+
19+
// Called once when the command executes
20+
protected void initialize() {
21+
Robot.intakeEject.toggleRightIntake();
22+
}
23+
24+
}

Robot2018/src/org/usfirst/frc/team199/Robot2018/subsystems/IntakeEject.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import edu.wpi.first.wpilibj.PowerDistributionPanel;
99
import edu.wpi.first.wpilibj.VictorSP;
1010
import edu.wpi.first.wpilibj.command.Subsystem;
11+
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
1112

1213
/**
1314
*
@@ -123,6 +124,40 @@ public void lowerIntake() {
123124
rightVerticalSolenoid.set(rightSet);
124125
}
125126

127+
/**
128+
* Toggles the left intake between open and closed
129+
*/
130+
public void toggleLeftIntake() {
131+
DoubleSolenoid.Value set;
132+
if (Robot.getBool("Bool/Left Horizontal Solenoid Open", true)) {
133+
set = Robot.getBool("Intake Left Horizontal Solenoid Inverted", false) ? DoubleSolenoid.Value.kForward
134+
: DoubleSolenoid.Value.kReverse;
135+
} else {
136+
set = Robot.getBool("Intake Left Horizontal Solenoid Inverted", false) ? DoubleSolenoid.Value.kReverse
137+
: DoubleSolenoid.Value.kForward;
138+
}
139+
leftHorizontalSolenoid.set(set);
140+
SmartDashboard.putBoolean("Bool/Left Horizontal Solenoid Open",
141+
Robot.getBool("Left Horizontal Solenoid Open", true));
142+
}
143+
144+
/**
145+
* Toggles the right intake between open and closed
146+
*/
147+
public void toggleRightIntake() {
148+
DoubleSolenoid.Value set;
149+
if (Robot.getBool("Bool/Right Horizontal Solenoid Open", true)) {
150+
set = Robot.getBool("Intake Right Horizontal Solenoid Inverted", false) ? DoubleSolenoid.Value.kForward
151+
: DoubleSolenoid.Value.kReverse;
152+
} else {
153+
set = Robot.getBool("Intake Right Horizontal Solenoid Inverted", false) ? DoubleSolenoid.Value.kReverse
154+
: DoubleSolenoid.Value.kForward;
155+
}
156+
rightHorizontalSolenoid.set(set);
157+
SmartDashboard.putBoolean("Bool/Right Horizontal Solenoid Open",
158+
Robot.getBool("right Horizontal Solenoid Open", true));
159+
}
160+
126161
/**
127162
* Opens the intake
128163
*/
@@ -133,6 +168,8 @@ public void openIntake() {
133168
DoubleSolenoid.Value rightSet = Robot.getBool("Intake Right Horizontal Solenoid Inverted", false)
134169
? DoubleSolenoid.Value.kReverse
135170
: DoubleSolenoid.Value.kForward;
171+
SmartDashboard.putBoolean("Bool/Left Horizontal Solenoid Open", true);
172+
SmartDashboard.putBoolean("Bool/Right Horizontal Solenoid Open", true);
136173
leftHorizontalSolenoid.set(leftSet);
137174
rightHorizontalSolenoid.set(rightSet);
138175
}
@@ -147,6 +184,8 @@ public void closeIntake() {
147184
DoubleSolenoid.Value rightSet = Robot.getBool("Intake Right Horizontal Solenoid Inverted", false)
148185
? DoubleSolenoid.Value.kForward
149186
: DoubleSolenoid.Value.kReverse;
187+
SmartDashboard.putBoolean("Bool/Left Horizontal Solenoid Open", false);
188+
SmartDashboard.putBoolean("Bool/Right Horizontal Solenoid Open", false);
150189
leftHorizontalSolenoid.set(leftSet);
151190
rightHorizontalSolenoid.set(rightSet);
152191
}

Robot2018/src/org/usfirst/frc/team199/Robot2018/subsystems/IntakeEjectInterface.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ public interface IntakeEjectInterface {
6464
*/
6565
public void lowerIntake();
6666

67+
/**
68+
* Toggles the left intake between open and closed
69+
*/
70+
public void toggleLeftIntake();
71+
72+
/**
73+
* Toggles the right intake between open and closed
74+
*/
75+
public void toggleRightIntake();
76+
6777
/**
6878
* Closes the intake
6979
*/

0 commit comments

Comments
 (0)