SCRIPT: wpiformat

This commit is contained in:
PJ Reiniger
2025-11-07 20:01:58 -05:00
committed by Peter Johnson
parent ae6bdc9d25
commit 2109161534
749 changed files with 5504 additions and 3936 deletions

View File

@@ -84,7 +84,8 @@ class ExpansionHubServo {
* @param minAngle Minimum angle
* @param maxAngle Maximum angle
*/
void SetAngleRange(wpi::units::degree_t minAngle, wpi::units::degree_t maxAngle);
void SetAngleRange(wpi::units::degree_t minAngle,
wpi::units::degree_t maxAngle);
/**
* Sets the PWM range for the servo.
@@ -95,7 +96,8 @@ class ExpansionHubServo {
* @param minPwm Minimum PWM
* @param maxPwm Maximum PWM
*/
void SetPWMRange(wpi::units::microsecond_t minPwm, wpi::units::microsecond_t maxPwm);
void SetPWMRange(wpi::units::microsecond_t minPwm,
wpi::units::microsecond_t maxPwm);
/**
* Sets whether the servo is reversed.

View File

@@ -139,7 +139,8 @@ class MecanumDrive : public RobotDriveBase,
* @param zRotation The robot's rotation rate around the Z axis [-1.0..1.0].
* Counterclockwise is positive.
*/
void DrivePolar(double magnitude, wpi::math::Rotation2d angle, double zRotation);
void DrivePolar(double magnitude, wpi::math::Rotation2d angle,
double zRotation);
/**
* Cartesian inverse kinematics for Mecanum platform.

View File

@@ -79,7 +79,8 @@ class DriverStation final {
* @return The angle clockwise from straight up, or std::nullopt if the
* POVDirection is kCenter.
*/
static constexpr std::optional<wpi::math::Rotation2d> GetAngle(POVDirection angle) {
static constexpr std::optional<wpi::math::Rotation2d> GetAngle(
POVDirection angle) {
switch (angle) {
case kCenter:
return std::nullopt;

View File

@@ -14,7 +14,7 @@ class BooleanSubscriber;
class BooleanTopic;
class NetworkTable;
class NetworkTableInstance;
} // namespace nt
} // namespace wpi::nt
namespace wpi {
/**
@@ -50,7 +50,8 @@ class NetworkBooleanEvent : public BooleanEvent {
* @param table The NetworkTable that contains the topic
* @param topicName The topic name within the table that contains the value
*/
NetworkBooleanEvent(EventLoop* loop, std::shared_ptr<wpi::nt::NetworkTable> table,
NetworkBooleanEvent(EventLoop* loop,
std::shared_ptr<wpi::nt::NetworkTable> table,
std::string_view topicName);
/**

View File

@@ -19,8 +19,9 @@ namespace wpi {
* sensors have multiple axis and can be treated as multiple devices. Each is
* calibrated by finding the center value over a period of time.
*/
class AnalogAccelerometer : public wpi::util::Sendable,
public wpi::util::SendableHelper<AnalogAccelerometer> {
class AnalogAccelerometer
: public wpi::util::Sendable,
public wpi::util::SendableHelper<AnalogAccelerometer> {
public:
/**
* Create a new instance of an accelerometer.

View File

@@ -131,7 +131,8 @@ class LEDPattern {
*
* <pre>
* // LEDs per meter, a known value taken from the spec sheet of our
* particular LED strip wpi::units::meter_t LED_SPACING = wpi::units::meter_t{1 /60.0};
* particular LED strip wpi::units::meter_t LED_SPACING =
* wpi::units::meter_t{1 /60.0};
*
* wpi::LEDPattern rainbow = wpi::LEDPattern::Rainbow();
* wpi::LEDPattern scrollingRainbow =

View File

@@ -28,10 +28,11 @@ WPI_IGNORE_DEPRECATED
/**
* Common base class for all PWM Motor Controllers.
*/
class PWMMotorController : public MotorController,
public MotorSafety,
public wpi::util::Sendable,
public wpi::util::SendableHelper<PWMMotorController> {
class PWMMotorController
: public MotorController,
public MotorSafety,
public wpi::util::Sendable,
public wpi::util::SendableHelper<PWMMotorController> {
public:
PWMMotorController(PWMMotorController&&) = default;
PWMMotorController& operator=(PWMMotorController&&) = default;

View File

@@ -228,7 +228,8 @@ class PneumaticsBase {
* @return The pressure read by an analog pressure sensor on the
* specified analog input channel.
*/
virtual wpi::units::pounds_per_square_inch_t GetPressure(int channel) const = 0;
virtual wpi::units::pounds_per_square_inch_t GetPressure(
int channel) const = 0;
/**
* Create a solenoid object for the specified channel.

View File

@@ -22,7 +22,8 @@ namespace wpi {
* The Solenoid class is typically used for pneumatics solenoids, but could be
* used for any device within the current spec of the module.
*/
class Solenoid : public wpi::util::Sendable, public wpi::util::SendableHelper<Solenoid> {
class Solenoid : public wpi::util::Sendable,
public wpi::util::SendableHelper<Solenoid> {
public:
/**
* Constructs a solenoid for a specified module and type.

View File

@@ -346,7 +346,8 @@ class PowerDistribution : public wpi::util::Sendable,
void InitSendable(wpi::util::SendableBuilder& builder) override;
private:
wpi::hal::Handle<HAL_PowerDistributionHandle, HAL_CleanPowerDistribution> m_handle;
wpi::hal::Handle<HAL_PowerDistributionHandle, HAL_CleanPowerDistribution>
m_handle;
int m_module;
};

View File

@@ -12,7 +12,8 @@
namespace wpi {
class SharpIR : public wpi::util::Sendable, public wpi::util::SendableHelper<SharpIR> {
class SharpIR : public wpi::util::Sendable,
public wpi::util::SendableHelper<SharpIR> {
public:
/**
* Sharp GP2Y0A02YK0F is an analog IR sensor capable of measuring

View File

@@ -18,8 +18,9 @@ namespace wpi {
* units you choose, by way of the scaling and offset constants passed to the
* constructor.
*/
class AnalogPotentiometer : public wpi::util::Sendable,
public wpi::util::SendableHelper<AnalogPotentiometer> {
class AnalogPotentiometer
: public wpi::util::Sendable,
public wpi::util::SendableHelper<AnalogPotentiometer> {
public:
/**
* Construct an Analog Potentiometer object from a channel number.

View File

@@ -21,7 +21,8 @@ namespace wpi {
* low in that frequency. These can be attached to any SmartIO.
*
*/
class DutyCycle : public wpi::util::Sendable, public wpi::util::SendableHelper<DutyCycle> {
class DutyCycle : public wpi::util::Sendable,
public wpi::util::SendableHelper<DutyCycle> {
public:
/**
* Constructs a DutyCycle input from a smartio channel.

View File

@@ -123,7 +123,8 @@ class TimedRobot : public IterativeRobotBase {
std::chrono::microseconds m_startTime;
uint64_t m_loopStartTimeUs = 0;
wpi::util::priority_queue<Callback, std::vector<Callback>, std::greater<Callback>>
wpi::util::priority_queue<Callback, std::vector<Callback>,
std::greater<Callback>>
m_callbacks;
};

View File

@@ -31,9 +31,9 @@ class BatterySim {
* @param currents The currents drawn from the battery.
* @return The battery's voltage under load.
*/
static wpi::units::volt_t Calculate(wpi::units::volt_t nominalVoltage,
wpi::units::ohm_t resistance,
std::span<const wpi::units::ampere_t> currents) {
static wpi::units::volt_t Calculate(
wpi::units::volt_t nominalVoltage, wpi::units::ohm_t resistance,
std::span<const wpi::units::ampere_t> currents) {
return std::max(0_V, nominalVoltage - std::accumulate(currents.begin(),
currents.end(), 0_A) *
resistance);
@@ -69,7 +69,8 @@ class BatterySim {
* @param currents The currents drawn from the battery.
* @return The battery's voltage under load.
*/
static wpi::units::volt_t Calculate(std::span<const wpi::units::ampere_t> currents) {
static wpi::units::volt_t Calculate(
std::span<const wpi::units::ampere_t> currents) {
return Calculate(12_V, 0.02_Ohm, currents);
}

View File

@@ -24,13 +24,14 @@ class DCMotorSim : public LinearSystemSim<2, 1, 2> {
*
* @param plant The linear system representing the DC motor. This
* system can be created with wpi::math::LinearSystemId::DCMotorSystem(). If
* wpi::math::LinearSystemId::DCMotorSystem(kV, kA) is used, the distance unit must be
* radians.
* wpi::math::LinearSystemId::DCMotorSystem(kV, kA) is used, the distance unit
* must be radians.
* @param gearbox The type of and number of motors in the DC motor
* gearbox.
* @param measurementStdDevs The standard deviation of the measurement noise.
*/
DCMotorSim(const wpi::math::LinearSystem<2, 1, 2>& plant, const wpi::math::DCMotor& gearbox,
DCMotorSim(const wpi::math::LinearSystem<2, 1, 2>& plant,
const wpi::math::DCMotor& gearbox,
const std::array<double, 2>& measurementStdDevs = {0.0, 0.0});
using LinearSystemSim::SetState;

View File

@@ -20,12 +20,13 @@ class DifferentialDrivetrainSim {
/**
* Creates a simulated differential drivetrain.
*
* @param plant The wpi::math::LinearSystem representing the robot's drivetrain. This
* system can be created with
* @param plant The wpi::math::LinearSystem representing the robot's
* drivetrain. This system can be created with
* wpi::math::LinearSystemId::DrivetrainVelocitySystem() or
* wpi::math::LinearSystemId::IdentifyDrivetrainSystem().
* @param trackwidth The robot's trackwidth.
* @param driveMotor A wpi::math::DCMotor representing the left side of the drivetrain.
* @param driveMotor A wpi::math::DCMotor representing the left side of the
* drivetrain.
* @param gearingRatio The gearingRatio ratio of the left side, as output over
* input. This must be the same ratio as the ratio used to
* identify or create the plant.
@@ -41,13 +42,15 @@ class DifferentialDrivetrainSim {
*/
DifferentialDrivetrainSim(
wpi::math::LinearSystem<2, 2, 2> plant, wpi::units::meter_t trackwidth,
wpi::math::DCMotor driveMotor, double gearingRatio, wpi::units::meter_t wheelRadius,
wpi::math::DCMotor driveMotor, double gearingRatio,
wpi::units::meter_t wheelRadius,
const std::array<double, 7>& measurementStdDevs = {});
/**
* Creates a simulated differential drivetrain.
*
* @param driveMotor A wpi::math::DCMotor representing the left side of the drivetrain.
* @param driveMotor A wpi::math::DCMotor representing the left side of the
* drivetrain.
* @param gearing The gearing on the drive between motor and wheel, as
* output over input. This must be the same ratio as the
* ratio used to identify or create the plant.
@@ -67,9 +70,9 @@ class DifferentialDrivetrainSim {
* starting point.
*/
DifferentialDrivetrainSim(
wpi::math::DCMotor driveMotor, double gearing, wpi::units::kilogram_square_meter_t J,
wpi::units::kilogram_t mass, wpi::units::meter_t wheelRadius,
wpi::units::meter_t trackwidth,
wpi::math::DCMotor driveMotor, double gearing,
wpi::units::kilogram_square_meter_t J, wpi::units::kilogram_t mass,
wpi::units::meter_t wheelRadius, wpi::units::meter_t trackwidth,
const std::array<double, 7>& measurementStdDevs = {});
/**
@@ -88,7 +91,8 @@ class DifferentialDrivetrainSim {
* @param leftVoltage The left voltage.
* @param rightVoltage The right voltage.
*/
void SetInputs(wpi::units::volt_t leftVoltage, wpi::units::volt_t rightVoltage);
void SetInputs(wpi::units::volt_t leftVoltage,
wpi::units::volt_t rightVoltage);
/**
* Sets the gearing reduction on the drivetrain. This is commonly used for
@@ -101,8 +105,8 @@ class DifferentialDrivetrainSim {
/**
* Updates the simulation.
*
* @param dt The time that's passed since the last Update(wpi::units::second_t)
* call.
* @param dt The time that's passed since the last
* Update(wpi::units::second_t) call.
*/
void Update(wpi::units::second_t dt);
@@ -193,7 +197,8 @@ class DifferentialDrivetrainSim {
* @param u The input.
* @return The state derivative with respect to time.
*/
wpi::math::Vectord<7> Dynamics(const wpi::math::Vectord<7>& x, const Eigen::Vector2d& u);
wpi::math::Vectord<7> Dynamics(const wpi::math::Vectord<7>& x,
const Eigen::Vector2d& u);
class State {
public:
@@ -234,14 +239,17 @@ class DifferentialDrivetrainSim {
class KitbotMotor {
public:
/// One CIM motor per drive side.
static constexpr wpi::math::DCMotor SingleCIMPerSide = wpi::math::DCMotor::CIM(1);
static constexpr wpi::math::DCMotor SingleCIMPerSide =
wpi::math::DCMotor::CIM(1);
/// Two CIM motors per drive side.
static constexpr wpi::math::DCMotor DualCIMPerSide = wpi::math::DCMotor::CIM(2);
static constexpr wpi::math::DCMotor DualCIMPerSide =
wpi::math::DCMotor::CIM(2);
/// One Mini CIM motor per drive side.
static constexpr wpi::math::DCMotor SingleMiniCIMPerSide =
wpi::math::DCMotor::MiniCIM(1);
/// Two Mini CIM motors per drive side.
static constexpr wpi::math::DCMotor DualMiniCIMPerSide = wpi::math::DCMotor::MiniCIM(2);
static constexpr wpi::math::DCMotor DualMiniCIMPerSide =
wpi::math::DCMotor::MiniCIM(2);
/// One Falcon 500 motor per drive side.
static constexpr wpi::math::DCMotor SingleFalcon500PerSide =
wpi::math::DCMotor::Falcon500(1);
@@ -249,9 +257,11 @@ class DifferentialDrivetrainSim {
static constexpr wpi::math::DCMotor DualFalcon500PerSide =
wpi::math::DCMotor::Falcon500(2);
/// One NEO motor per drive side.
static constexpr wpi::math::DCMotor SingleNEOPerSide = wpi::math::DCMotor::NEO(1);
static constexpr wpi::math::DCMotor SingleNEOPerSide =
wpi::math::DCMotor::NEO(1);
/// Two NEO motors per drive side.
static constexpr wpi::math::DCMotor DualNEOPerSide = wpi::math::DCMotor::NEO(2);
static constexpr wpi::math::DCMotor DualNEOPerSide =
wpi::math::DCMotor::NEO(2);
};
/**
@@ -285,9 +295,9 @@ class DifferentialDrivetrainSim {
const std::array<double, 7>& measurementStdDevs = {}) {
// MOI estimation -- note that I = mr² for point masses
wpi::units::kilogram_square_meter_t batteryMoi = 12.5_lb * 10_in * 10_in;
wpi::units::kilogram_square_meter_t gearboxMoi = (2.8_lb + 2.0_lb) *
2 // CIM plus toughbox per side
* (26_in / 2) * (26_in / 2);
wpi::units::kilogram_square_meter_t gearboxMoi =
(2.8_lb + 2.0_lb) * 2 // CIM plus toughbox per side
* (26_in / 2) * (26_in / 2);
return DifferentialDrivetrainSim{
motor, gearing, batteryMoi + gearboxMoi, 60_lb,

View File

@@ -19,12 +19,13 @@ namespace wpi::sim {
class ElevatorSim : public LinearSystemSim<2, 1, 2> {
public:
template <typename Distance>
using Velocity_t = wpi::units::unit_t<
wpi::units::compound_unit<Distance, wpi::units::inverse<wpi::units::seconds>>>;
using Velocity_t = wpi::units::unit_t<wpi::units::compound_unit<
Distance, wpi::units::inverse<wpi::units::seconds>>>;
template <typename Distance>
using Acceleration_t = wpi::units::unit_t<wpi::units::compound_unit<
wpi::units::compound_unit<Distance, wpi::units::inverse<wpi::units::seconds>>,
wpi::units::compound_unit<Distance,
wpi::units::inverse<wpi::units::seconds>>,
wpi::units::inverse<wpi::units::seconds>>>;
/**
@@ -41,9 +42,10 @@ class ElevatorSim : public LinearSystemSim<2, 1, 2> {
* @param startingHeight The starting height of the elevator.
* @param measurementStdDevs The standard deviation of the measurements.
*/
ElevatorSim(const wpi::math::LinearSystem<2, 1, 2>& plant, const wpi::math::DCMotor& gearbox,
wpi::units::meter_t minHeight, wpi::units::meter_t maxHeight,
bool simulateGravity, wpi::units::meter_t startingHeight,
ElevatorSim(const wpi::math::LinearSystem<2, 1, 2>& plant,
const wpi::math::DCMotor& gearbox, wpi::units::meter_t minHeight,
wpi::units::meter_t maxHeight, bool simulateGravity,
wpi::units::meter_t startingHeight,
const std::array<double, 2>& measurementStdDevs = {0.0, 0.0});
/**
@@ -63,9 +65,10 @@ class ElevatorSim : public LinearSystemSim<2, 1, 2> {
* @param measurementStdDevs The standard deviation of the measurements.
*/
ElevatorSim(const wpi::math::DCMotor& gearbox, double gearing,
wpi::units::kilogram_t carriageMass, wpi::units::meter_t drumRadius,
wpi::units::meter_t minHeight, wpi::units::meter_t maxHeight,
bool simulateGravity, wpi::units::meter_t startingHeight,
wpi::units::kilogram_t carriageMass,
wpi::units::meter_t drumRadius, wpi::units::meter_t minHeight,
wpi::units::meter_t maxHeight, bool simulateGravity,
wpi::units::meter_t startingHeight,
const std::array<double, 2>& measurementStdDevs = {0.0, 0.0});
/**
@@ -98,7 +101,8 @@ class ElevatorSim : public LinearSystemSim<2, 1, 2> {
* @param position The new position
* @param velocity The new velocity
*/
void SetState(wpi::units::meter_t position, wpi::units::meters_per_second_t velocity);
void SetState(wpi::units::meter_t position,
wpi::units::meters_per_second_t velocity);
/**
* Returns whether the elevator would hit the lower limit.
@@ -166,8 +170,9 @@ class ElevatorSim : public LinearSystemSim<2, 1, 2> {
* @param u The system inputs (voltage).
* @param dt The time difference between controller updates.
*/
wpi::math::Vectord<2> UpdateX(const wpi::math::Vectord<2>& currentXhat, const wpi::math::Vectord<1>& u,
wpi::units::second_t dt) override;
wpi::math::Vectord<2> UpdateX(const wpi::math::Vectord<2>& currentXhat,
const wpi::math::Vectord<1>& u,
wpi::units::second_t dt) override;
private:
wpi::math::DCMotor m_gearbox;

View File

@@ -29,7 +29,8 @@ class FlywheelSim : public LinearSystemSim<1, 1, 1> {
* gearbox.
* @param measurementStdDevs The standard deviation of the measurement noise.
*/
FlywheelSim(const wpi::math::LinearSystem<1, 1, 1>& plant, const wpi::math::DCMotor& gearbox,
FlywheelSim(const wpi::math::LinearSystem<1, 1, 1>& plant,
const wpi::math::DCMotor& gearbox,
const std::array<double, 1>& measurementStdDevs = {0.0});
using LinearSystemSim::SetState;

View File

@@ -131,9 +131,9 @@ class LinearSystemSim {
* @param u The system inputs (usually voltage).
* @param dt The time difference between controller updates.
*/
virtual wpi::math::Vectord<States> UpdateX(const wpi::math::Vectord<States>& currentXhat,
const wpi::math::Vectord<Inputs>& u,
wpi::units::second_t dt) {
virtual wpi::math::Vectord<States> UpdateX(
const wpi::math::Vectord<States>& currentXhat,
const wpi::math::Vectord<Inputs>& u, wpi::units::second_t dt) {
return m_plant.CalculateX(currentXhat, u, dt);
}

View File

@@ -37,7 +37,8 @@ class SingleJointedArmSim : public LinearSystemSim<2, 1, 2> {
*/
SingleJointedArmSim(const wpi::math::LinearSystem<2, 1, 2>& system,
const wpi::math::DCMotor& gearbox, double gearing,
wpi::units::meter_t armLength, wpi::units::radian_t minAngle,
wpi::units::meter_t armLength,
wpi::units::radian_t minAngle,
wpi::units::radian_t maxAngle, bool simulateGravity,
wpi::units::radian_t startingAngle,
const std::array<double, 2>& measurementStdDevs = {0.0,
@@ -57,13 +58,12 @@ class SingleJointedArmSim : public LinearSystemSim<2, 1, 2> {
* @param startingAngle The initial position of the arm.
* @param measurementStdDevs The standard deviation of the measurement noise.
*/
SingleJointedArmSim(const wpi::math::DCMotor& gearbox, double gearing,
wpi::units::kilogram_square_meter_t moi,
wpi::units::meter_t armLength, wpi::units::radian_t minAngle,
wpi::units::radian_t maxAngle, bool simulateGravity,
wpi::units::radian_t startingAngle,
const std::array<double, 2>& measurementStdDevs = {0.0,
0.0});
SingleJointedArmSim(
const wpi::math::DCMotor& gearbox, double gearing,
wpi::units::kilogram_square_meter_t moi, wpi::units::meter_t armLength,
wpi::units::radian_t minAngle, wpi::units::radian_t maxAngle,
bool simulateGravity, wpi::units::radian_t startingAngle,
const std::array<double, 2>& measurementStdDevs = {0.0, 0.0});
using LinearSystemSim::SetState;
@@ -74,7 +74,8 @@ class SingleJointedArmSim : public LinearSystemSim<2, 1, 2> {
* @param angle The new angle.
* @param velocity The new angular velocity.
*/
void SetState(wpi::units::radian_t angle, wpi::units::radians_per_second_t velocity);
void SetState(wpi::units::radian_t angle,
wpi::units::radians_per_second_t velocity);
/**
* Returns whether the arm would hit the lower limit.
@@ -156,8 +157,9 @@ class SingleJointedArmSim : public LinearSystemSim<2, 1, 2> {
* @param u The system inputs (voltage).
* @param dt The time difference between controller updates.
*/
wpi::math::Vectord<2> UpdateX(const wpi::math::Vectord<2>& currentXhat, const wpi::math::Vectord<1>& u,
wpi::units::second_t dt) override;
wpi::math::Vectord<2> UpdateX(const wpi::math::Vectord<2>& currentXhat,
const wpi::math::Vectord<1>& u,
wpi::units::second_t dt) override;
private:
wpi::units::meter_t m_armLen;

View File

@@ -38,7 +38,8 @@ namespace wpi {
* also be shown by using the GetObject() function. Other objects can
* also have multiple poses (which will show the object at multiple locations).
*/
class Field2d : public wpi::nt::NTSendable, public wpi::util::SendableHelper<Field2d> {
class Field2d : public wpi::nt::NTSendable,
public wpi::util::SendableHelper<Field2d> {
public:
using Entry = size_t;
@@ -61,7 +62,8 @@ class Field2d : public wpi::nt::NTSendable, public wpi::util::SendableHelper<Fie
* @param y Y location
* @param rotation rotation
*/
void SetRobotPose(wpi::units::meter_t x, wpi::units::meter_t y, wpi::math::Rotation2d rotation);
void SetRobotPose(wpi::units::meter_t x, wpi::units::meter_t y,
wpi::math::Rotation2d rotation);
/**
* Get the robot pose.

View File

@@ -52,7 +52,8 @@ class FieldObject2d {
* @param y Y location
* @param rotation rotation
*/
void SetPose(wpi::units::meter_t x, wpi::units::meter_t y, wpi::math::Rotation2d rotation);
void SetPose(wpi::units::meter_t x, wpi::units::meter_t y,
wpi::math::Rotation2d rotation);
/**
* Get the pose.
@@ -97,7 +98,8 @@ class FieldObject2d {
* @param out output wpi::util::SmallVector to hold 2D poses
* @return span referring to output wpi::util::SmallVector
*/
std::span<const wpi::math::Pose2d> GetPoses(wpi::util::SmallVectorImpl<wpi::math::Pose2d>& out) const;
std::span<const wpi::math::Pose2d> GetPoses(
wpi::util::SmallVectorImpl<wpi::math::Pose2d>& out) const;
private:
void UpdateEntry(bool setDefault = false);

View File

@@ -155,7 +155,8 @@ class SendableBuilderImpl : public wpi::nt::NTSendableBuilder {
void AddSmallStringProperty(
std::string_view key,
std::function<std::string_view(wpi::util::SmallVectorImpl<char>& buf)> getter,
std::function<std::string_view(wpi::util::SmallVectorImpl<char>& buf)>
getter,
std::function<void(std::string_view)> setter) override;
void AddSmallBooleanArrayProperty(
@@ -173,26 +174,29 @@ class SendableBuilderImpl : public wpi::nt::NTSendableBuilder {
void AddSmallFloatArrayProperty(
std::string_view key,
std::function<std::span<const float>(wpi::util::SmallVectorImpl<float>& buf)>
std::function<
std::span<const float>(wpi::util::SmallVectorImpl<float>& buf)>
getter,
std::function<void(std::span<const float>)> setter) override;
void AddSmallDoubleArrayProperty(
std::string_view key,
std::function<std::span<const double>(wpi::util::SmallVectorImpl<double>& buf)>
std::function<
std::span<const double>(wpi::util::SmallVectorImpl<double>& buf)>
getter,
std::function<void(std::span<const double>)> setter) override;
void AddSmallStringArrayProperty(
std::string_view key,
std::function<
std::span<const std::string>(wpi::util::SmallVectorImpl<std::string>& buf)>
std::function<std::span<const std::string>(
wpi::util::SmallVectorImpl<std::string>& buf)>
getter,
std::function<void(std::span<const std::string>)> setter) override;
void AddSmallRawProperty(
std::string_view key, std::string_view typeString,
std::function<std::span<uint8_t>(wpi::util::SmallVectorImpl<uint8_t>& buf)>
std::function<
std::span<uint8_t>(wpi::util::SmallVectorImpl<uint8_t>& buf)>
getter,
std::function<void(std::span<const uint8_t>)> setter) override;

View File

@@ -19,8 +19,9 @@ namespace wpi {
* It contains static, non-templated variables to avoid their duplication in the
* template class.
*/
class SendableChooserBase : public wpi::util::Sendable,
public wpi::util::SendableHelper<SendableChooserBase> {
class SendableChooserBase
: public wpi::util::Sendable,
public wpi::util::SendableHelper<SendableChooserBase> {
public:
SendableChooserBase();
~SendableChooserBase() override = default;

View File

@@ -16,7 +16,7 @@
namespace wpi::util {
class Sendable;
} // namespace wpi
} // namespace wpi::util
namespace wpi {

View File

@@ -116,7 +116,8 @@ class SysIdRoutineLog {
* @param acceleration The linear acceleration to record.
* @return The motor log (for call chaining).
*/
MotorLog& acceleration(wpi::units::meters_per_second_squared_t acceleration) {
MotorLog& acceleration(
wpi::units::meters_per_second_squared_t acceleration) {
return value("acceleration", acceleration.value(), acceleration.name());
}
@@ -128,7 +129,8 @@ class SysIdRoutineLog {
* @param acceleration The angular acceleration to record.
* @return The motor log (for call chaining).
*/
MotorLog& acceleration(wpi::units::turns_per_second_squared_t acceleration) {
MotorLog& acceleration(
wpi::units::turns_per_second_squared_t acceleration) {
return value("acceleration", acceleration.value(), acceleration.name());
}

View File

@@ -26,9 +26,9 @@ namespace wpi {
* connected and provides a match number, the log file is renamed to
* "WPILIB_yyyyMMdd_HHmmss_{event}_{match}.wpilog".
*
* On startup, all existing WPILIB_TBD log files are deleted. If there is less than
* 50 MB of free space on the target storage, WPILIB_ log files are deleted (oldest
* to newest) until there is 50 MB free OR there are 10 files remaining.
* On startup, all existing WPILIB_TBD log files are deleted. If there is less
* than 50 MB of free space on the target storage, WPILIB_ log files are deleted
* (oldest to newest) until there is 50 MB free OR there are 10 files remaining.
*
* By default, all NetworkTables value changes are stored to the data log.
*/

View File

@@ -134,7 +134,7 @@ namespace warn {
* @param[out] status error code
* @param[in] format error message format
*/
#define WPILIB_ReportError(status, format, ...) \
#define WPILIB_ReportError(status, format, ...) \
do { \
if ((status) != 0) { \
::wpi::ReportError(status, __FILE__, __LINE__, __FUNCTION__, \
@@ -147,7 +147,7 @@ namespace warn {
*
* @param[in] format error message format
*/
#define WPILIB_ReportWarning(format, ...) \
#define WPILIB_ReportWarning(format, ...) \
do { \
::wpi::ReportError(::wpi::warn::Warning, __FILE__, __LINE__, __FUNCTION__, \
format __VA_OPT__(, ) __VA_ARGS__); \
@@ -161,7 +161,7 @@ namespace warn {
* @param[in] format error message format
* @return runtime error object
*/
#define WPILIB_MakeError(status, format, ...) \
#define WPILIB_MakeError(status, format, ...) \
::wpi::MakeError(status, __FILE__, __LINE__, __FUNCTION__, \
format __VA_OPT__(, ) __VA_ARGS__)
@@ -172,7 +172,7 @@ namespace warn {
* @param[out] status error code
* @param[in] format error message format
*/
#define WPILIB_CheckErrorStatus(status, format, ...) \
#define WPILIB_CheckErrorStatus(status, format, ...) \
do { \
if ((status) < 0) { \
throw ::wpi::MakeError(status, __FILE__, __LINE__, __FUNCTION__, \
@@ -183,7 +183,7 @@ namespace warn {
} \
} while (0)
#define WPILIB_AssertMessage(condition, format, ...) \
#define WPILIB_AssertMessage(condition, format, ...) \
do { \
if (!(condition)) { \
throw ::wpi::MakeError(::wpi::err::AssertionFailure, __FILE__, __LINE__, \

View File

@@ -11,7 +11,7 @@
namespace wpi::util {
class raw_ostream;
} // namespace wpi
} // namespace wpi::util
namespace wpi {
/**

View File

@@ -12,7 +12,7 @@
namespace wpi::util {
class raw_ostream;
} // namespace wpi
} // namespace wpi::util
namespace wpi {
/**
@@ -66,7 +66,8 @@ class Tracer {
static constexpr std::chrono::milliseconds kMinPrintPeriod{1000};
wpi::hal::fpga_clock::time_point m_startTime;
wpi::hal::fpga_clock::time_point m_lastEpochsPrintTime = wpi::hal::fpga_clock::epoch();
wpi::hal::fpga_clock::time_point m_lastEpochsPrintTime =
wpi::hal::fpga_clock::epoch();
wpi::util::StringMap<std::chrono::nanoseconds> m_epochs;
};

View File

@@ -34,7 +34,8 @@ class Watchdog {
Watchdog(wpi::units::second_t timeout, std::function<void()> callback);
template <typename Callable, typename Arg, typename... Args>
Watchdog(wpi::units::second_t timeout, Callable&& f, Arg&& arg, Args&&... args)
Watchdog(wpi::units::second_t timeout, Callable&& f, Arg&& arg,
Args&&... args)
: Watchdog(timeout,
std::bind(std::forward<Callable>(f), std::forward<Arg>(arg),
std::forward<Args>(args)...)) {}

View File

@@ -782,9 +782,12 @@ class Color {
*/
explicit constexpr Color(std::string_view hexString) {
if (hexString.length() != 7 || !hexString.starts_with("#") ||
!wpi::util::isHexDigit(hexString[1]) || !wpi::util::isHexDigit(hexString[2]) ||
!wpi::util::isHexDigit(hexString[3]) || !wpi::util::isHexDigit(hexString[4]) ||
!wpi::util::isHexDigit(hexString[5]) || !wpi::util::isHexDigit(hexString[6])) {
!wpi::util::isHexDigit(hexString[1]) ||
!wpi::util::isHexDigit(hexString[2]) ||
!wpi::util::isHexDigit(hexString[3]) ||
!wpi::util::isHexDigit(hexString[4]) ||
!wpi::util::isHexDigit(hexString[5]) ||
!wpi::util::isHexDigit(hexString[6])) {
throw std::invalid_argument(
fmt::format("Invalid hex string for Color \"{}\"", hexString));
}
@@ -861,8 +864,8 @@ class Color {
return wpi::util::ct_string<char, std::char_traits<char>, 7>{
{'#', wpi::util::hexdigit(r / 16), wpi::util::hexdigit(r % 16),
wpi::util::hexdigit(g / 16), wpi::util::hexdigit(g % 16), wpi::util::hexdigit(b / 16),
wpi::util::hexdigit(b % 16)}};
wpi::util::hexdigit(g / 16), wpi::util::hexdigit(g % 16),
wpi::util::hexdigit(b / 16), wpi::util::hexdigit(b % 16)}};
}
/// Red component (0-1).

View File

@@ -57,9 +57,12 @@ class Color8Bit {
*/
explicit constexpr Color8Bit(std::string_view hexString) {
if (hexString.length() != 7 || !hexString.starts_with("#") ||
!wpi::util::isHexDigit(hexString[1]) || !wpi::util::isHexDigit(hexString[2]) ||
!wpi::util::isHexDigit(hexString[3]) || !wpi::util::isHexDigit(hexString[4]) ||
!wpi::util::isHexDigit(hexString[5]) || !wpi::util::isHexDigit(hexString[6])) {
!wpi::util::isHexDigit(hexString[1]) ||
!wpi::util::isHexDigit(hexString[2]) ||
!wpi::util::isHexDigit(hexString[3]) ||
!wpi::util::isHexDigit(hexString[4]) ||
!wpi::util::isHexDigit(hexString[5]) ||
!wpi::util::isHexDigit(hexString[6])) {
throw std::invalid_argument(
fmt::format("Invalid hex string for Color \"{}\"", hexString));
}
@@ -87,9 +90,12 @@ class Color8Bit {
*/
static constexpr Color8Bit FromHexString(std::string_view hexString) {
if (hexString.length() != 7 || !hexString.starts_with("#") ||
!wpi::util::isHexDigit(hexString[1]) || !wpi::util::isHexDigit(hexString[2]) ||
!wpi::util::isHexDigit(hexString[3]) || !wpi::util::isHexDigit(hexString[4]) ||
!wpi::util::isHexDigit(hexString[5]) || !wpi::util::isHexDigit(hexString[6])) {
!wpi::util::isHexDigit(hexString[1]) ||
!wpi::util::isHexDigit(hexString[2]) ||
!wpi::util::isHexDigit(hexString[3]) ||
!wpi::util::isHexDigit(hexString[4]) ||
!wpi::util::isHexDigit(hexString[5]) ||
!wpi::util::isHexDigit(hexString[6])) {
throw std::invalid_argument(
fmt::format("Invalid hex string for Color \"{}\"", hexString));
}