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

Commit 2704c04

Browse files
authored
Merge branch 'master' into patch-1
2 parents c0f11f1 + 64b5912 commit 2704c04

21 files changed

Lines changed: 560 additions & 192 deletions

AAAScripts/scripts.txt

Lines changed: 18 additions & 14 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

@@ -242,25 +242,25 @@ moveto (48,80.375) #cross baseline
242242

243243
# Switch
244244
CRxx:
245-
moveto (0,60)(48,60)(-48,104.375)#5 feet forward, 4 right, 7 forward
245+
246+
moveto (0,60) (48,60) (-48,104.375)#5 feet forward, 4 right, 7 forward
246247
switch #deploy switch
247248

248249
CLxx:
249-
moveto (0,60)(-48,60)(-48,104.375)#5 feet forward, 4 left, 7 forward
250+
moveto (0,60) (-48,60) (-48,104.375)#5 feet forward, 4 left, 7 forward
250251
switch #deploy switch
251252

252-
253253
# Scale
254254
CxRx:
255-
moveto (0,60)(114,60)#5 feet forward, 9.5 right
255+
moveto (0,60) (114,60)#5 feet forward, 9.5 right
256256
turn -90
257257
move 224.375 #22 feet forward, compensating for robot length
258258
turn -90 #turn to face the switch
259259
scale #deploy scale
260260

261261

262262
CxLx:
263-
moveto (0,60)(-90,60) #5 feet forward, 90in left
263+
moveto (0,60) (-90,60) #5 feet forward, 90in left
264264
turn 90
265265
move 224.375 #22 feet forward, compensating for robot length
266266
turn 90 #turn to face the switch
@@ -269,7 +269,7 @@ scale #deploy scale
269269

270270
# Switch and Scale
271271
CRLx:
272-
moveto (0,60)(48,60)(48,104.375) #5 feet forward, 4 right, 7 forward
272+
moveto (0,60) (48,60) (48,104.375) #5 feet forward, 4 right, 7 forward
273273
switch #deploy switch
274274
move -39 #move 39 inches back
275275
turn -90 #turn -90 degrees
@@ -287,7 +287,7 @@ scale #deploy scale2
287287

288288

289289
CRRx:
290-
moveto (0,60)(48,60)(48,104.375)#5 feet forward, 4 right, 7 forward
290+
moveto (0,60) (48,60) (48,104.375)#5 feet forward, 4 right, 7 forward
291291
switch #deploy switch
292292
move -39 #move 39 inches back
293293
turn -90 #turn -90 degrees
@@ -305,7 +305,8 @@ scale #deploy scale
305305

306306

307307
CLRx:
308-
moveto (0,60)(-48,60)(-48,104.375) #5 feet forward, 4 left, 7 for
308+
309+
moveto (0,60) (-48,60) (-48,104.375) #5 feet forward, 4 left, 7 for
309310
switch #deploy switch
310311
move -39 #move 39 inches back
311312
turn -90 #turn -90 degrees
@@ -322,7 +323,8 @@ scale #deploy scale
322323

323324

324325
CLLx:
325-
moveto (0,60)(-48,60)(-48,104.375) #5 feet forward, 4 left, 7 forward
326+
327+
moveto (0,60) (-48,60) (-48,104.375) #5 feet forward, 4 left, 7 forward
326328
switch #deploy switch
327329
move -39 #move 39 inches back
328330
turn 90 #turn 90 degrees
@@ -342,7 +344,8 @@ scale #deploy scale2
342344

343345
# Switch and Exchange
344346
CRxE:
345-
moveto (0,60)(48,60)(48,104.375)#5 feet forward, 4 right, 7 forward
347+
348+
moveto (0,60) (48,60) (48,104.375)#5 feet forward, 4 right, 7 forward
346349
switch #deploy switch
347350
move -24 # 2 feet back
348351
turn -90
@@ -356,7 +359,8 @@ turn -90 #turn to face the exchange
356359
exchange
357360

358361
CLxE:
359-
moveto (0,60)(-48,60)(-48,104.375)#5 feet forward, 4 left, 7 forward
362+
363+
moveto (0,60) (-48,60) (-48,104.375)#5 feet forward, 4 left, 7 forward
360364
switch #deploy switch
361365
move -24
362366
turn 90
@@ -369,7 +373,7 @@ exchange
369373

370374
# Exchange
371375
CxxE:
372-
moveto (0,60)(-48,60)(-48,104.375) #5 feet forward, 3 left, 7 feet forward until against switch enclosure,compensating for robot length
376+
moveto (0,60) (-48,60) (-48,104.375) #5 feet forward, 3 left, 7 feet forward until against switch enclosure,compensating for robot length
373377
move -96 #move 8 feet back
374378
turn 180 #turn 180 degrees to face the exchange
375379
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+
#Tue Feb 20 09:44:13 PST 2018
22
C\:\\Users\\dean\\git\\RobotCode2018\\Robot2018\\lib\\libpathfinderjava.so=4087ee38c338446b8305f67716260df4

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public OI() {
9090
MoveLiftUpButton.whileHeld(new RunLift(Robot.lift, true));
9191
MoveLiftDownButton.whileHeld(new RunLift(Robot.lift, false));
9292

93-
// manipulator = new Joystick(2);
93+
manipulator = new Joystick(2);
9494
// closeIntake = new JoystickButton(manipulator, getButton("Close Intake
9595
// Button", 1));
9696
// closeIntake.whenPressed(new CloseIntake());

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

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
import java.util.Map;
1313

1414
import org.usfirst.frc.team199.Robot2018.autonomous.AutoUtils;
15+
import org.usfirst.frc.team199.Robot2018.autonomous.Position;
1516
import org.usfirst.frc.team199.Robot2018.commands.Autonomous;
16-
import org.usfirst.frc.team199.Robot2018.commands.Autonomous.Position;
1717
import org.usfirst.frc.team199.Robot2018.commands.Autonomous.Strategy;
1818
import org.usfirst.frc.team199.Robot2018.commands.ShiftLowGear;
1919
import org.usfirst.frc.team199.Robot2018.subsystems.Climber;
@@ -22,9 +22,9 @@
2222
import org.usfirst.frc.team199.Robot2018.subsystems.IntakeEject;
2323
import org.usfirst.frc.team199.Robot2018.subsystems.Lift;
2424

25-
import edu.wpi.first.wpilibj.CameraServer;
2625
import edu.wpi.first.wpilibj.DriverStation;
2726
import edu.wpi.first.wpilibj.IterativeRobot;
27+
import edu.wpi.first.wpilibj.PIDController;
2828
import edu.wpi.first.wpilibj.Preferences;
2929
import edu.wpi.first.wpilibj.command.Command;
3030
import edu.wpi.first.wpilibj.command.Scheduler;
@@ -53,7 +53,7 @@ public class Robot extends IterativeRobot {
5353
public static Map<String, ArrayList<String[]>> autoScripts;
5454

5555
Command autonomousCommand;
56-
SendableChooser<Position> posChooser = new SendableChooser<Position>();
56+
SendableChooser<Autonomous.Position> posChooser = new SendableChooser<Autonomous.Position>();
5757
Map<String, SendableChooser<Strategy>> stratChoosers = new HashMap<String, SendableChooser<Strategy>>();
5858
String[] fmsPossibilities = { "LL", "LR", "RL", "RR" };
5959

@@ -69,6 +69,14 @@ public double getConst(String key, double def) {
6969
}
7070
return pref.getDouble("Const/" + key, def);
7171
}
72+
73+
public void putData(String string, PIDController controller) {
74+
SmartDashboard.putData(string, controller);
75+
}
76+
77+
public void putNumber(String string, double d) {
78+
SmartDashboard.putNumber(string, d);
79+
}
7280
/*
7381
* if (!SmartDashboard.containsKey("Const/" + key)) { if
7482
* (!SmartDashboard.putNumber("Const/" + key, def)) {
@@ -109,7 +117,7 @@ public void robotInit() {
109117
oi = new OI();
110118

111119
// auto position chooser
112-
for (Position p : Position.values()) {
120+
for (Autonomous.Position p : Autonomous.Position.values()) {
113121
posChooser.addObject(p.getSDName(), p);
114122
}
115123
SmartDashboard.putData("Starting Position", posChooser);
@@ -131,8 +139,8 @@ public void robotInit() {
131139
autoScripts = AutoUtils.parseScriptFile(Preferences.getInstance().getString("autoscripts", ""));
132140

133141
listen = new Listener();
134-
CameraServer.getInstance().startAutomaticCapture(0);
135-
CameraServer.getInstance().startAutomaticCapture(1);
142+
// CameraServer.getInstance().startAutomaticCapture(0);
143+
// CameraServer.getInstance().startAutomaticCapture(1);
136144
}
137145

138146
/**
@@ -157,9 +165,11 @@ public void disabledPeriodic() {
157165
*/
158166
@Override
159167
public void autonomousInit() {
168+
dt.resetAHRS();
169+
AutoUtils.position = new Position(0, 0, 0);
160170
Scheduler.getInstance().add(new ShiftLowGear());
161171
String fmsInput = DriverStation.getInstance().getGameSpecificMessage();
162-
Position startPos = posChooser.getSelected();
172+
Autonomous.Position startPos = posChooser.getSelected();
163173
double autoDelay = SmartDashboard.getNumber("Auto Delay", 0);
164174

165175
Map<String, Strategy> strategies = new HashMap<String, Strategy>();
@@ -169,8 +179,8 @@ public void autonomousInit() {
169179
strategies.put(key, chooser.getSelected());
170180
}
171181

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

176186
/**

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));
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
package org.usfirst.frc.team199.Robot2018;
22

3+
import edu.wpi.first.wpilibj.PIDController;
4+
35
public interface SmartDashboardInterface {
46
public double getConst(String key, double def);
7+
8+
public void putData(String string, PIDController controller);
9+
10+
public void putNumber(String string, double d);
511
}

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

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
public class AutoUtils {
88

9-
public static Position position = new Position(0, 0, 0);
9+
public static Position position;
1010

1111
/**
1212
* Parses the inputted script file into a map of scripts
@@ -24,23 +24,25 @@ 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;
28+
int errorCount = 0;
2829
for (String line : lines) {
30+
count++;
2931
// remove comments
3032
int commentIndex = line.indexOf("#");
3133
if (commentIndex != -1)
3234
line = line.substring(0, commentIndex);
3335

3436
// trim and remove extra whitespace just to make it neater
35-
line = line.trim().replaceAll("\\s+", " ");
37+
line = line.trim().replaceAll("\\s+", " ");
3638
// make coordinates with spaces also work
3739
int parenIndex = line.indexOf("(");
3840
while (parenIndex != -1) {
3941
// removes all spaces between the parentheses
4042
int endParenIndex = line.indexOf(")", parenIndex);
4143
String coord = line.substring(parenIndex + 1, endParenIndex);
4244
line = line.substring(0, parenIndex + 1) + coord.replaceAll(" ", "") + line.substring(endParenIndex);
43-
45+
4446
// finds next parentheses
4547
parenIndex = line.indexOf("(", parenIndex + 1);
4648
}
@@ -74,9 +76,11 @@ public static Map<String, ArrayList<String[]>> parseScriptFile(String scriptFile
7476
if (isValidCommand(instruction, args, count)) {
7577
String[] command = { instruction, args };
7678
currScript.add(command);
79+
} else {
80+
errorCount++;
7781
}
7882
}
79-
count++;
83+
8084
}
8185

8286
// puts the last script in
@@ -85,6 +89,8 @@ public static Map<String, ArrayList<String[]>> parseScriptFile(String scriptFile
8589
// remove the stray one in the beginning
8690
autoScripts.remove("");
8791

92+
System.out.println("[INFO] Successfuly parsed " + count + " lines with " + errorCount + " errors.");
93+
8894
return autoScripts;
8995
}
9096

@@ -187,7 +193,7 @@ else if (instruction.equals("jump")) {
187193
* the message to log
188194
*/
189195

190-
private static void logWarning (int lineNumber, String message) {
196+
private static void logWarning(int lineNumber, String message) {
191197
System.err.println("[ERROR] Line " + lineNumber + ": " + message);
192198
}
193199

@@ -243,16 +249,16 @@ public static double[] parsePoint(String cmdArgs) {
243249
double[] point = new double[2];
244250
String parentheseless;
245251
String[] pointparts;
246-
if (AutoUtils.isPoint(cmdArgs)) {
252+
if (isPoint(cmdArgs)) {
247253
parentheseless = cmdArgs.substring(1, cmdArgs.length() - 1);
248254
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-
}
255+
try {
256+
point[0] = Double.parseDouble(pointparts[0]);
257+
point[1] = Double.parseDouble(pointparts[1]);
258+
} catch (Exception e) {
259+
point[0] = 1;
260+
point[1] = 1;
261+
}
256262
}
257263
return point;
258264
}

Robot2018/src/org/usfirst/frc/team199/Robot2018/autonomous/scriptupload/scriptupload.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#nt setup
22
from networktables import NetworkTables
33
import __future__
4+
import time
45
NetworkTables.initialize(server='10.1.99.2')
56
prefs = NetworkTables.getTable("Preferences")
67

@@ -30,6 +31,8 @@
3031
prefs.putString("autoscripts", oneline)
3132
print("Uploading %s as a String[] to key \"autoscripts\"" % filename)
3233

34+
time.sleep(0.1)
35+
3336
#checks if the key has been filled
3437
tester = "" #a variable to check if autoscripts is None
3538

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

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

0 commit comments

Comments
 (0)