Skip to content

Commit 5a8585b

Browse files
committed
Add support for File Exporting under the Pathfinder class
1 parent 946cfee commit 5a8585b

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

Pathfinder-Java/src/main/java/jaci/pathfinder/Pathfinder.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package jaci.pathfinder;
22

3+
import java.io.File;
4+
35
/**
46
* The main class of the Pathfinder Library. The Pathfinder Library is used for Motion Profile and Trajectory Generation.
57
*
@@ -44,4 +46,40 @@ public static Trajectory generate(Waypoint[] waypoints, Trajectory.Config config
4446
return PathfinderJNI.generateTrajectory(waypoints, config);
4547
}
4648

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+
4785
}

0 commit comments

Comments
 (0)