[wpimath] Add BangBangController Usage Reporting (#7411)

This commit is contained in:
sciencewhiz
2024-11-20 17:00:54 -08:00
committed by GitHub
parent d92f17b014
commit 0a3ccf93c6
10 changed files with 27 additions and 2 deletions

View File

@@ -11,6 +11,8 @@
#include <wpi/sendable/Sendable.h>
#include <wpi/sendable/SendableHelper.h>
#include "wpimath/MathShared.h"
namespace frc {
/**
@@ -40,7 +42,13 @@ class WPILIB_DLLEXPORT BangBangController
*/
constexpr explicit BangBangController(
double tolerance = std::numeric_limits<double>::infinity())
: m_tolerance(tolerance) {}
: m_tolerance(tolerance) {
if (!std::is_constant_evaluated()) {
++instances;
wpi::math::MathSharedStore::ReportUsage(
wpi::math::MathUsageId::kController_BangBangController, instances);
}
}
/**
* Sets the setpoint for the bang-bang controller.
@@ -127,6 +135,9 @@ class WPILIB_DLLEXPORT BangBangController
double m_setpoint = 0;
double m_measurement = 0;
// Usage reporting instances
inline static int instances = 0;
};
} // namespace frc

View File

@@ -24,6 +24,7 @@ enum class MathUsageId {
kOdometry_MecanumDrive,
kController_PIDController2,
kController_ProfiledPIDController,
kController_BangBangController,
};
class WPILIB_DLLEXPORT MathShared {