[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

@@ -114,3 +114,4 @@ kResourceType_Redux_future4 = 112
kResourceType_Redux_future5 = 113
kResourceType_RevSparkFlexCAN = 114
kResourceType_RevSparkFlexPWM = 115
kResourceType_BangBangController = 116

View File

@@ -251,6 +251,8 @@ public final class FRCNetComm {
public static final int kResourceType_RevSparkFlexCAN = 114;
/** kResourceType_RevSparkFlexPWM = 115. */
public static final int kResourceType_RevSparkFlexPWM = 115;
/** kResourceType_BangBangController = 116. */
public static final int kResourceType_BangBangController = 116;
}
/**

View File

@@ -167,6 +167,7 @@ namespace HALUsageReporting {
kResourceType_Redux_future5 = 113,
kResourceType_RevSparkFlexCAN = 114,
kResourceType_RevSparkFlexPWM = 115,
kResourceType_BangBangController = 116,
};
enum tInstances : int32_t {
kLanguage_LabVIEW = 1,

View File

@@ -136,6 +136,7 @@ typedef enum
kResourceType_Redux_future5 = 113,
kResourceType_RevSparkFlexCAN = 114,
kResourceType_RevSparkFlexPWM = 115,
kResourceType_BangBangController = 116,
// kResourceType_MaximumID = 255,
} tResourceType;

View File

@@ -139,6 +139,9 @@ class WPILibMathShared : public wpi::math::MathShared {
HAL_Report(HALUsageReporting::kResourceType_ProfiledPIDController,
count);
break;
case wpi::math::MathUsageId::kController_BangBangController:
HAL_Report(HALUsageReporting::kResourceType_BangBangController, count);
break;
}
}

View File

@@ -115,6 +115,8 @@ public abstract class RobotBase implements AutoCloseable {
tResourceType.kResourceType_PIDController2, count);
case kController_ProfiledPIDController -> HAL.report(
tResourceType.kResourceType_ProfiledPIDController, count);
case kController_BangBangController -> HAL.report(
tResourceType.kResourceType_BangBangController, count);
default -> {
// NOP
}

View File

@@ -35,4 +35,7 @@ public enum MathUsageId {
/** ProfiledPIDController. */
kController_ProfiledPIDController,
/** BangBangController. */
kController_BangBangController,
}

View File

@@ -45,7 +45,7 @@ public class BangBangController implements Sendable {
SendableRegistry.addLW(this, "BangBangController", instances);
MathSharedStore.reportUsage(MathUsageId.kController_PIDController2, instances);
MathSharedStore.reportUsage(MathUsageId.kController_BangBangController, instances);
}
/**

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 {