[hal,wpilib,wpimath] Add Usage Reporting for Choreo and PathWeaver (#7464)

This commit is contained in:
sciencewhiz
2024-11-30 20:33:09 -08:00
committed by GitHub
parent 9807d60566
commit 892e062316
11 changed files with 39 additions and 0 deletions

View File

@@ -38,4 +38,7 @@ public enum MathUsageId {
/** BangBangController. */
kController_BangBangController,
/** PathWeaver Trajectory. */
kTrajectory_PathWeaver,
}

View File

@@ -4,6 +4,8 @@
package edu.wpi.first.math.trajectory;
import edu.wpi.first.math.MathSharedStore;
import edu.wpi.first.math.MathUsageId;
import edu.wpi.first.math.geometry.Pose2d;
import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.math.jni.TrajectoryUtilJNI;
@@ -68,6 +70,8 @@ public final class TrajectoryUtil {
return elements;
}
private static int pathWeaverTrajectoryInstances;
/**
* Imports a Trajectory from a JSON file exported from PathWeaver.
*
@@ -76,6 +80,8 @@ public final class TrajectoryUtil {
* @throws IOException if reading from the file fails.
*/
public static Trajectory fromPathweaverJson(Path path) throws IOException {
MathSharedStore.reportUsage(
MathUsageId.kTrajectory_PathWeaver, ++pathWeaverTrajectoryInstances);
return createTrajectoryFromElements(TrajectoryUtilJNI.fromPathweaverJson(path.toString()));
}