mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
[wpilibc] MotorSafety::GetDescription(): Return std::string (#3390)
This is only called in an error condition, so it's not necessary to over optimize it.
This commit is contained in:
@@ -8,8 +8,6 @@
|
||||
#include <utility>
|
||||
|
||||
#include <wpi/SmallPtrSet.h>
|
||||
#include <wpi/SmallString.h>
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
#include "frc/DriverStation.h"
|
||||
#include "frc/Errors.h"
|
||||
@@ -90,11 +88,8 @@ void MotorSafety::Check() {
|
||||
}
|
||||
|
||||
if (stopTime < Timer::GetFPGATimestamp()) {
|
||||
wpi::SmallString<128> buf;
|
||||
wpi::raw_svector_ostream desc(buf);
|
||||
GetDescription(desc);
|
||||
FRC_ReportError(err::Timeout, "{}... Output not updated often enough",
|
||||
desc.str());
|
||||
GetDescription());
|
||||
StopMotor();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <hal/FRCUsageReporting.h>
|
||||
#include <hal/HALBase.h>
|
||||
#include <hal/Ports.h>
|
||||
#include <hal/Relay.h>
|
||||
#include <wpi/StackTrace.h>
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
#include "frc/Errors.h"
|
||||
#include "frc/SensorUtil.h"
|
||||
@@ -168,8 +168,8 @@ void Relay::StopMotor() {
|
||||
Set(kOff);
|
||||
}
|
||||
|
||||
void Relay::GetDescription(wpi::raw_ostream& desc) const {
|
||||
desc << "Relay " << GetChannel();
|
||||
std::string Relay::GetDescription() const {
|
||||
return fmt::format("Relay {}", GetChannel());
|
||||
}
|
||||
|
||||
void Relay::InitSendable(SendableBuilder& builder) {
|
||||
|
||||
@@ -189,8 +189,8 @@ void DifferentialDrive::StopMotor() {
|
||||
Feed();
|
||||
}
|
||||
|
||||
void DifferentialDrive::GetDescription(wpi::raw_ostream& desc) const {
|
||||
desc << "DifferentialDrive";
|
||||
std::string DifferentialDrive::GetDescription() const {
|
||||
return "DifferentialDrive";
|
||||
}
|
||||
|
||||
void DifferentialDrive::InitSendable(SendableBuilder& builder) {
|
||||
|
||||
@@ -114,8 +114,8 @@ void KilloughDrive::StopMotor() {
|
||||
Feed();
|
||||
}
|
||||
|
||||
void KilloughDrive::GetDescription(wpi::raw_ostream& desc) const {
|
||||
desc << "KilloughDrive";
|
||||
std::string KilloughDrive::GetDescription() const {
|
||||
return "KilloughDrive";
|
||||
}
|
||||
|
||||
void KilloughDrive::InitSendable(SendableBuilder& builder) {
|
||||
|
||||
@@ -109,8 +109,8 @@ MecanumDrive::WheelSpeeds MecanumDrive::DriveCartesianIK(double ySpeed,
|
||||
wheelSpeeds[kRearLeft], wheelSpeeds[kRearRight]};
|
||||
}
|
||||
|
||||
void MecanumDrive::GetDescription(wpi::raw_ostream& desc) const {
|
||||
desc << "MecanumDrive";
|
||||
std::string MecanumDrive::GetDescription() const {
|
||||
return "MecanumDrive";
|
||||
}
|
||||
|
||||
void MecanumDrive::InitSendable(SendableBuilder& builder) {
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#include "frc/motorcontrol/NidecBrushless.h"
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <hal/FRCUsageReporting.h>
|
||||
#include <wpi/raw_ostream.h>
|
||||
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
@@ -64,8 +64,8 @@ void NidecBrushless::StopMotor() {
|
||||
m_pwm.SetDisabled();
|
||||
}
|
||||
|
||||
void NidecBrushless::GetDescription(wpi::raw_ostream& desc) const {
|
||||
desc << "Nidec " << GetChannel();
|
||||
std::string NidecBrushless::GetDescription() const {
|
||||
return fmt::format("Nidec {}", GetChannel());
|
||||
}
|
||||
|
||||
int NidecBrushless::GetChannel() const {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "frc/motorcontrol/PWMMotorController.h"
|
||||
|
||||
#include <wpi/raw_ostream.h>
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
|
||||
@@ -34,8 +34,8 @@ void PWMMotorController::StopMotor() {
|
||||
Disable();
|
||||
}
|
||||
|
||||
void PWMMotorController::GetDescription(wpi::raw_ostream& desc) const {
|
||||
desc << "PWM " << GetChannel();
|
||||
std::string PWMMotorController::GetDescription() const {
|
||||
return fmt::format("PWM {}", GetChannel());
|
||||
}
|
||||
|
||||
int PWMMotorController::GetChannel() const {
|
||||
|
||||
Reference in New Issue
Block a user