Guest User

Untitled

a guest
Feb 22nd, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. package org.usfirst.frc.team1797.robot.utils;
  2.  
  3. import java.io.File;
  4. import java.util.Arrays;
  5. import java.util.HashMap;
  6.  
  7. import org.usfirst.frc.team1797.robot.commands.auto.AutoRunner.Routine;
  8.  
  9. import jaci.pathfinder.Pathfinder;
  10. import jaci.pathfinder.Trajectory;
  11.  
  12. /*
  13. * Created by techtide/greenie/ab for Phoenix 1797 of ASL Robotics.
  14. */
  15.  
  16. public class TrajectoryUtils {
  17. private HashMap<String, Trajectory> fileTrajectoryMap;
  18. private String path = "/home/lvuser/";
  19.  
  20. public TrajectoryUtils() {
  21. fileTrajectoryMap = new HashMap<>();
  22. initialiseFileTrajectoryMap();
  23. }
  24.  
  25. public void initialiseFileTrajectoryMap() {
  26. // Instantiates and reads all files into a map based on the format of "File/routine name":Trajectory.
  27. File folderPath = new File(path + "trajectories/");
  28. File[] folder = folderPath.listFiles();
  29. for(File file : folder) {
  30. fileTrajectoryMap.put(file.getName(), Pathfinder.readFromCSV(file));
  31. }
  32. System.out.println("[TrajectoryManager: initFileTrajectoryMap] The files in the trajectory hashmap are: "
  33. + fileTrajectoryMap);
  34. }
  35.  
  36. public Trajectory csvToTrajectory(Routine routineToRun, char direction) {
  37. // File f = new File(path + "trajectories/" + routineToRun.name() + direction + ".csv");
  38. // System.out.println("[TrajectoryManager: csvToTrajectory] The file's name is: " + f.getName());
  39. // return Pathfinder.readFromCSV(f);
  40. System.out.println("CSV FILE NAME: "+ routineToRun.name().toUpperCase() + direction + ".csv");
  41. return fileTrajectoryMap.get(routineToRun.name().toUpperCase() + direction + ".csv");
  42. }
  43. }
Add Comment
Please, Sign In to add comment