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

Commit 2979aee

Browse files
authored
Merge pull request #69 from doawelul/master
add more functionality to intakeEject
2 parents 0cf1806 + b2cc9ff commit 2979aee

File tree

9 files changed

+83
-168
lines changed

9 files changed

+83
-168
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ public OI(Robot robot) {
107107

108108
manipulator = new Joystick(2);
109109
if (manipulator.getButtonCount() == 0) {
110-
System.out.println("Manipulator not plugged in!");
110+
System.err.println(
111+
"ERROR: manipulator does not appear to be plugged in. Disabling intake code. Restart code with manipulator plugged in to enable intake code");
111112
} else {
112113
closeIntakeButton = new JoystickButton(manipulator, getButton("Close Intake Button", 1));
113114
closeIntakeButton.whenPressed(new CloseIntake());
@@ -128,6 +129,7 @@ public OI(Robot robot) {
128129
toggleRightIntakeButton = new JoystickButton(manipulator, getButton("Toggle Right Intake Button", 4));
129130
toggleRightIntakeButton.whenPressed(new ToggleRightIntake());
130131
}
132+
131133
}
132134

133135
// /**

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,8 @@ public class RobotMap {
4343

4444
public static VictorSP leftIntakeMotor;
4545
public static VictorSP rightIntakeMotor;
46-
public static DoubleSolenoid leftIntakeVerticalSolenoid;
47-
public static DoubleSolenoid rightIntakeVerticalSolenoid;
48-
public static DoubleSolenoid leftIntakeHorizontalSolenoid;
49-
public static DoubleSolenoid rightIntakeHorizontalSolenoid;
46+
public static DoubleSolenoid leftIntakeSolenoid;
47+
public static DoubleSolenoid rightIntakeSolenoid;
5048

5149
public static DigitalSource leftEncPort1;
5250
public static DigitalSource leftEncPort2;
@@ -129,16 +127,10 @@ public RobotMap() {
129127

130128
leftIntakeMotor = new VictorSP(getPort("IntakeLeftVictorSP", 8));
131129
rightIntakeMotor = new VictorSP(getPort("IntakeRightVictorSP", 9));
132-
leftIntakeHorizontalSolenoid = new DoubleSolenoid(getPort("IntakeLeftHorizontalSolenoidPort1", 4),
130+
leftIntakeSolenoid = new DoubleSolenoid(getPort("IntakeLeftHorizontalSolenoidPort1", 4),
133131
getPort("IntakeLeftHorizontalSolenoidPort2", 5));
134-
rightIntakeHorizontalSolenoid = new DoubleSolenoid(getPort("IntakeRightHorizontalSolenoidPort1", 2),
132+
rightIntakeSolenoid = new DoubleSolenoid(getPort("IntakeRightHorizontalSolenoidPort1", 2),
135133
getPort("IntakeRightHorizontalSolenoidPort2", 3));
136-
// leftIntakeVerticalSolenoid = new
137-
// DoubleSolenoid(getPort("IntakeLeftVerticalSolenoidPort1", 6),
138-
// getPort("IntakeLeftVerticalSolenoidPort2", 7));
139-
// rightIntakeVerticalSolenoid = new
140-
// DoubleSolenoid(getPort("IntakeRightVerticalSolenoidPort1", 8),
141-
// getPort("IntakeRightVerticalSolenoidPort2", 9));
142134

143135
leftEncPort1 = new DigitalInput(getPort("1LeftEnc", 2));
144136
leftEncPort2 = new DigitalInput(getPort("2LeftEnc", 3));

Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/AutoMoveTo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ public AutoMoveTo(String[] args, DrivetrainInterface dt, SmartDashboardInterface
3939
public AutoMoveTo(String[] args) {
4040
this(args, Robot.dt, Robot.sd, Robot.dt.getDistEncAvg(), Robot.dt.getGyro());
4141
}
42-
}
42+
}

Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/LowerIntake.java

Lines changed: 0 additions & 25 deletions
This file was deleted.

Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/PIDMove.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,4 +215,4 @@ public void pidWrite(double output) {
215215
dt.arcadeDrive(output, 0);
216216
sd.putNumber("Move PID Output", output);
217217
}
218-
}
218+
}

Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/PIDTurn.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,4 +287,4 @@ public void pidWrite(double output) {
287287
private double getDistanceBetweenWheels() {
288288
return sd.getConst("Distance Between Wheels", 26.25);
289289
}
290-
}
290+
}

Robot2018/src/org/usfirst/frc/team199/Robot2018/commands/RaiseIntake.java

Lines changed: 0 additions & 25 deletions
This file was deleted.

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

Lines changed: 73 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
import edu.wpi.first.wpilibj.DoubleSolenoid;
88
import edu.wpi.first.wpilibj.PowerDistributionPanel;
9+
import edu.wpi.first.wpilibj.Preferences;
910
import edu.wpi.first.wpilibj.VictorSP;
1011
import edu.wpi.first.wpilibj.command.Subsystem;
11-
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
1212

1313
/**
1414
*
@@ -17,12 +17,20 @@ public class IntakeEject extends Subsystem implements IntakeEjectInterface {
1717
private final PowerDistributionPanel pdp = RobotMap.pdp;
1818
private final VictorSP leftIntakeMotor = RobotMap.leftIntakeMotor;
1919
private final VictorSP rightIntakeMotor = RobotMap.rightIntakeMotor;
20-
private final DoubleSolenoid leftVerticalSolenoid = RobotMap.leftIntakeVerticalSolenoid;
21-
private final DoubleSolenoid rightVerticalSolenoid = RobotMap.rightIntakeVerticalSolenoid;
22-
private final DoubleSolenoid leftHorizontalSolenoid = RobotMap.leftIntakeHorizontalSolenoid;
23-
private final DoubleSolenoid rightHorizontalSolenoid = RobotMap.rightIntakeHorizontalSolenoid;
24-
private boolean rightOpen = false;
25-
private boolean leftOpen = false;
20+
private final DoubleSolenoid leftSolenoid = RobotMap.leftIntakeSolenoid;
21+
private final DoubleSolenoid rightSolenoid = RobotMap.rightIntakeSolenoid;
22+
private boolean leftOpen = isForw(leftSolenoid.get());
23+
private boolean rightOpen = isForw(rightSolenoid.get());
24+
25+
/**
26+
* Return whether or not the doubleSolenoid is set to open
27+
*
28+
* @param val
29+
* The value of the doublesolenoid
30+
*/
31+
public boolean isForw(DoubleSolenoid.Value val) {
32+
return val == DoubleSolenoid.Value.kForward;
33+
}
2634

2735
/**
2836
* Set the default command for a subsystem here.
@@ -99,120 +107,93 @@ public void runIntake(double speed) {
99107
}
100108

101109
/**
102-
* Raises the intake
110+
* Toggles the left intake between open and closed Laura's that works because it
111+
* has been TESTED
103112
*/
104-
public void raiseIntake() {
105-
DoubleSolenoid.Value leftSet = Robot.getBool("Intake Left Vertical Solenoid Inverted", false)
106-
? DoubleSolenoid.Value.kReverse
107-
: DoubleSolenoid.Value.kForward;
108-
DoubleSolenoid.Value rightSet = Robot.getBool("Intake Right Vertical Solenoid Inverted", false)
109-
? DoubleSolenoid.Value.kReverse
110-
: DoubleSolenoid.Value.kForward;
111-
leftVerticalSolenoid.set(leftSet);
112-
rightVerticalSolenoid.set(rightSet);
113-
}
113+
// public void toggleLeftIntake() {
114+
// if (leftOpen) {
115+
// // set to closed
116+
// leftHorizontalSolenoid.set(DoubleSolenoid.Value.kReverse);
117+
// } else {
118+
// // set to open
119+
// leftHorizontalSolenoid.set(DoubleSolenoid.Value.kForward);
120+
// }
121+
// leftOpen = !leftOpen;
122+
// }
114123

115124
/**
116-
* Lowers the intake
125+
* Takes into account SmartDashboard keys and current position to toggle the
126+
* position of one of the horizontal solenoids
127+
*
128+
* @param left
129+
* Whether or not the solenoid to toggle is the left solenoid
130+
* @return The DoubleSolenoid.Value that the solenoid should be set to
117131
*/
118-
public void lowerIntake() {
119-
DoubleSolenoid.Value leftSet = Robot.getBool("Intake Left Vertical Solenoid Inverted", false)
120-
? DoubleSolenoid.Value.kForward
121-
: DoubleSolenoid.Value.kReverse;
122-
DoubleSolenoid.Value rightSet = Robot.getBool("Intake Right Vertical Solenoid Inverted", false)
123-
? DoubleSolenoid.Value.kForward
124-
: DoubleSolenoid.Value.kReverse;
125-
leftVerticalSolenoid.set(leftSet);
126-
rightVerticalSolenoid.set(rightSet);
132+
public DoubleSolenoid.Value toggleHorizontal(boolean left) {
133+
boolean open = left ? leftOpen : rightOpen;
134+
String side = left ? "Left" : "Right";
135+
String key = "Intake " + side + " Horizontal Solenoid Inverted";
136+
boolean inverted = Robot.getBool(key, false);
137+
if ((open && inverted) || (!open && !inverted)) {
138+
return DoubleSolenoid.Value.kForward;
139+
} else {
140+
return DoubleSolenoid.Value.kReverse;
141+
}
127142
}
128143

144+
/**
145+
* Laura's thing that "works" because it has been tested
146+
*/
147+
// public void toggleRightIntake() {
148+
// if (rightOpen) {
149+
// // set to closed
150+
// rightHorizontalSolenoid.set(DoubleSolenoid.Value.kReverse);
151+
// } else {
152+
// // set to open
153+
// rightHorizontalSolenoid.set(DoubleSolenoid.Value.kForward);
154+
// }
155+
// rightOpen = !rightOpen;
156+
// }
157+
129158
/**
130159
* Toggles the left intake between open and closed
131160
*/
132161
public void toggleLeftIntake() {
133-
// DoubleSolenoid.Value set;
134-
// if (Robot.getBool("Left Horizontal Solenoid Open", true)) {
135-
// set = Robot.getBool("Intake Left Horizontal Solenoid Inverted", false) ?
136-
// DoubleSolenoid.Value.kForward
137-
// : DoubleSolenoid.Value.kReverse;
138-
// } else {
139-
// set = Robot.getBool("Intake Left Horizontal Solenoid Inverted", false) ?
140-
// DoubleSolenoid.Value.kReverse
141-
// : DoubleSolenoid.Value.kForward;
142-
// }
143-
// leftHorizontalSolenoid.set(set);
144-
// SmartDashboard.putBoolean("Bool/Left Horizontal Solenoid Open",
145-
// !Robot.getBool("Left Horizontal Solenoid Open", true));
146-
if (leftOpen) {
147-
// set to closed
148-
leftHorizontalSolenoid.set(DoubleSolenoid.Value.kReverse);
149-
} else {
150-
// set to open
151-
leftHorizontalSolenoid.set(DoubleSolenoid.Value.kForward);
152-
}
162+
leftSolenoid.set(toggleHorizontal(true));
153163
leftOpen = !leftOpen;
164+
Preferences.getInstance().putBoolean("Left Horizontal Solenoid Open", leftOpen);
154165
}
155166

156167
/**
157168
* Toggles the right intake between open and closed
158169
*/
159170
public void toggleRightIntake() {
160-
// DoubleSolenoid.Value set;
161-
// if (Robot.getBool("Right Horizontal Solenoid Open", true)) {
162-
// set = Robot.getBool("Intake Right Horizontal Solenoid Inverted", false) ?
163-
// DoubleSolenoid.Value.kForward
164-
// : DoubleSolenoid.Value.kReverse;
165-
// } else {
166-
// set = Robot.getBool("Intake Right Horizontal Solenoid Inverted", false) ?
167-
// DoubleSolenoid.Value.kReverse
168-
// : DoubleSolenoid.Value.kForward;
169-
// }
170-
// rightHorizontalSolenoid.set(set);
171-
// SmartDashboard.putBoolean("Bool/Right Horizontal Solenoid Open",
172-
// !Robot.getBool("Right Horizontal Solenoid Open", true));
173-
if (rightOpen) {
174-
// set to closed
175-
rightHorizontalSolenoid.set(DoubleSolenoid.Value.kReverse);
176-
} else {
177-
// set to open
178-
rightHorizontalSolenoid.set(DoubleSolenoid.Value.kForward);
179-
}
171+
rightSolenoid.set(toggleHorizontal(false));
180172
rightOpen = !rightOpen;
173+
Preferences.getInstance().putBoolean("Right Horizontal Solenoid Open", rightOpen);
181174
}
182175

183176
/**
184177
* Closes the intake
185178
*/
186179
public void closeIntake() {
187-
DoubleSolenoid.Value leftSet = Robot.getBool("Intake Left Horizontal Solenoid Inverted", false)
188-
? DoubleSolenoid.Value.kReverse
189-
: DoubleSolenoid.Value.kForward;
190-
DoubleSolenoid.Value rightSet = Robot.getBool("Intake Right Horizontal Solenoid Inverted", false)
191-
? DoubleSolenoid.Value.kReverse
192-
: DoubleSolenoid.Value.kForward;
193-
SmartDashboard.putBoolean("Bool/Left Horizontal Solenoid Open", false);
194-
SmartDashboard.putBoolean("Bool/Right Horizontal Solenoid Open", false);
195-
leftHorizontalSolenoid.set(leftSet);
196-
rightHorizontalSolenoid.set(rightSet);
197-
leftOpen = false;
198-
rightOpen = false;
180+
if (leftOpen) {
181+
toggleLeftIntake();
182+
}
183+
if (rightOpen) {
184+
toggleRightIntake();
185+
}
199186
}
200187

201188
/**
202189
* Opens the intake
203190
*/
204191
public void openIntake() {
205-
DoubleSolenoid.Value leftSet = Robot.getBool("Intake Left Horizontal Solenoid Inverted", false)
206-
? DoubleSolenoid.Value.kForward
207-
: DoubleSolenoid.Value.kReverse;
208-
DoubleSolenoid.Value rightSet = Robot.getBool("Intake Right Horizontal Solenoid Inverted", false)
209-
? DoubleSolenoid.Value.kForward
210-
: DoubleSolenoid.Value.kReverse;
211-
SmartDashboard.putBoolean("Bool/Left Horizontal Solenoid Open", true);
212-
SmartDashboard.putBoolean("Bool/Right Horizontal Solenoid Open", true);
213-
leftHorizontalSolenoid.set(leftSet);
214-
rightHorizontalSolenoid.set(rightSet);
215-
leftOpen = false;
216-
rightOpen = false;
192+
if (!leftOpen) {
193+
toggleLeftIntake();
194+
}
195+
if (!rightOpen) {
196+
toggleRightIntake();
197+
}
217198
}
218199
}

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,6 @@ public interface IntakeEjectInterface {
5454
*/
5555
public void runIntake(double speed);
5656

57-
/**
58-
* Raises the intake
59-
*/
60-
public void raiseIntake();
61-
62-
/**
63-
* Lowers the intake
64-
*/
65-
public void lowerIntake();
66-
6757
/**
6858
* Toggles the left intake between open and closed
6959
*/

0 commit comments

Comments
 (0)