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

Commit c80e519

Browse files
Merge branch 'better-auto' of https://github.com/kevinzwang/RobotCode2018.git into better-auto
2 parents 3d0494a + 5992ed0 commit c80e519

6 files changed

Lines changed: 30 additions & 35 deletions

File tree

AAAScripts/scripts.txt

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ moveto (0,120) #Drive past auto line
77

88
#Switch
99
RRxx:
10-
moveto (0,155)
11-
turn -90
12-
switch
10+
moveto (0,148) -90
11+
switch 19
1312

1413
RLxx:
1514
move 56
@@ -76,9 +75,8 @@ moveto (0, 120) #Drive past auto line
7675

7776
#Switch
7877
LLxx:
79-
move 150
80-
turn 90
81-
switch
78+
moveto (0,148) 90
79+
switch 19
8280

8381
LRxx:
8482
move 56
@@ -139,17 +137,16 @@ exchange
139137

140138
# Cross Auto Line
141139
Cxxx:
142-
moveto (0,50) (48,50) (48,92) #cross baseline
143-
140+
moveto (0, 12) (40, 88)
144141

145142
# Switch
146143
CRxx:
147-
moveto (0,50) (48,50) (48,85)
148-
switch #deploy switch
144+
moveto (0,15) (50,85) 0
145+
switch 15
149146

150147
CLxx:
151-
moveto (0,50) (-56,50) (-56,85)
152-
switch #deploy switch
148+
moveto (0,15) (-60,85) 0
149+
switch 15
153150

154151

155152
# Switch and Exchange

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,21 +109,21 @@ public static boolean isValidCommand(String instruction, String args, int lineNu
109109
// moveto takes in a set of points, and the last arg can be a number
110110
if (instruction.equals("moveto")) {
111111
if (args == "") {
112-
logError(lineNumber, "The command `moveto` requires at least one argument.");
112+
logError(lineNumber, "The command `" + instruction + "` requires at least one argument.");
113113
return false;
114114
}
115115

116116
String[] splitArgs = args.split(" ");
117117
for (int i = 0; i < splitArgs.length - 1; i++) {
118118
if (!isPoint(splitArgs[i])) {
119119
logError(lineNumber,
120-
"The arguments for command `moveto` should be points formatted like this: " + "`(x,y)`.");
120+
"The arguments for command `" + instruction + "` should be points formatted like this: " + "`(x,y)`.");
121121
return false;
122122
}
123123
}
124124

125125
if (!isDouble(splitArgs[splitArgs.length - 1]) && !isPoint(splitArgs[splitArgs.length - 1])) {
126-
logError(lineNumber, "The last argument for command `moveto` should be a number, or a point "
126+
logError(lineNumber, "The last argument for command `" + instruction + "` should be a number, or a point "
127127
+ "formatted like this: `(x,y)`.");
128128
return false;
129129
}
@@ -132,32 +132,32 @@ public static boolean isValidCommand(String instruction, String args, int lineNu
132132
// turn can take a number or point
133133
else if (instruction.equals("turn")) {
134134
if (args.contains(" ")) {
135-
logError(lineNumber, "Command `turn` only accepts one argument.");
135+
logError(lineNumber, "Command `" + instruction + "` only accepts one argument.");
136136
return false;
137137
}
138138

139139
if (!isDouble(args) && !isPoint(args)) {
140-
logError(lineNumber, "The argument for command `turn` should be a number or a point formatted like "
140+
logError(lineNumber, "The argument for command `" + instruction + "` should be a number or a point formatted like "
141141
+ "this: `(x,y)`.");
142142
return false;
143143
}
144144
}
145145

146-
// move and wait can take only a number
147-
else if (instruction.equals("move") || instruction.equals("wait")) {
146+
// these can take only a number
147+
else if (instruction.equals("move") || instruction.equals("wait") || instruction.equals("switch") || instruction.equals("scale")) {
148148
if (args.contains(" ")) {
149-
logError(lineNumber, "Command `move` only accepts one argument.");
149+
logError(lineNumber, "Command `" + instruction + "` only accepts one argument.");
150150
return false;
151151
}
152152

153153
if (!isDouble(args)) {
154-
logError(lineNumber, "The argument for command `move` should be a number.");
154+
logError(lineNumber, "The argument for command `" + instruction + "` should be a number.");
155155
return false;
156156
}
157157
}
158158

159159
// switch, scale, exchange, intake, and end all don't have any args
160-
else if (instruction.equals("switch") || instruction.equals("scale") || instruction.equals("exchange")
160+
else if (instruction.equals("exchange")
161161
|| instruction.equals("intake") || instruction.equals("end")) {
162162
if (!args.equals("")) {
163163
logError(lineNumber, "Command `" + instruction + "` does not accept any arguments.");
@@ -168,7 +168,7 @@ else if (instruction.equals("switch") || instruction.equals("scale") || instruct
168168
// Jump only takes one argument
169169
else if (instruction.equals("jump")) {
170170
if (args.contains(" ")) {
171-
logError(lineNumber, "Command `jump` only accepts one argument.");
171+
logError(lineNumber, "Command `" + instruction + "` only accepts one argument.");
172172
return false;
173173
}
174174
}

Robot2018/src/org/usfirst/frc/team199/Robot2018/autonomous/aaa-reference.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Ex:
5050
| jump | Jumps to the specified script and continues the current script when finished. (Doesn’t make the robot go up.) | `jump MoveToRScale`
5151
| move | Move forward or backwards for the specified amount in inches, relative to the current position. | `move 24` |
5252
| moveto | Move to 1 or more points, sequentially, with an optional last value having a final angle to face towards, all relative to the starting position. | `moveto (12,0) (36,12)` <br> `moveto (0,12) 90` |
53-
| scale | Place a cube at scale height. | `scale` |
54-
| switch | Place a cube at switch height. | `switch` |
53+
| scale | Place a cube at scale height after moving forward by the specified amount with the lift up, and after moves 12 inches back. | `scale 24` |
54+
| switch | Place a cube at switch height after moving forward by the specified amount with the lift up, and after moves 12 inches back. | `switch 24` |
5555
| turn | Turn towards a relative point or rotate clockwise by an angle in degrees, relative to the current position. <br> Negative angle for counterclockwise. | `turn (36,48)` <br> `turn 45` |
5656
| wait | Waits for the number of seconds before proceeding to next command. | `wait 5` |

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@
99
*/
1010
public class EjectToScale extends CommandGroup {
1111

12-
public EjectToScale() {
12+
public EjectToScale(double dist) {
1313
addSequential(new AutoLift(Robot.lift, "SCALE"));
14-
addSequential(
15-
new PIDMove(Robot.getConst("Auto Scale Move Dist", 18), Robot.dt, Robot.sd, Robot.dt.getDistEncAvg()));
14+
addSequential(new PIDMove(dist, Robot.dt, Robot.sd, Robot.dt.getDistEncAvg()));
1615
addSequential(new OuttakeCube());
17-
addSequential(new PIDMove(-1 * Robot.getConst("Auto Scale Move Dist", 18), Robot.dt, Robot.sd,
16+
addSequential(new PIDMove(-1 * Robot.getConst("Scale move back dist", 12), Robot.dt, Robot.sd,
1817
Robot.dt.getDistEncAvg()));
1918
addSequential(new AutoLift(Robot.lift, "GROUND"));
2019
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@
99
*/
1010
public class EjectToSwitch extends CommandGroup {
1111

12-
public EjectToSwitch() {
12+
public EjectToSwitch(double dist) {
1313
addSequential(new AutoLift(Robot.lift, "SWITCH"));
14-
addSequential(
15-
new PIDMove(Robot.getConst("Auto Switch Move Dist", 18), Robot.dt, Robot.sd, Robot.dt.getDistEncAvg()));
14+
addSequential(new PIDMove(dist, Robot.dt, Robot.sd, Robot.dt.getDistEncAvg()));
1615
addSequential(new OuttakeCube());
17-
addSequential(new PIDMove(-1 * Robot.getConst("Auto Switch Move Dist", 18), Robot.dt, Robot.sd,
16+
addSequential(new PIDMove(-1 * Robot.getConst("Switch move back dist", 12), Robot.dt, Robot.sd,
1817
Robot.dt.getDistEncAvg()));
1918
addSequential(new AutoLift(Robot.lift, "GROUND"));
2019
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ public RunScript(String scriptName) {
4444
addSequential(new PIDMove(distance, Robot.dt, Robot.sd, Robot.dt.getDistEncAvg()));
4545
break;
4646
case "switch":
47-
addSequential(new EjectToSwitch());
47+
addSequential(new EjectToSwitch(Double.parseDouble(cmdArgs)));
4848
break;
4949
case "scale":
50-
addSequential(new EjectToScale());
50+
addSequential(new EjectToScale(Double.parseDouble(cmdArgs)));
5151
break;
5252
case "exchange":
5353
addSequential(new EjectToExchange());

0 commit comments

Comments
 (0)