mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[hal,wpilib,wpimath] Add Usage Reporting for Choreo and PathWeaver (#7464)
This commit is contained in:
@@ -117,3 +117,6 @@ kResourceType_RevSparkFlexPWM = 115
|
||||
kResourceType_BangBangController = 116
|
||||
kResourceType_DataLogManager = 117
|
||||
kResourceType_LoggingFramework = 118
|
||||
kResourceType_ChoreoTrajectory = 119
|
||||
kResourceType_ChoreoTrigger = 120
|
||||
kResourceType_PathWeaverTrajectory = 121
|
||||
|
||||
@@ -257,6 +257,12 @@ public final class FRCNetComm {
|
||||
public static final int kResourceType_DataLogManager = 117;
|
||||
/** kResourceType_LoggingFramework = 118. */
|
||||
public static final int kResourceType_LoggingFramework = 118;
|
||||
/** kResourceType_ChoreoTrajectory = 119. */
|
||||
public static final int kResourceType_ChoreoTrajectory = 119;
|
||||
/** kResourceType_ChoreoTrigger = 120. */
|
||||
public static final int kResourceType_ChoreoTrigger = 120;
|
||||
/** kResourceType_PathWeaverTrajectory = 121. */
|
||||
public static final int kResourceType_PathWeaverTrajectory = 121;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -170,6 +170,9 @@ namespace HALUsageReporting {
|
||||
kResourceType_BangBangController = 116,
|
||||
kResourceType_DataLogManager = 117,
|
||||
kResourceType_LoggingFramework = 118,
|
||||
kResourceType_ChoreoTrajectory = 119,
|
||||
kResourceType_ChoreoTrigger = 120,
|
||||
kResourceType_PathWeaverTrajectory = 121,
|
||||
};
|
||||
enum tInstances : int32_t {
|
||||
kLanguage_LabVIEW = 1,
|
||||
|
||||
@@ -139,6 +139,9 @@ typedef enum
|
||||
kResourceType_BangBangController = 116,
|
||||
kResourceType_DataLogManager = 117,
|
||||
kResourceType_LoggingFramework = 118,
|
||||
kResourceType_ChoreoTrajectory = 119,
|
||||
kResourceType_ChoreoTrigger = 120,
|
||||
kResourceType_PathWeaverTrajectory = 121,
|
||||
|
||||
// kResourceType_MaximumID = 255,
|
||||
} tResourceType;
|
||||
|
||||
@@ -142,6 +142,10 @@ class WPILibMathShared : public wpi::math::MathShared {
|
||||
case wpi::math::MathUsageId::kController_BangBangController:
|
||||
HAL_Report(HALUsageReporting::kResourceType_BangBangController, count);
|
||||
break;
|
||||
case wpi::math::MathUsageId::kTrajectory_PathWeaver:
|
||||
HAL_Report(HALUsageReporting::kResourceType_PathWeaverTrajectory,
|
||||
count);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -117,6 +117,8 @@ public abstract class RobotBase implements AutoCloseable {
|
||||
tResourceType.kResourceType_ProfiledPIDController, count);
|
||||
case kController_BangBangController -> HAL.report(
|
||||
tResourceType.kResourceType_BangBangController, count);
|
||||
case kTrajectory_PathWeaver -> HAL.report(
|
||||
tResourceType.kResourceType_PathWeaverTrajectory, count);
|
||||
default -> {
|
||||
// NOP
|
||||
}
|
||||
|
||||
@@ -38,4 +38,7 @@ public enum MathUsageId {
|
||||
|
||||
/** BangBangController. */
|
||||
kController_BangBangController,
|
||||
|
||||
/** PathWeaver Trajectory. */
|
||||
kTrajectory_PathWeaver,
|
||||
}
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,10 @@ Trajectory TrajectoryUtil::FromPathweaverJson(std::string_view path) {
|
||||
|
||||
wpi::json json = wpi::json::parse(fileBuffer.value()->GetCharBuffer());
|
||||
|
||||
wpi::math::MathSharedStore::ReportUsage(
|
||||
wpi::math::MathUsageId::kTrajectory_PathWeaver,
|
||||
++pathWeaverTrajectoryInstances);
|
||||
|
||||
return Trajectory{json.get<std::vector<Trajectory::State>>()};
|
||||
}
|
||||
|
||||
|
||||
@@ -53,5 +53,9 @@ class WPILIB_DLLEXPORT TrajectoryUtil {
|
||||
* @return the trajectory represented by the JSON
|
||||
*/
|
||||
static Trajectory DeserializeTrajectory(std::string_view jsonStr);
|
||||
|
||||
private:
|
||||
// Usage reporting for PathWeaver Trajectory instances
|
||||
inline static int pathWeaverTrajectoryInstances = 0;
|
||||
};
|
||||
} // namespace frc
|
||||
|
||||
@@ -25,6 +25,7 @@ enum class MathUsageId {
|
||||
kController_PIDController2,
|
||||
kController_ProfiledPIDController,
|
||||
kController_BangBangController,
|
||||
kTrajectory_PathWeaver,
|
||||
};
|
||||
|
||||
class WPILIB_DLLEXPORT MathShared {
|
||||
|
||||
Reference in New Issue
Block a user