[hal] Change usage reporting to string-based (#7763)

This commit is contained in:
Peter Johnson
2025-02-07 12:37:23 -08:00
committed by GitHub
parent bfff891b5c
commit 764ada9b66
188 changed files with 637 additions and 2298 deletions

View File

@@ -4,7 +4,7 @@
#include "frc/ADXL345_I2C.h"
#include <hal/FRCUsageReporting.h>
#include <hal/UsageReporting.h>
#include <networktables/DoubleTopic.h>
#include <networktables/NTSendableBuilder.h>
#include <wpi/sendable/SendableRegistry.h>
@@ -27,8 +27,9 @@ ADXL345_I2C::ADXL345_I2C(I2C::Port port, Range range, int deviceAddress)
// Specify the data format to read
SetRange(range);
HAL_Report(HALUsageReporting::kResourceType_ADXL345,
HALUsageReporting::kADXL345_I2C, 0);
HAL_ReportUsage(
fmt::format("I2C[{}][{}]", static_cast<int>(port), deviceAddress),
"ADXL345");
wpi::SendableRegistry::Add(this, "ADXL345_I2C", port);
}

View File

@@ -5,10 +5,10 @@
#include "frc/AddressableLED.h"
#include <hal/AddressableLED.h>
#include <hal/FRCUsageReporting.h>
#include <hal/HALBase.h>
#include <hal/PWM.h>
#include <hal/Ports.h>
#include <hal/UsageReporting.h>
#include <wpi/StackTrace.h>
#include "frc/Errors.h"
@@ -31,7 +31,7 @@ AddressableLED::AddressableLED(int port) : m_port{port} {
HAL_FreePWMPort(m_pwmHandle);
}
HAL_Report(HALUsageReporting::kResourceType_AddressableLEDs, port + 1);
HAL_ReportUsage("IO", port, "AddressableLED");
}
void AddressableLED::SetLength(int length) {

View File

@@ -4,7 +4,7 @@
#include "frc/AnalogAccelerometer.h"
#include <hal/FRCUsageReporting.h>
#include <hal/UsageReporting.h>
#include <wpi/NullDeleter.h>
#include <wpi/sendable/SendableBuilder.h>
#include <wpi/sendable/SendableRegistry.h>
@@ -53,8 +53,7 @@ void AnalogAccelerometer::InitSendable(wpi::SendableBuilder& builder) {
}
void AnalogAccelerometer::InitAccelerometer() {
HAL_Report(HALUsageReporting::kResourceType_Accelerometer,
m_analogInput->GetChannel() + 1);
HAL_ReportUsage("IO", m_analogInput->GetChannel(), "Accelerometer");
wpi::SendableRegistry::Add(this, "Accelerometer",
m_analogInput->GetChannel());

View File

@@ -6,6 +6,7 @@
#include <utility>
#include <hal/UsageReporting.h>
#include <wpi/NullDeleter.h>
#include <wpi/sendable/SendableBuilder.h>
@@ -67,6 +68,8 @@ void AnalogEncoder::Init(double fullRange, double expectedZero) {
m_fullRange = fullRange;
m_expectedZero = expectedZero;
HAL_ReportUsage("IO", m_analogInput->GetChannel(), "AnalogEncoder");
wpi::SendableRegistry::Add(this, "Analog Encoder",
m_analogInput->GetChannel());
}

View File

@@ -7,9 +7,9 @@
#include <string>
#include <hal/AnalogInput.h>
#include <hal/FRCUsageReporting.h>
#include <hal/HALBase.h>
#include <hal/Ports.h>
#include <hal/UsageReporting.h>
#include <wpi/StackTrace.h>
#include <wpi/sendable/SendableBuilder.h>
#include <wpi/sendable/SendableRegistry.h>
@@ -31,7 +31,7 @@ AnalogInput::AnalogInput(int channel) {
m_port = HAL_InitializeAnalogInputPort(channel, stackTrace.c_str(), &status);
FRC_CheckErrorStatus(status, "Channel {}", channel);
HAL_Report(HALUsageReporting::kResourceType_AnalogChannel, channel + 1);
HAL_ReportUsage("IO", channel, "AnalogInput");
wpi::SendableRegistry::Add(this, "AnalogInput", channel);
}

View File

@@ -9,20 +9,13 @@
#include <hal/CAN.h>
#include <hal/CANAPI.h>
#include <hal/Errors.h>
#include <hal/FRCUsageReporting.h>
#include <hal/UsageReporting.h>
#include "frc/Errors.h"
using namespace frc;
CAN::CAN(int deviceId) {
int32_t status = 0;
m_handle =
HAL_InitializeCAN(kTeamManufacturer, deviceId, kTeamDeviceType, &status);
FRC_CheckErrorStatus(status, "device id {}", deviceId);
HAL_Report(HALUsageReporting::kResourceType_CAN, deviceId + 1);
}
CAN::CAN(int deviceId) : CAN{kTeamManufacturer, deviceId, kTeamDeviceType} {}
CAN::CAN(int deviceId, int deviceManufacturer, int deviceType) {
int32_t status = 0;
@@ -32,7 +25,9 @@ CAN::CAN(int deviceId, int deviceManufacturer, int deviceType) {
FRC_CheckErrorStatus(status, "device id {} mfg {} type {}", deviceId,
deviceManufacturer, deviceType);
HAL_Report(HALUsageReporting::kResourceType_CAN, deviceId + 1);
HAL_ReportUsage(
fmt::format("CAN[{}][{}][{}]", deviceType, deviceManufacturer, deviceId),
"");
}
void CAN::WritePacket(const uint8_t* data, int length, int apiId) {

View File

@@ -6,7 +6,6 @@
#include <frc/PneumaticHub.h>
#include <hal/FRCUsageReporting.h>
#include <hal/Ports.h>
#include <wpi/sendable/SendableBuilder.h>
#include <wpi/sendable/SendableRegistry.h>
@@ -24,7 +23,7 @@ Compressor::Compressor(int module, PneumaticsModuleType moduleType)
m_module->EnableCompressorDigital();
HAL_Report(HALUsageReporting::kResourceType_Compressor, module + 1);
m_module->ReportUsage("Compressor", "");
wpi::SendableRegistry::Add(this, "Compressor", module);
}

View File

@@ -13,7 +13,7 @@
#include <vector>
#include <fmt/chrono.h>
#include <hal/FRCUsageReporting.h>
#include <hal/UsageReporting.h>
#include <networktables/NetworkTableInstance.h>
#include <wpi/DataLog.h>
#include <wpi/DataLogBackgroundWriter.h>
@@ -79,8 +79,7 @@ static std::string MakeLogDir(std::string_view dir) {
(s.permissions() & fs::perms::others_write) != fs::perms::none) {
fs::create_directory("/u/logs", ec);
return "/u/logs";
HAL_Report(HALUsageReporting::kResourceType_DataLogManager,
HALUsageReporting::kDataLogLocation_USB);
HAL_ReportUsage("DataLogManager", "USB");
}
if (RobotBase::GetRuntimeType() == kRoboRIO) {
FRC_ReportWarning(
@@ -88,8 +87,7 @@ static std::string MakeLogDir(std::string_view dir) {
"not recommended! Plug in a FAT32 formatted flash drive!");
}
fs::create_directory("/home/lvuser/logs", ec);
HAL_Report(HALUsageReporting::kResourceType_DataLogManager,
HALUsageReporting::kDataLogLocation_Onboard);
HAL_ReportUsage("DataLogManager", "Onboard");
return "/home/lvuser/logs";
#else
std::string logDir = filesystem::GetOperatingDirectory() + "/logs";

View File

@@ -7,9 +7,9 @@
#include <string>
#include <hal/DIO.h>
#include <hal/FRCUsageReporting.h>
#include <hal/HALBase.h>
#include <hal/Ports.h>
#include <hal/UsageReporting.h>
#include <wpi/StackTrace.h>
#include <wpi/sendable/SendableBuilder.h>
#include <wpi/sendable/SendableRegistry.h>
@@ -30,7 +30,7 @@ DigitalInput::DigitalInput(int channel) {
m_handle = HAL_InitializeDIOPort(channel, true, stackTrace.c_str(), &status);
FRC_CheckErrorStatus(status, "Channel {}", channel);
HAL_Report(HALUsageReporting::kResourceType_DigitalInput, channel + 1);
HAL_ReportUsage("IO", channel, "DigitalInput");
wpi::SendableRegistry::Add(this, "DigitalInput", channel);
}

View File

@@ -7,9 +7,9 @@
#include <string>
#include <hal/DIO.h>
#include <hal/FRCUsageReporting.h>
#include <hal/HALBase.h>
#include <hal/Ports.h>
#include <hal/UsageReporting.h>
#include <wpi/StackTrace.h>
#include <wpi/sendable/SendableBuilder.h>
#include <wpi/sendable/SendableRegistry.h>
@@ -31,7 +31,7 @@ DigitalOutput::DigitalOutput(int channel) {
m_handle = HAL_InitializeDIOPort(channel, false, stackTrace.c_str(), &status);
FRC_CheckErrorStatus(status, "Channel {}", channel);
HAL_Report(HALUsageReporting::kResourceType_DigitalOutput, channel + 1);
HAL_ReportUsage("IO", channel, "DigitalOutput");
wpi::SendableRegistry::Add(this, "DigitalOutput", channel);
}

View File

@@ -6,8 +6,6 @@
#include <utility>
#include <hal/FRCUsageReporting.h>
#include <hal/HALBase.h>
#include <hal/Ports.h>
#include <wpi/NullDeleter.h>
#include <wpi/sendable/SendableBuilder.h>
@@ -50,10 +48,9 @@ DoubleSolenoid::DoubleSolenoid(int module, PneumaticsModuleType moduleType,
}
}
HAL_Report(HALUsageReporting::kResourceType_Solenoid, m_forwardChannel + 1,
m_module->GetModuleNumber() + 1);
HAL_Report(HALUsageReporting::kResourceType_Solenoid, m_reverseChannel + 1,
m_module->GetModuleNumber() + 1);
m_module->ReportUsage(
fmt::format("Solenoid[{},{}]", m_forwardChannel, m_reverseChannel),
"DoubleSolenoid");
wpi::SendableRegistry::Add(this, "DoubleSolenoid",
m_module->GetModuleNumber(), m_forwardChannel);

View File

@@ -8,8 +8,8 @@
#include <utility>
#include <hal/DutyCycle.h>
#include <hal/FRCUsageReporting.h>
#include <hal/HALBase.h>
#include <hal/UsageReporting.h>
#include <wpi/NullDeleter.h>
#include <wpi/StackTrace.h>
#include <wpi/sendable/SendableBuilder.h>
@@ -31,7 +31,7 @@ void DutyCycle::InitDutyCycle() {
std::string stackTrace = wpi::GetStackTrace(1);
m_handle = HAL_InitializeDutyCycle(m_channel, stackTrace.c_str(), &status);
FRC_CheckErrorStatus(status, "Channel {}", GetSourceChannel());
HAL_Report(HALUsageReporting::kResourceType_DutyCycle, m_channel + 1);
HAL_ReportUsage("IO", m_channel, "DutyCycle");
wpi::SendableRegistry::Add(this, "Duty Cycle", m_channel);
}

View File

@@ -8,7 +8,7 @@
#include <utility>
#include <hal/Encoder.h>
#include <hal/FRCUsageReporting.h>
#include <hal/UsageReporting.h>
#include <wpi/NullDeleter.h>
#include <wpi/sendable/SendableBuilder.h>
#include <wpi/sendable/SendableRegistry.h>
@@ -172,8 +172,19 @@ void Encoder::InitEncoder(int aChannel, int bChannel, bool reverseDirection,
static_cast<HAL_EncoderEncodingType>(encodingType), &status);
FRC_CheckErrorStatus(status, "InitEncoder");
HAL_Report(HALUsageReporting::kResourceType_Encoder, GetFPGAIndex() + 1,
encodingType);
const char* type = "Encoder";
switch (encodingType) {
case k1X:
type = "Encoder:1x";
break;
case k2X:
type = "Encoder:2x";
break;
case k4X:
type = "Encoder:4x";
break;
}
HAL_ReportUsage(fmt::format("IO[{},{}]", aChannel, bChannel), type);
// wpi::SendableRegistry::Add(this, "Encoder", m_aSource->GetChannel());
}

View File

@@ -6,8 +6,8 @@
#include <algorithm>
#include <hal/FRCUsageReporting.h>
#include <hal/I2C.h>
#include <hal/UsageReporting.h>
#include "frc/Errors.h"
@@ -20,7 +20,8 @@ I2C::I2C(Port port, int deviceAddress)
HAL_InitializeI2C(m_port, &status);
FRC_CheckErrorStatus(status, "Port {}", static_cast<int>(port));
HAL_Report(HALUsageReporting::kResourceType_I2C, deviceAddress);
HAL_ReportUsage(
fmt::format("I2C[{}][{}]", static_cast<int>(port), deviceAddress), "");
}
I2C::Port I2C::GetPort() const {

View File

@@ -7,7 +7,6 @@
#include <frc/DriverStation.h>
#include <hal/DriverStation.h>
#include <hal/FRCUsageReporting.h>
#include <networktables/NetworkTableInstance.h>
#include <wpi/print.h>

View File

@@ -6,7 +6,7 @@
#include <cmath>
#include <hal/FRCUsageReporting.h>
#include <hal/UsageReporting.h>
#include "frc/event/BooleanEvent.h"
@@ -19,7 +19,7 @@ Joystick::Joystick(int port) : GenericHID(port) {
m_axes[Axis::kTwist] = kDefaultTwistChannel;
m_axes[Axis::kThrottle] = kDefaultThrottleChannel;
HAL_Report(HALUsageReporting::kResourceType_Joystick, port + 1);
HAL_ReportUsage("HID", port, "Joystick");
}
void Joystick::SetXChannel(int channel) {

View File

@@ -8,7 +8,6 @@
#include <fmt/format.h>
#include <hal/DriverStation.h>
#include <hal/FRCUsageReporting.h>
#include <hal/Notifier.h>
#include <hal/Threads.h>

View File

@@ -6,10 +6,10 @@
#include <utility>
#include <hal/FRCUsageReporting.h>
#include <hal/HALBase.h>
#include <hal/PWM.h>
#include <hal/Ports.h>
#include <hal/UsageReporting.h>
#include <wpi/StackTrace.h>
#include <wpi/sendable/SendableBuilder.h>
#include <wpi/sendable/SendableRegistry.h>
@@ -37,7 +37,7 @@ PWM::PWM(int channel, bool registerSendable) {
HAL_SetPWMEliminateDeadband(m_handle, false, &status);
FRC_CheckErrorStatus(status, "Channel {}", channel);
HAL_Report(HALUsageReporting::kResourceType_PWM, channel + 1);
HAL_ReportUsage("IO", channel, "PWM");
if (registerSendable) {
wpi::SendableRegistry::Add(this, "PWM", channel);
}

View File

@@ -11,6 +11,7 @@
#include <fmt/format.h>
#include <hal/REVPH.h>
#include <hal/UsageReporting.h>
#include <wpi/NullDeleter.h>
#include <wpi/StackTrace.h>
@@ -441,6 +442,10 @@ Compressor PneumaticHub::MakeCompressor() {
return Compressor{m_module, PneumaticsModuleType::REVPH};
}
void PneumaticHub::ReportUsage(std::string_view device, std::string_view data) {
HAL_ReportUsage(fmt::format("PH[{}]/{}", m_module, device), data);
}
std::shared_ptr<PneumaticsBase> PneumaticHub::GetForModule(int module) {
std::string stackTrace = wpi::GetStackTrace(1);
std::scoped_lock lock(m_handleLock);

View File

@@ -7,7 +7,9 @@
#include <memory>
#include <string>
#include <fmt/format.h>
#include <hal/CTREPCM.h>
#include <hal/UsageReporting.h>
#include <wpi/NullDeleter.h>
#include <wpi/StackTrace.h>
@@ -289,6 +291,11 @@ Compressor PneumaticsControlModule::MakeCompressor() {
return Compressor{m_module, PneumaticsModuleType::CTREPCM};
}
void PneumaticsControlModule::ReportUsage(std::string_view device,
std::string_view data) {
HAL_ReportUsage(fmt::format("PCM[{}]/{}", m_module, device), data);
}
std::shared_ptr<PneumaticsBase> PneumaticsControlModule::GetForModule(
int module) {
std::string stackTrace = wpi::GetStackTrace(1);

View File

@@ -7,9 +7,9 @@
#include <vector>
#include <fmt/format.h>
#include <hal/FRCUsageReporting.h>
#include <hal/Ports.h>
#include <hal/PowerDistribution.h>
#include <hal/UsageReporting.h>
#include <wpi/StackTrace.h>
#include <wpi/sendable/SendableBuilder.h>
#include <wpi/sendable/SendableRegistry.h>
@@ -41,11 +41,9 @@ PowerDistribution::PowerDistribution() {
if (HAL_GetPowerDistributionType(m_handle, &status) ==
HAL_PowerDistributionType::HAL_PowerDistributionType_kCTRE) {
HAL_Report(HALUsageReporting::kResourceType_PDP,
HALUsageReporting::kPDP_CTRE);
HAL_ReportUsage("PDP", m_module, "");
} else {
HAL_Report(HALUsageReporting::kResourceType_PDP,
HALUsageReporting::kPDP_REV);
HAL_ReportUsage("PDH", m_module, "");
}
wpi::SendableRegistry::Add(this, "PowerDistribution", m_module);
}
@@ -62,11 +60,9 @@ PowerDistribution::PowerDistribution(int module, ModuleType moduleType) {
FRC_ReportError(status, "Module {}", module);
if (moduleType == ModuleType::kCTRE) {
HAL_Report(HALUsageReporting::kResourceType_PDP,
HALUsageReporting::kPDP_CTRE);
HAL_ReportUsage("PDP_CTRE", m_module, "");
} else {
HAL_Report(HALUsageReporting::kResourceType_PDP,
HALUsageReporting::kPDP_REV);
HAL_ReportUsage("PDH_REV", m_module, "");
}
wpi::SendableRegistry::Add(this, "PowerDistribution", m_module);
}

View File

@@ -9,7 +9,7 @@
#include <vector>
#include <fmt/format.h>
#include <hal/FRCUsageReporting.h>
#include <hal/UsageReporting.h>
#include <networktables/MultiSubscriber.h>
#include <networktables/NetworkTable.h>
#include <networktables/NetworkTableInstance.h>
@@ -179,5 +179,5 @@ Instance::Instance() {
}
}
});
HAL_Report(HALUsageReporting::kResourceType_Preferences, 0);
HAL_ReportUsage("Preferences", "");
}

View File

@@ -6,8 +6,8 @@
#include <string>
#include <hal/FRCUsageReporting.h>
#include <hal/SerialPort.h>
#include <hal/UsageReporting.h>
#include "frc/Errors.h"
@@ -39,8 +39,7 @@ SerialPort::SerialPort(int baudRate, Port port, int dataBits,
DisableTermination();
HAL_Report(HALUsageReporting::kResourceType_SerialPort,
static_cast<uint8_t>(port) + 1);
HAL_ReportUsage("SerialPort", static_cast<int>(port), "");
}
SerialPort::SerialPort(int baudRate, std::string_view portName, Port port,
@@ -70,8 +69,7 @@ SerialPort::SerialPort(int baudRate, std::string_view portName, Port port,
DisableTermination();
HAL_Report(HALUsageReporting::kResourceType_SerialPort,
static_cast<uint8_t>(port) + 1);
HAL_ReportUsage("SerialPort", static_cast<int>(port), "");
}
void SerialPort::SetFlowControl(SerialPort::FlowControl flowControl) {

View File

@@ -4,7 +4,7 @@
#include "frc/Servo.h"
#include <hal/FRCUsageReporting.h>
#include <hal/UsageReporting.h>
#include <wpi/sendable/SendableBuilder.h>
#include <wpi/sendable/SendableRegistry.h>
@@ -23,7 +23,7 @@ Servo::Servo(int channel) : PWM(channel) {
// Assign defaults for period multiplier for the servo PWM control signal
SetPeriodMultiplier(kPeriodMultiplier_4X);
HAL_Report(HALUsageReporting::kResourceType_Servo, channel + 1);
HAL_ReportUsage("IO", channel, "Servo");
wpi::SendableRegistry::SetName(this, "Servo", channel);
}

View File

@@ -6,6 +6,7 @@
#include <algorithm>
#include <hal/UsageReporting.h>
#include <wpi/sendable/SendableBuilder.h>
#include <wpi/sendable/SendableRegistry.h>
@@ -31,6 +32,7 @@ SharpIR SharpIR::GP2Y0A51SK0F(int channel) {
SharpIR::SharpIR(int channel, double a, double b, double minCM, double maxCM)
: m_sensor(channel), m_A(a), m_B(b), m_minCM(minCM), m_maxCM(maxCM) {
HAL_ReportUsage("IO", channel, "SharpIR");
wpi::SendableRegistry::Add(this, "SharpIR", channel);
m_simDevice = hal::SimDevice("SharpIR", m_sensor.GetChannel());

View File

@@ -6,7 +6,6 @@
#include <utility>
#include <hal/FRCUsageReporting.h>
#include <wpi/NullDeleter.h>
#include <wpi/sendable/SendableBuilder.h>
#include <wpi/sendable/SendableRegistry.h>
@@ -28,8 +27,7 @@ Solenoid::Solenoid(int module, PneumaticsModuleType moduleType, int channel)
throw FRC_MakeError(err::ResourceAlreadyAllocated, "Channel {}", m_channel);
}
HAL_Report(HALUsageReporting::kResourceType_Solenoid, m_channel + 1,
m_module->GetModuleNumber() + 1);
m_module->ReportUsage(fmt::format("Solenoid[{}]", m_channel), "Solenoid");
wpi::SendableRegistry::Add(this, "Solenoid", m_module->GetModuleNumber(),
m_channel);
}

View File

@@ -4,7 +4,6 @@
#include "frc/Threads.h"
#include <hal/FRCUsageReporting.h>
#include <hal/Threads.h>
#include "frc/Errors.h"

View File

@@ -10,8 +10,8 @@
#include <utility>
#include <hal/DriverStation.h>
#include <hal/FRCUsageReporting.h>
#include <hal/Notifier.h>
#include <hal/UsageReporting.h>
#include "frc/Errors.h"
@@ -87,8 +87,7 @@ TimedRobot::TimedRobot(units::second_t period) : IterativeRobotBase(period) {
FRC_CheckErrorStatus(status, "InitializeNotifier");
HAL_SetNotifierName(m_notifier, "TimedRobot", &status);
HAL_Report(HALUsageReporting::kResourceType_Framework,
HALUsageReporting::kFramework_Timed);
HAL_ReportUsage("Framework", "TimedRobot");
}
TimedRobot::~TimedRobot() {

View File

@@ -7,7 +7,7 @@
#include <string>
#include <hal/Counter.h>
#include <hal/FRCUsageReporting.h>
#include <hal/UsageReporting.h>
#include <wpi/StackTrace.h>
#include <wpi/sendable/SendableBuilder.h>
@@ -24,7 +24,7 @@ Tachometer::Tachometer(int channel, EdgeConfiguration configuration)
stackTrace.c_str(), &status);
FRC_CheckErrorStatus(status, "{}", channel);
HAL_Report(HALUsageReporting::kResourceType_Counter, channel + 1);
HAL_ReportUsage("IO", channel, "Tachometer");
wpi::SendableRegistry::Add(this, "Tachometer", channel);
}

View File

@@ -8,7 +8,7 @@
#include <string>
#include <hal/Counter.h>
#include <hal/FRCUsageReporting.h>
#include <hal/UsageReporting.h>
#include <wpi/StackTrace.h>
#include <wpi/sendable/SendableBuilder.h>
@@ -27,7 +27,7 @@ UpDownCounter::UpDownCounter(int channel, EdgeConfiguration configuration)
Reset();
HAL_Report(HALUsageReporting::kResourceType_Counter, channel + 1);
HAL_ReportUsage("IO", channel, "UpDownCounter");
wpi::SendableRegistry::Add(this, "UpDown Counter", channel);
}

View File

@@ -9,7 +9,7 @@
#include <string>
#include <utility>
#include <hal/FRCUsageReporting.h>
#include <hal/UsageReporting.h>
#include <wpi/sendable/SendableBuilder.h>
#include <wpi/sendable/SendableRegistry.h>
@@ -42,8 +42,7 @@ void DifferentialDrive::ArcadeDrive(double xSpeed, double zRotation,
bool squareInputs) {
static bool reported = false;
if (!reported) {
HAL_Report(HALUsageReporting::kResourceType_RobotDrive,
HALUsageReporting::kRobotDrive2_DifferentialArcade, 2);
HAL_ReportUsage("RobotDrive", "DifferentialArcade");
reported = true;
}
@@ -65,8 +64,7 @@ void DifferentialDrive::CurvatureDrive(double xSpeed, double zRotation,
bool allowTurnInPlace) {
static bool reported = false;
if (!reported) {
HAL_Report(HALUsageReporting::kResourceType_RobotDrive,
HALUsageReporting::kRobotDrive2_DifferentialCurvature, 2);
HAL_ReportUsage("RobotDrive", "DifferentialCurvature");
reported = true;
}
@@ -88,8 +86,7 @@ void DifferentialDrive::TankDrive(double leftSpeed, double rightSpeed,
bool squareInputs) {
static bool reported = false;
if (!reported) {
HAL_Report(HALUsageReporting::kResourceType_RobotDrive,
HALUsageReporting::kRobotDrive2_DifferentialTank, 2);
HAL_ReportUsage("RobotDrive", "DifferentialTank");
reported = true;
}

View File

@@ -8,7 +8,7 @@
#include <string>
#include <utility>
#include <hal/FRCUsageReporting.h>
#include <hal/UsageReporting.h>
#include <wpi/sendable/SendableBuilder.h>
#include <wpi/sendable/SendableRegistry.h>
@@ -52,8 +52,7 @@ MecanumDrive::MecanumDrive(std::function<void(double)> frontLeftMotor,
void MecanumDrive::DriveCartesian(double xSpeed, double ySpeed,
double zRotation, Rotation2d gyroAngle) {
if (!reported) {
HAL_Report(HALUsageReporting::kResourceType_RobotDrive,
HALUsageReporting::kRobotDrive2_MecanumCartesian, 4);
HAL_ReportUsage("RobotDrive", "MecanumCartesian");
reported = true;
}
@@ -79,8 +78,7 @@ void MecanumDrive::DriveCartesian(double xSpeed, double ySpeed,
void MecanumDrive::DrivePolar(double magnitude, Rotation2d angle,
double zRotation) {
if (!reported) {
HAL_Report(HALUsageReporting::kResourceType_RobotDrive,
HALUsageReporting::kRobotDrive2_MecanumPolar, 4);
HAL_ReportUsage("RobotDrive", "MecanumPolar");
reported = true;
}

View File

@@ -8,8 +8,6 @@
#include <cmath>
#include <cstddef>
#include <hal/FRCUsageReporting.h>
#include "frc/motorcontrol/MotorController.h"
using namespace frc;

View File

@@ -7,7 +7,7 @@
#include <string>
#include <fmt/format.h>
#include <hal/FRCUsageReporting.h>
#include <hal/UsageReporting.h>
#include <wpi/sendable/SendableBuilder.h>
#include <wpi/sendable/SendableRegistry.h>
@@ -26,7 +26,8 @@ NidecBrushless::NidecBrushless(int pwmChannel, int dioChannel)
m_dio.SetPWMRate(15625);
m_dio.EnablePWM(0.5);
HAL_Report(HALUsageReporting::kResourceType_NidecBrushless, pwmChannel + 1);
HAL_ReportUsage(fmt::format("IO[{},{}]", pwmChannel, dioChannel),
"NidecBrushless");
wpi::SendableRegistry::Add(this, "Nidec Brushless", pwmChannel);
}

View File

@@ -9,7 +9,7 @@
#include <utility>
#include <vector>
#include <hal/FRCUsageReporting.h>
#include <hal/UsageReporting.h>
#include <networktables/NetworkTable.h>
#include <networktables/NetworkTableInstance.h>
#include <wpi/StringMap.h>
@@ -77,8 +77,7 @@ bool SmartDashboard::IsPersistent(std::string_view key) {
nt::NetworkTableEntry SmartDashboard::GetEntry(std::string_view key) {
if (!gReported) {
HAL_Report(HALUsageReporting::kResourceType_SmartDashboard,
HALUsageReporting::kSmartDashboard_Instance);
HAL_ReportUsage("SmartDashboard", "");
gReported = true;
}
return GetInstance().table->GetEntry(key);
@@ -89,8 +88,7 @@ void SmartDashboard::PutData(std::string_view key, wpi::Sendable* data) {
throw FRC_MakeError(err::NullParameter, "value");
}
if (!gReported) {
HAL_Report(HALUsageReporting::kResourceType_SmartDashboard,
HALUsageReporting::kSmartDashboard_Instance);
HAL_ReportUsage("SmartDashboard", "");
gReported = true;
}
auto& inst = GetInstance();