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

Commit 7c12555

Browse files
committed
resolve merge conflicts
;)
2 parents 07d1fb8 + 091b6b2 commit 7c12555

File tree

21 files changed

+639
-282
lines changed

21 files changed

+639
-282
lines changed

AAAScripts/scripts.txt

Lines changed: 80 additions & 91 deletions
Large diffs are not rendered by default.
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: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -94,19 +94,23 @@ public OI() {
9494
moveLiftDownButton = new JoystickButton(rightJoy, getButton("Run Lift Motor Down", 11));
9595
moveLiftUpButton.whileHeld(new RunLift(Robot.lift, true));
9696
moveLiftDownButton.whileHeld(new RunLift(Robot.lift, false));
97-
98-
// manipulator = new Joystick(2);
99-
// closeIntakeButton = new JoystickButton(manipulator, getButton("Close Intake Button", 1));
100-
// closeIntakeButton.whenPressed(new CloseIntake());
101-
// openIntakeButton = new JoystickButton(manipulator, getButton("Open Intake Button", 2));
102-
// openIntakeButton.whenPressed(new OpenIntake());
103-
// raiseIntakeButton = new JoystickButton(manipulator, getButton("Raise Intake Button", 3));
104-
// raiseIntakeButton.whenPressed(new RaiseIntake());
105-
// lowerIntakeButton = new JoystickButton(manipulator, getButton("Lower Intake Button", 4));
106-
// lowerIntakeButton.whenPressed(new LowerIntake());
107-
// intakeCubeButton = new JoystickButton(manipulator, getButton("Intake Button", 5));
108-
// intakeCubeButton.whenPressed(new IntakeCube());
109-
// outtakeCubeButton = new JoystickButton(manipulator, getButton("Outtake Button", 6));
110-
// outtakeCubeButton.whenPressed(new OuttakeCube());
97+
98+
manipulator = new Joystick(2);
99+
// closeIntake = new JoystickButton(manipulator, getButton("Close Intake
100+
// Button", 1));
101+
// closeIntake.whenPressed(new CloseIntake());
102+
// openIntake = new JoystickButton(manipulator, getButton("Open Intake Button",
103+
// 2));
104+
// openIntake.whenPressed(new OpenIntake());
105+
// raiseIntake = new JoystickButton(manipulator, getButton("Raise Intake
106+
// Button", 3));
107+
// raiseIntake.whenPressed(new RaiseIntake());
108+
// lowerIntake = new JoystickButton(manipulator, getButton("Lower Intake
109+
// Button", 4));
110+
// lowerIntake.whenPressed(new LowerIntake());
111+
// intake = new JoystickButton(manipulator, getButton("Intake Button", 5));
112+
// intake.whenPressed(new IntakeCube());
113+
// outake = new JoystickButton(manipulator, getButton("Outake Button", 6));
114+
// outake.whenPressed(new OutakeCube());
111115
}
112116
}

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.

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

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,39 +17,26 @@
1717
*/
1818
public class AutoMoveTo extends CommandGroup {
1919

20-
public AutoMoveTo(String[] args, DrivetrainInterface dt, SmartDashboardInterface sd, PIDSource pidMoveSrc) {
20+
public AutoMoveTo(String[] args, DrivetrainInterface dt, SmartDashboardInterface sd, PIDSource pidMoveSrc,
21+
PIDSource pidTurnSource) {
2122
// requires(Drivetrain);
2223
double rotation;
2324
double[] point = { 0, 0 };
2425
for (String arg : args) {
2526
if (AutoUtils.isDouble(arg)) {
2627
rotation = Double.valueOf(arg);
27-
double relrotation = rotation - AutoUtils.position.getRot();
28-
addSequential(new PIDTurn(relrotation, dt, sd, pidMoveSrc));
29-
AutoUtils.position.setRot(rotation);
28+
addSequential(new PIDTurn(rotation, dt, sd, pidTurnSource, true));
3029
} else if (AutoUtils.isPoint(arg)) {
3130
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))));
31+
addSequential(new PIDTurn(point, dt, sd, pidTurnSource));
32+
addSequential(new PIDMove(point, dt, sd, pidMoveSrc));
4633
} else {
4734
throw new IllegalArgumentException();
4835
}
4936
}
5037
}
5138

5239
public AutoMoveTo(String[] args) {
53-
this(args, Robot.dt, Robot.sd, Robot.dt.getDistEncAvg());
40+
this(args, Robot.dt, Robot.sd, Robot.dt.getDistEncAvg(), Robot.dt.getGyro());
5441
}
5542
}

0 commit comments

Comments
 (0)