Skip to content

Commit

Permalink
Add support for File Exporting under the Pathfinder class
Browse files Browse the repository at this point in the history
  • Loading branch information
JaciBrunning committed Mar 28, 2016
1 parent 946cfee commit 5a8585b
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Pathfinder-Java/src/main/java/jaci/pathfinder/Pathfinder.java
Original file line number Diff line number Diff line change
@@ -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.
*
Expand Down Expand Up @@ -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()));
}

}

0 comments on commit 5a8585b

Please sign in to comment.