diff --git a/Pathfinder-Java/src/main/java/jaci/pathfinder/Pathfinder.java b/Pathfinder-Java/src/main/java/jaci/pathfinder/Pathfinder.java index 67d238e..7460d08 100644 --- a/Pathfinder-Java/src/main/java/jaci/pathfinder/Pathfinder.java +++ b/Pathfinder-Java/src/main/java/jaci/pathfinder/Pathfinder.java @@ -1,5 +1,7 @@ package jaci.pathfinder; +import java.io.File; + /** * The main class of the Pathfinder Library. The Pathfinder Library is used for Motion Profile and Trajectory Generation. * @@ -44,4 +46,40 @@ public static Trajectory generate(Waypoint[] waypoints, Trajectory.Config config return PathfinderJNI.generateTrajectory(waypoints, config); } + /** + * Write the Trajectory to a Binary (non human readable) file + * @param file The file to write to + * @param trajectory The trajectory to write + */ + public static void writeToFile(File file, Trajectory trajectory) { + PathfinderJNI.trajectorySerialize(trajectory.segments, file.getAbsolutePath()); + } + + /** + * Read a Trajectory from a Binary (non human readable) file + * @param file The file to read from + * @return The trajectory that was read from file + */ + public static Trajectory readFromFile(File file) { + return new Trajectory(PathfinderJNI.trajectoryDeserialize(file.getAbsolutePath())); + } + + /** + * Write the Trajectory to a CSV File + * @param file The file to write to + * @param trajectory The trajectory to write + */ + public static void writeToCSV(File file, Trajectory trajectory) { + PathfinderJNI.trajectorySerializeCSV(trajectory.segments, file.getAbsolutePath()); + } + + /** + * Read a Trajectory from a CSV File + * @param file The file to read from + * @return The trajectory that was read from file + */ + public static Trajectory readFromCSV(File file) { + return new Trajectory(PathfinderJNI.trajectoryDeserializeCSV(file.getAbsolutePath())); + } + }