[wpimath] Add usage reporting for state-space classes (#8453)

- LinearQuadraticRegulator
- Kalman filters
- Pose estimators
- LinearSystemLoop

Fixes #2925.
This commit is contained in:
Peter Johnson
2025-12-06 09:17:02 -08:00
committed by GitHub
parent 0d1dd84e86
commit baa6379267
20 changed files with 95 additions and 0 deletions

View File

@@ -135,6 +135,8 @@ class LinearQuadraticRegulator {
}
Reset();
wpi::math::MathSharedStore::ReportUsage(
wpi::math::MathUsageId::kController_LinearQuadraticRegulator, 1);
}
/**
@@ -194,6 +196,8 @@ class LinearQuadraticRegulator {
}
Reset();
wpi::math::MathSharedStore::ReportUsage(
wpi::math::MathUsageId::kController_LinearQuadraticRegulator, 1);
}
LinearQuadraticRegulator(LinearQuadraticRegulator&&) = default;

View File

@@ -137,6 +137,8 @@ class ExtendedKalmanFilter {
m_initP = StateMatrix::Zero();
}
m_P = m_initP;
wpi::math::MathSharedStore::ReportUsage(
wpi::math::MathUsageId::kEstimator_KalmanFilter, 2);
}
/**
@@ -221,6 +223,8 @@ class ExtendedKalmanFilter {
m_initP = StateMatrix::Zero();
}
m_P = m_initP;
wpi::math::MathSharedStore::ReportUsage(
wpi::math::MathUsageId::kEstimator_KalmanFilter, 2);
}
/**

View File

@@ -118,6 +118,8 @@ class KalmanFilter {
}
Reset();
wpi::math::MathSharedStore::ReportUsage(
wpi::math::MathUsageId::kEstimator_KalmanFilter, 1);
}
/**

View File

@@ -70,6 +70,8 @@ class WPILIB_DLLEXPORT PoseEstimator {
}
SetVisionMeasurementStdDevs(visionMeasurementStdDevs);
wpi::math::MathSharedStore::ReportUsage(
wpi::math::MathUsageId::kEstimator_PoseEstimator, 1);
}
/**

View File

@@ -76,6 +76,8 @@ class WPILIB_DLLEXPORT PoseEstimator3d {
}
SetVisionMeasurementStdDevs(visionMeasurementStdDevs);
wpi::math::MathSharedStore::ReportUsage(
wpi::math::MathUsageId::kEstimator_PoseEstimator3d, 1);
}
/**

View File

@@ -149,6 +149,8 @@ class SteadyStateKalmanFilter {
}
Reset();
wpi::math::MathSharedStore::ReportUsage(
wpi::math::MathUsageId::kEstimator_KalmanFilter, 4);
}
SteadyStateKalmanFilter(SteadyStateKalmanFilter&&) = default;

View File

@@ -107,6 +107,8 @@ class UnscentedKalmanFilter {
m_dt = dt;
Reset();
wpi::math::MathSharedStore::ReportUsage(
wpi::math::MathUsageId::kEstimator_KalmanFilter, 3);
}
/**
@@ -166,6 +168,8 @@ class UnscentedKalmanFilter {
m_dt = dt;
Reset();
wpi::math::MathSharedStore::ReportUsage(
wpi::math::MathUsageId::kEstimator_KalmanFilter, 3);
}
/**

View File

@@ -129,6 +129,8 @@ class LinearSystemLoop {
m_clampFunc(clampFunction) {
m_nextR.setZero();
Reset(m_nextR);
wpi::math::MathSharedStore::ReportUsage(
wpi::math::MathUsageId::kSystem_LinearSystemLoop, 1);
}
LinearSystemLoop(LinearSystemLoop&&) = default;

View File

@@ -26,6 +26,11 @@ enum class MathUsageId {
kController_ProfiledPIDController,
kController_BangBangController,
kTrajectory_PathWeaver,
kController_LinearQuadraticRegulator,
kEstimator_KalmanFilter,
kEstimator_PoseEstimator,
kEstimator_PoseEstimator3d,
kSystem_LinearSystemLoop,
};
class WPILIB_DLLEXPORT MathShared {