mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
[wpimath] Add BangBangController Usage Reporting (#7411)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -24,6 +24,7 @@ enum class MathUsageId {
|
||||
kOdometry_MecanumDrive,
|
||||
kController_PIDController2,
|
||||
kController_ProfiledPIDController,
|
||||
kController_BangBangController,
|
||||
};
|
||||
|
||||
class WPILIB_DLLEXPORT MathShared {
|
||||
|
||||
Reference in New Issue
Block a user