mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-30 02:31:44 +00:00
[hal] Change usage reporting to string-based (#7763)
This commit is contained in:
@@ -45,8 +45,8 @@ class WPILIB_DLLEXPORT BangBangController
|
||||
: m_tolerance(tolerance) {
|
||||
if (!std::is_constant_evaluated()) {
|
||||
++instances;
|
||||
wpi::math::MathSharedStore::ReportUsage(
|
||||
wpi::math::MathUsageId::kController_BangBangController, instances);
|
||||
wpi::math::MathSharedStore::ReportUsage("BangBangController",
|
||||
std::to_string(instances));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,8 +74,8 @@ class WPILIB_DLLEXPORT PIDController
|
||||
if (!std::is_constant_evaluated()) {
|
||||
++instances;
|
||||
|
||||
wpi::math::MathSharedStore::ReportUsage(
|
||||
wpi::math::MathUsageId::kController_PIDController2, instances);
|
||||
wpi::math::MathSharedStore::ReportUsage("PIDController",
|
||||
std::to_string(instances));
|
||||
wpi::SendableRegistry::Add(this, "PIDController", instances);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,8 +63,8 @@ class ProfiledPIDController
|
||||
m_profile{m_constraints} {
|
||||
if (!std::is_constant_evaluated()) {
|
||||
int instances = detail::IncrementAndGetProfiledPIDControllerInstances();
|
||||
wpi::math::MathSharedStore::ReportUsage(
|
||||
wpi::math::MathUsageId::kController_ProfiledPIDController, instances);
|
||||
wpi::math::MathSharedStore::ReportUsage("ProfiledPIDController",
|
||||
std::to_string(instances));
|
||||
wpi::SendableRegistry::Add(this, "ProfiledPIDController", instances);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,8 +96,8 @@ class LinearFilter {
|
||||
|
||||
if (!std::is_constant_evaluated()) {
|
||||
++instances;
|
||||
wpi::math::MathSharedStore::ReportUsage(
|
||||
wpi::math::MathUsageId::kFilter_Linear, instances);
|
||||
wpi::math::MathSharedStore::ReportUsage("LinearFilter",
|
||||
std::to_string(instances));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,8 +41,8 @@ class WPILIB_DLLEXPORT DifferentialDriveKinematics
|
||||
constexpr explicit DifferentialDriveKinematics(units::meter_t trackWidth)
|
||||
: trackWidth(trackWidth) {
|
||||
if (!std::is_constant_evaluated()) {
|
||||
wpi::math::MathSharedStore::ReportUsage(
|
||||
wpi::math::MathUsageId::kKinematics_DifferentialDrive, 1);
|
||||
wpi::math::MathSharedStore::ReportUsage("DifferentialDriveKinematics",
|
||||
"");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,8 +66,7 @@ class WPILIB_DLLEXPORT MecanumDriveKinematics
|
||||
SetInverseKinematics(frontLeftWheel, frontRightWheel, rearLeftWheel,
|
||||
rearRightWheel);
|
||||
m_forwardKinematics = m_inverseKinematics.householderQr();
|
||||
wpi::math::MathSharedStore::ReportUsage(
|
||||
wpi::math::MathUsageId::kKinematics_MecanumDrive, 1);
|
||||
wpi::math::MathSharedStore::ReportUsage("MecanumDriveKinematics", "");
|
||||
}
|
||||
|
||||
MecanumDriveKinematics(const MecanumDriveKinematics&) = default;
|
||||
|
||||
@@ -78,8 +78,7 @@ class SwerveDriveKinematics
|
||||
|
||||
m_forwardKinematics = m_inverseKinematics.householderQr();
|
||||
|
||||
wpi::math::MathSharedStore::ReportUsage(
|
||||
wpi::math::MathUsageId::kKinematics_SwerveDrive, 1);
|
||||
wpi::math::MathSharedStore::ReportUsage("SwerveDriveKinematics", "");
|
||||
}
|
||||
|
||||
explicit SwerveDriveKinematics(
|
||||
@@ -95,8 +94,7 @@ class SwerveDriveKinematics
|
||||
|
||||
m_forwardKinematics = m_inverseKinematics.householderQr();
|
||||
|
||||
wpi::math::MathSharedStore::ReportUsage(
|
||||
wpi::math::MathUsageId::kKinematics_SwerveDrive, 1);
|
||||
wpi::math::MathSharedStore::ReportUsage("Kinematics_SwerveDrive", "");
|
||||
}
|
||||
|
||||
SwerveDriveKinematics(const SwerveDriveKinematics&) = default;
|
||||
|
||||
@@ -48,8 +48,7 @@ class SwerveDriveOdometry
|
||||
: SwerveDriveOdometry::Odometry(m_kinematicsImpl, gyroAngle,
|
||||
modulePositions, initialPose),
|
||||
m_kinematicsImpl(kinematics) {
|
||||
wpi::math::MathSharedStore::ReportUsage(
|
||||
wpi::math::MathUsageId::kOdometry_SwerveDrive, 1);
|
||||
wpi::math::MathSharedStore::ReportUsage("SwerveDriveOdometry", "");
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -53,8 +53,7 @@ class SwerveDriveOdometry3d
|
||||
: SwerveDriveOdometry3d::Odometry3d(m_kinematicsImpl, gyroAngle,
|
||||
modulePositions, initialPose),
|
||||
m_kinematicsImpl(kinematics) {
|
||||
wpi::math::MathSharedStore::ReportUsage(
|
||||
wpi::math::MathUsageId::kOdometry_SwerveDrive, 1);
|
||||
wpi::math::MathSharedStore::ReportUsage("SwerveDriveOdometry3d", "");
|
||||
}
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
@@ -69,8 +69,7 @@ class TrapezoidProfile {
|
||||
*/
|
||||
constexpr Constraints() {
|
||||
if (!std::is_constant_evaluated()) {
|
||||
wpi::math::MathSharedStore::ReportUsage(
|
||||
wpi::math::MathUsageId::kTrajectory_TrapezoidProfile, 1);
|
||||
wpi::math::MathSharedStore::ReportUsage("TrapezoidProfile", "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,8 +83,7 @@ class TrapezoidProfile {
|
||||
Acceleration_t maxAcceleration)
|
||||
: maxVelocity{maxVelocity}, maxAcceleration{maxAcceleration} {
|
||||
if (!std::is_constant_evaluated()) {
|
||||
wpi::math::MathSharedStore::ReportUsage(
|
||||
wpi::math::MathUsageId::kTrajectory_TrapezoidProfile, 1);
|
||||
wpi::math::MathSharedStore::ReportUsage("TrapezoidProfile", "");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -13,28 +13,14 @@
|
||||
|
||||
namespace wpi::math {
|
||||
|
||||
enum class MathUsageId {
|
||||
kKinematics_DifferentialDrive,
|
||||
kKinematics_MecanumDrive,
|
||||
kKinematics_SwerveDrive,
|
||||
kTrajectory_TrapezoidProfile,
|
||||
kFilter_Linear,
|
||||
kOdometry_DifferentialDrive,
|
||||
kOdometry_SwerveDrive,
|
||||
kOdometry_MecanumDrive,
|
||||
kController_PIDController2,
|
||||
kController_ProfiledPIDController,
|
||||
kController_BangBangController,
|
||||
kTrajectory_PathWeaver,
|
||||
};
|
||||
|
||||
class WPILIB_DLLEXPORT MathShared {
|
||||
public:
|
||||
virtual ~MathShared() = default;
|
||||
virtual void ReportErrorV(fmt::string_view format, fmt::format_args args) = 0;
|
||||
virtual void ReportWarningV(fmt::string_view format,
|
||||
fmt::format_args args) = 0;
|
||||
virtual void ReportUsage(MathUsageId id, int count) = 0;
|
||||
virtual void ReportUsage(std::string_view resource,
|
||||
std::string_view data) = 0;
|
||||
virtual units::second_t GetTimestamp() = 0;
|
||||
|
||||
template <typename S, typename... Args>
|
||||
@@ -72,8 +58,8 @@ class WPILIB_DLLEXPORT MathSharedStore {
|
||||
ReportWarningV(format, fmt::make_format_args(args...));
|
||||
}
|
||||
|
||||
static void ReportUsage(MathUsageId id, int count) {
|
||||
GetMathShared().ReportUsage(id, count);
|
||||
static void ReportUsage(std::string_view resource, std::string_view data) {
|
||||
GetMathShared().ReportUsage(resource, data);
|
||||
}
|
||||
|
||||
static units::second_t GetTimestamp() {
|
||||
|
||||
Reference in New Issue
Block a user