|
1 | 1 | package jaci.pathfinder;
|
2 | 2 |
|
| 3 | +import java.io.File; |
| 4 | + |
3 | 5 | /**
|
4 | 6 | * The main class of the Pathfinder Library. The Pathfinder Library is used for Motion Profile and Trajectory Generation.
|
5 | 7 | *
|
@@ -44,4 +46,40 @@ public static Trajectory generate(Waypoint[] waypoints, Trajectory.Config config
|
44 | 46 | return PathfinderJNI.generateTrajectory(waypoints, config);
|
45 | 47 | }
|
46 | 48 |
|
| 49 | + /** |
| 50 | + * Write the Trajectory to a Binary (non human readable) file |
| 51 | + * @param file The file to write to |
| 52 | + * @param trajectory The trajectory to write |
| 53 | + */ |
| 54 | + public static void writeToFile(File file, Trajectory trajectory) { |
| 55 | + PathfinderJNI.trajectorySerialize(trajectory.segments, file.getAbsolutePath()); |
| 56 | + } |
| 57 | + |
| 58 | + /** |
| 59 | + * Read a Trajectory from a Binary (non human readable) file |
| 60 | + * @param file The file to read from |
| 61 | + * @return The trajectory that was read from file |
| 62 | + */ |
| 63 | + public static Trajectory readFromFile(File file) { |
| 64 | + return new Trajectory(PathfinderJNI.trajectoryDeserialize(file.getAbsolutePath())); |
| 65 | + } |
| 66 | + |
| 67 | + /** |
| 68 | + * Write the Trajectory to a CSV File |
| 69 | + * @param file The file to write to |
| 70 | + * @param trajectory The trajectory to write |
| 71 | + */ |
| 72 | + public static void writeToCSV(File file, Trajectory trajectory) { |
| 73 | + PathfinderJNI.trajectorySerializeCSV(trajectory.segments, file.getAbsolutePath()); |
| 74 | + } |
| 75 | + |
| 76 | + /** |
| 77 | + * Read a Trajectory from a CSV File |
| 78 | + * @param file The file to read from |
| 79 | + * @return The trajectory that was read from file |
| 80 | + */ |
| 81 | + public static Trajectory readFromCSV(File file) { |
| 82 | + return new Trajectory(PathfinderJNI.trajectoryDeserializeCSV(file.getAbsolutePath())); |
| 83 | + } |
| 84 | + |
47 | 85 | }
|
0 commit comments