rearrange a few more files. realize that adding the auton read from file thing was...
authorLogan Howard <logan@oflogan.com>
Sat, 18 Apr 2015 05:02:00 +0000 (22:02 -0700)
committerLogan Howard <logan@oflogan.com>
Sat, 18 Apr 2015 05:02:00 +0000 (22:02 -0700)
src/org/usfirst/frc/team3501/bases/CommandBase.java
src/org/usfirst/frc/team3501/robot/AutonData.java [deleted file]
src/org/usfirst/frc/team3501/robot/Robot.java
src/org/usfirst/frc/team3501/robot/autons/ContainerOverStep.java
src/org/usfirst/frc/team3501/robot/autons/PickUpContainer.java
src/org/usfirst/frc/team3501/util/AutonData.java [new file with mode: 0644]

index d797ce6700dd6194256727061b85515bcd37f7fe..770f48d3793eb8e76ec90fe8574d696c099a04fe 100644 (file)
@@ -1,9 +1,9 @@
 package org.usfirst.frc.team3501.bases;
 
-import org.usfirst.frc.team3501.robot.AutonData;
 import org.usfirst.frc.team3501.robot.OI;
 import org.usfirst.frc.team3501.robot.Robot;
 import org.usfirst.frc.team3501.robot.subsystems.*;
+import org.usfirst.frc.team3501.util.AutonData;
 
 public interface CommandBase {
 
diff --git a/src/org/usfirst/frc/team3501/robot/AutonData.java b/src/org/usfirst/frc/team3501/robot/AutonData.java
deleted file mode 100644 (file)
index a643b06..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-package org.usfirst.frc.team3501.robot;
-
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.HashMap;
-
-public class AutonData {
-
-    HashMap<String, Double> speeds;
-    HashMap<String, Double> times;
-
-    public AutonData() {
-        speeds = new HashMap<String, Double>();
-        times  = new HashMap<String, Double>();
-
-        populate();
-    }
-
-    public double getSpeed(String key) {
-        Double ret = speeds.get(key);
-
-        return (ret != null) ? ret : 0;
-    }
-
-    public double getTime(String key) {
-        Double ret = times.get(key);
-
-        return (ret != null) ? ret : 0;
-    }
-
-    public void update() {
-        speeds.clear();
-        times.clear();
-
-        populate();
-    }
-
-    private void populate() {
-        String file;
-
-        try {
-            file = readConfigFile();
-        } catch (IOException e) {
-            e.printStackTrace();
-            populateDefaults();
-            return;
-        }
-
-        try {
-            Arrays.stream(file.split("\n"))
-            .map(line -> line.split(" "))
-            .forEach((action) -> {
-                double speed = Double.parseDouble(action[0]);
-                double time  = Double.parseDouble(action[1]);
-                String name  = action[2];
-
-                speeds.put(name, speed);
-                times.put(name, time);
-            });
-        } catch (Exception e) {
-            e.printStackTrace();
-            populateDefaults();
-        }
-    }
-
-    private void populateDefaults() {
-        speeds.clear();
-        times.clear();
-
-        speeds.put("drive_over_step",  0.7);
-        speeds.put("drive_past_step",  0.5);
-        speeds.put("pickup_container", 0.5);
-
-        times.put("drive_over_step",  1.2);
-        times.put("drive_past_step",  1.5);
-        times.put("pickup_container", 1.4);
-    }
-
-    private String readConfigFile() throws IOException {
-        BufferedReader in = new BufferedReader(new FileReader(
-                "auton_times_and_speeds.conf"));
-
-        StringBuilder sb = new StringBuilder();
-
-        in.readLine(); // get rid of first line
-
-        String curLine;
-        while ((curLine = in.readLine()) != null)
-            sb.append(curLine + "\n");
-        String finalString = sb.toString();
-
-        in.close();
-
-        return finalString;
-    }
-}
index 532d25415fb7b47fc56b7fd66d968eba63b58cb2..c7ef783478c8307e5b01d3e5ae714dd192e9b887 100644 (file)
@@ -11,6 +11,7 @@ import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
 import org.usfirst.frc.team3501.robot.autons.*;
 import org.usfirst.frc.team3501.robot.commands.*;
 import org.usfirst.frc.team3501.robot.subsystems.*;
+import org.usfirst.frc.team3501.util.AutonData;
 
 public class Robot extends IterativeRobot {
 
index 75e592bfdcf4b53330882473f5fe1c8de196071e..35019a19853b98b1130d6f5731c23508daeaac68 100644 (file)
@@ -1,17 +1,15 @@
 package org.usfirst.frc.team3501.robot.autons;
 
-import org.usfirst.frc.team3501.robot.Robot;
-
-import edu.wpi.first.wpilibj.command.CommandGroup;
+import org.usfirst.frc.team3501.bases.CommandGroup;
 
 public class ContainerOverStep extends CommandGroup {
 
     public ContainerOverStep() {
         super("ContainerOverStep");
 
-        requires(Robot.drivetrain);
-        requires(Robot.arm);
-        requires(Robot.claw);
+        requires(drivetrain);
+        requires(arm);
+        requires(claw);
 
         queueCommands();
     }
index 3f4b4aac9e3695abc922f5d6c5fc2ed4f4511145..87d82bcb34ae92485c07a358969973bdeaa0c36c 100644 (file)
@@ -1,7 +1,6 @@
 package org.usfirst.frc.team3501.robot.autons;
 
 import org.usfirst.frc.team3501.bases.CommandGroup;
-import org.usfirst.frc.team3501.robot.Robot;
 import org.usfirst.frc.team3501.robot.commands.*;
 
 public class PickUpContainer extends CommandGroup {
@@ -9,8 +8,8 @@ public class PickUpContainer extends CommandGroup {
     public PickUpContainer() {
         super("PickUpContainer");
 
-        requires(Robot.arm);
-        requires(Robot.claw);
+        requires(arm);
+        requires(claw);
 
         queueCommands();
     }
@@ -18,7 +17,7 @@ public class PickUpContainer extends CommandGroup {
     private void queueCommands() {
         addSequential(new CloseClaw());
         addSequential(new MoveArmFor(
-                Robot.autonData.getTime("pickup_container"),
-                Robot.autonData.getSpeed("pickup_container")));
+                autonData.getTime("pickup_container"),
+                autonData.getSpeed("pickup_container")));
     }
 }
diff --git a/src/org/usfirst/frc/team3501/util/AutonData.java b/src/org/usfirst/frc/team3501/util/AutonData.java
new file mode 100644 (file)
index 0000000..df91645
--- /dev/null
@@ -0,0 +1,98 @@
+package org.usfirst.frc.team3501.util;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.HashMap;
+
+public class AutonData {
+
+    HashMap<String, Double> speeds;
+    HashMap<String, Double> times;
+
+    public AutonData() {
+        speeds = new HashMap<String, Double>();
+        times  = new HashMap<String, Double>();
+
+        populate();
+    }
+
+    public double getSpeed(String key) {
+        Double ret = speeds.get(key);
+
+        return (ret != null) ? ret : 0;
+    }
+
+    public double getTime(String key) {
+        Double ret = times.get(key);
+
+        return (ret != null) ? ret : 0;
+    }
+
+    public void update() {
+        speeds.clear();
+        times.clear();
+
+        populate();
+    }
+
+    private void populate() {
+        String file;
+
+        try {
+            file = readConfigFile();
+        } catch (IOException e) {
+            e.printStackTrace();
+            populateDefaults();
+            return;
+        }
+
+        try {
+            Arrays.stream(file.split("\n"))
+            .map(line -> line.split(" "))
+            .forEach((action) -> {
+                double speed = Double.parseDouble(action[0]);
+                double time  = Double.parseDouble(action[1]);
+                String name  = action[2];
+
+                speeds.put(name, speed);
+                times.put(name, time);
+            });
+        } catch (Exception e) {
+            e.printStackTrace();
+            populateDefaults();
+        }
+    }
+
+    private void populateDefaults() {
+        speeds.clear();
+        times.clear();
+
+        speeds.put("drive_over_step",  0.7);
+        speeds.put("drive_past_step",  0.5);
+        speeds.put("pickup_container", 0.5);
+
+        times.put("drive_over_step",  1.2);
+        times.put("drive_past_step",  1.5);
+        times.put("pickup_container", 1.4);
+    }
+
+    private String readConfigFile() throws IOException {
+        BufferedReader in = new BufferedReader(new FileReader(
+                "auton_times_and_speeds.conf"));
+
+        StringBuilder sb = new StringBuilder();
+
+        in.readLine(); // get rid of first line
+
+        String curLine;
+        while ((curLine = in.readLine()) != null)
+            sb.append(curLine + "\n");
+        String finalString = sb.toString();
+
+        in.close();
+
+        return finalString;
+    }
+}