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

Commit 9d17303

Browse files
authored
Merge intakefix branch (Add toggle functionality to the left and right intake)
Add toggle functionality to the left and right intake
2 parents 01fa85b + 7c530bf commit 9d17303

18 files changed

Lines changed: 295 additions & 153 deletions

AAAScripts/scripts.txt

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ RxLx:
3636
#-------------------------------------------------
3737

3838
#Exchange
39-
RxxE
39+
RxxE:
4040
moveto (0, 188.4) (-210.6, 188.4) (-210.6, 44.4) (-123.6, 44.4) (-123.6, -39.6) 180 #Curve around switch for baseline #then go to exchange
4141
exchange
4242

@@ -144,7 +144,7 @@ LxRx:
144144
#-------------------------------------------------
145145

146146
#Exchange
147-
LxxE
147+
LxxE:
148148
moveto (0, 188.4) (210.6, 188.4) (210.6, 3.7) (124.8, 3.7) (124.8, -3.3) 180 #Curve around switch for baseline then go to exchange
149149
exchange
150150

@@ -244,13 +244,13 @@ moveto (48,80.375) #cross baseline
244244
CRxx:
245245
moveto (0,60) 90 #5 feet forward, turn 90
246246
moveto (48,60) -90 #4 feet right,turn -90
247-
moveto(48,104.375) #7 feet forward until against switch enclosure, compensating for robot length
247+
moveto (48,104.375) #7 feet forward until against switch enclosure, compensating for robot length
248248
switch #deploy switch
249249

250250
CLxx:
251251
moveto (0,60) -90 #5 feet forward, turn -90
252252
moveto (-48,60) 90 #4 feet left,turn 90
253-
moveto(-48,104.375) #7 feet forward until against switch enclosure,compensating for robot length
253+
moveto (-48,104.375) #7 feet forward until against switch enclosure,compensating for robot length
254254
switch #deploy switch
255255

256256

@@ -275,7 +275,7 @@ scale #deploy scale
275275
CRLx:
276276
moveto (0,60) 90 #5 feet forward, turn 90
277277
moveto (48,60) -90 #4 feet right,turn -90
278-
moveto(48,104.375) #7 feet forward until against switch enclosure
278+
moveto (48,104.375) #7 feet forward until against switch enclosure
279279
switch #deploy switch
280280
move -39 #move 39 inches back
281281
turn -90 #turn -90 degrees
@@ -294,7 +294,7 @@ scale #deploy scale2
294294
CRRx:
295295
moveto (0,60) 90 #5 feet forward, turn 90
296296
moveto (48,60) -90 #4 feet right,turn -90
297-
moveto(48,104.375) #7 feet forward until against switch enclosure
297+
moveto (48,104.375) #7 feet forward until against switch enclosure
298298
switch #deploy switch
299299
move -39 #move 39 inches back
300300
turn -90 #turn -90 degrees
@@ -313,7 +313,7 @@ scale #deploy scale
313313
CLRx:
314314
moveto (0,60) -90 #5 feet forward, turn -90
315315
moveto (-48,60) 90 #4 feet left,turn 90
316-
moveto(-48,104.375) #7 feet forward until against switch enclosure
316+
moveto (-48,104.375) #7 feet forward until against switch enclosure
317317
switch #deploy switch
318318
move -39 #move 39 inches back
319319
turn -90 #turn -90 degrees
@@ -331,7 +331,7 @@ scale #deploy scale
331331
CLLx:
332332
moveto (0,60) -90 #5 feet forward, turn -90
333333
moveto (-48,60) 90 #4 feet left,turn 90
334-
moveto(-48,104.375) #7 feet forward until against switch enclosure
334+
moveto (-48,104.375) #7 feet forward until against switch enclosure
335335
switch #deploy switch
336336
move -39 #move 39 inches back
337337
turn 90 #turn 90 degrees
@@ -352,7 +352,7 @@ scale #deploy scale2
352352
CRxE:
353353
moveto (0,60) 90 #5 feet forward, turn 90
354354
moveto (48,60) -90 #4 feet right,turn -90
355-
moveto(48,104.375) #7 feet forward until against switch enclosure, compensating for robot length
355+
moveto (48,104.375) #7 feet forward until against switch enclosure, compensating for robot length
356356
switch #deploy switch
357357
move -24 # 2 feet back
358358
turn -90
@@ -368,7 +368,7 @@ exchange
368368
CLxE:
369369
moveto (0,60) -90 #5 feet forward, turn -90
370370
moveto (-48,60) 90 #3 feet left,turn 90
371-
moveto(-48,104.375) #7 feet forward until against switch enclosure,compensating for robot length
371+
moveto (-48,104.375) #7 feet forward until against switch enclosure,compensating for robot length
372372
switch #deploy switch
373373
move -24
374374
turn 90
@@ -383,7 +383,7 @@ exchange
383383
CxxE:
384384
moveto (0,60) -90 #5 feet forward, turn -90
385385
moveto (-48,60) 90 #3 feet left,turn 90
386-
moveto(-48,104.375) #7 feet forward until against switch enclosure,compensating for robot length
386+
moveto (-48,104.375) #7 feet forward until against switch enclosure,compensating for robot length
387387
move -96 #move 8 feet back
388388
turn 180 #turn 180 degrees to face the exchange
389389
exchange
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
#Sun Feb 18 15:40:25 PST 2018
1+
#Sun Feb 18 17:40:43 PST 2018
22
C\:\\Users\\dean\\git\\RobotCode2018\\Robot2018\\lib\\libpathfinderjava.so=4087ee38c338446b8305f67716260df4

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
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ public void autonomousInit() {
169169
strategies.put(key, chooser.getSelected());
170170
}
171171

172-
Autonomous auto = new Autonomous(startPos, strategies, autoDelay, fmsInput, false);
173-
auto.start();
172+
Scheduler.getInstance().add(new Autonomous(startPos, strategies, autoDelay, fmsInput, false));
173+
// auto.start();
174174
}
175175

176176
/**

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,10 @@ public RobotMap() {
130130

131131
leftIntakeMotor = new VictorSP(getPort("IntakeLeftVictorSP", 9));
132132
rightIntakeMotor = new VictorSP(getPort("IntakeRightVictorSP", 8));
133-
// leftIntakeHorizontalSolenoid = new
134-
// DoubleSolenoid(getPort("IntakeLeftHorizontalSolenoidPort1", 2),
135-
// getPort("IntakeLeftHorizontalSolenoidPort2", 3));
136-
// rightIntakeHorizontalSolenoid = new
137-
// DoubleSolenoid(getPort("IntakeRightHorizontalSolenoidPort1", 4),
138-
// getPort("IntakeRightHorizontalSolenoidPort2", 5));
133+
leftIntakeHorizontalSolenoid = new DoubleSolenoid(getPort("IntakeLeftHorizontalSolenoidPort1", 2),
134+
getPort("IntakeLeftHorizontalSolenoidPort2", 3));
135+
rightIntakeHorizontalSolenoid = new DoubleSolenoid(getPort("IntakeRightHorizontalSolenoidPort1", 4),
136+
getPort("IntakeRightHorizontalSolenoidPort2", 5));
139137
// leftIntakeVerticalSolenoid = new
140138
// DoubleSolenoid(getPort("IntakeLeftVerticalSolenoidPort1", 6),
141139
// getPort("IntakeLeftVerticalSolenoidPort2", 7));

Robot2018/src/org/usfirst/frc/team199/Robot2018/autonomous/AutoUtils.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,24 @@ public static Map<String, ArrayList<String[]>> parseScriptFile(String scriptFile
2424
ArrayList<String[]> currScript = new ArrayList<String[]>();
2525
String currScriptName = "";
2626

27-
int count = 1;
27+
int count = 0;
2828
for (String line : lines) {
29+
count++;
2930
// remove comments
3031
int commentIndex = line.indexOf("#");
3132
if (commentIndex != -1)
3233
line = line.substring(0, commentIndex);
3334

3435
// trim and remove extra whitespace just to make it neater
35-
line = line.trim().replaceAll("\\s+", " ");
36+
line = line.trim().replaceAll("\\s+", " ");
3637
// make coordinates with spaces also work
3738
int parenIndex = line.indexOf("(");
3839
while (parenIndex != -1) {
3940
// removes all spaces between the parentheses
4041
int endParenIndex = line.indexOf(")", parenIndex);
4142
String coord = line.substring(parenIndex + 1, endParenIndex);
4243
line = line.substring(0, parenIndex + 1) + coord.replaceAll(" ", "") + line.substring(endParenIndex);
43-
44+
4445
// finds next parentheses
4546
parenIndex = line.indexOf("(", parenIndex + 1);
4647
}
@@ -76,7 +77,7 @@ public static Map<String, ArrayList<String[]>> parseScriptFile(String scriptFile
7677
currScript.add(command);
7778
}
7879
}
79-
count++;
80+
8081
}
8182

8283
// puts the last script in
@@ -187,7 +188,7 @@ else if (instruction.equals("jump")) {
187188
* the message to log
188189
*/
189190

190-
private static void logWarning (int lineNumber, String message) {
191+
private static void logWarning(int lineNumber, String message) {
191192
System.err.println("[ERROR] Line " + lineNumber + ": " + message);
192193
}
193194

@@ -246,13 +247,13 @@ public static double[] parsePoint(String cmdArgs) {
246247
if (AutoUtils.isPoint(cmdArgs)) {
247248
parentheseless = cmdArgs.substring(1, cmdArgs.length() - 1);
248249
pointparts = parentheseless.split(",");
249-
try {
250-
point[0] = Double.parseDouble(pointparts[0]);
251-
point[1] = Double.parseDouble(pointparts[1]);
252-
} catch (Exception e) {
253-
point[0] = 1;
254-
point[1] = 1;
255-
}
250+
try {
251+
point[0] = Double.parseDouble(pointparts[0]);
252+
point[1] = Double.parseDouble(pointparts[1]);
253+
} catch (Exception e) {
254+
point[0] = 1;
255+
point[1] = 1;
256+
}
256257
}
257258
return point;
258259
}

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

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

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

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,11 @@ public AutoMoveTo(String[] args, DrivetrainInterface dt, SmartDashboardInterface
2424
for (String arg : args) {
2525
if (AutoUtils.isDouble(arg)) {
2626
rotation = Double.valueOf(arg);
27-
double relrotation = rotation - AutoUtils.position.getRot();
28-
addSequential(new PIDTurn(relrotation, dt, sd, pidMoveSrc));
29-
AutoUtils.position.setRot(rotation);
27+
addSequential(new PIDTurn(rotation, dt, sd, pidMoveSrc, true));
3028
} else if (AutoUtils.isPoint(arg)) {
3129
point = AutoUtils.parsePoint(arg);
32-
double deltaX = point[0] - AutoUtils.position.getX();
33-
double deltaY = point[1] - AutoUtils.position.getY();
34-
double atan = Math.toDegrees(Math.atan(deltaX / deltaY));
35-
double relrotation = atan - AutoUtils.position.getRot();
36-
addSequential(new PIDTurn(relrotation, dt, sd, pidMoveSrc));
37-
double dX2 = deltaX * deltaX;
38-
double dY2 = deltaY * deltaY;
39-
double distance = Math.sqrt(dX2 + dY2);
40-
addSequential(new PIDMove(distance, dt, sd, pidMoveSrc));
41-
double x = AutoUtils.position.getX();
42-
double y = AutoUtils.position.getY();
43-
AutoUtils.position.setX(point[0]);
44-
AutoUtils.position.setY(point[1]);
45-
AutoUtils.position.setRot(Math.toDegrees(Math.atan((point[0] - x) / (point[1] - y))));
30+
addSequential(new PIDTurn(point, dt, sd, pidMoveSrc));
31+
addSequential(new PIDMove(point, dt, sd, pidMoveSrc));
4632
} else {
4733
throw new IllegalArgumentException();
4834
}

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

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ protected void initialize() {
2020

2121
// Called repeatedly when this Command is scheduled to run
2222
protected void execute() {
23-
Robot.intakeEject.runIntake(1);
23+
Robot.intakeEject.runIntake(-1);
2424
}
2525

2626
// Make this return true when this Command no longer needs to run execute()

0 commit comments

Comments
 (0)