mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[wpimath] Use JNI for trajectory serialization (#3257)
This commit is contained in:
committed by
GitHub
parent
3de800a607
commit
4d28b1f0cd
@@ -91,6 +91,38 @@ public final class WPIMathJNI {
|
||||
*/
|
||||
public static native boolean isStabilizable(int states, int inputs, double[] A, double[] B);
|
||||
|
||||
/**
|
||||
* Loads a Pathweaver JSON.
|
||||
*
|
||||
* @param path The path to the JSON.
|
||||
* @return A double array with the trajectory states from the JSON.
|
||||
*/
|
||||
public static native double[] fromPathweaverJson(String path) throws IOException;
|
||||
|
||||
/**
|
||||
* Converts a trajectory into a Pathweaver JSON and saves it.
|
||||
*
|
||||
* @param elements The elements of the trajectory.
|
||||
* @param path The location to save the JSON to.
|
||||
*/
|
||||
public static native void toPathweaverJson(double[] elements, String path) throws IOException;
|
||||
|
||||
/**
|
||||
* Deserializes a trajectory JSON into a double[] of trajectory elements.
|
||||
*
|
||||
* @param json The JSON containing the serialized trajectory.
|
||||
* @return A double array with the trajectory states.
|
||||
*/
|
||||
public static native double[] deserializeTrajectory(String json);
|
||||
|
||||
/**
|
||||
* Serializes the trajectory into a JSON string.
|
||||
*
|
||||
* @param elements The elements of the trajectory.
|
||||
* @return A JSON containing the serialized trajectory.
|
||||
*/
|
||||
public static native String serializeTrajectory(double[] elements);
|
||||
|
||||
public static class Helper {
|
||||
private static AtomicBoolean extractOnStaticLoad = new AtomicBoolean(true);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user