mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpilib] Require non-zero positive value for PIDController.period (#3175)
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
|
||||
#include <hal/FRCUsageReporting.h>
|
||||
|
||||
#include "frc/DriverStation.h"
|
||||
#include "frc/MathUtil.h"
|
||||
#include "frc/smartdashboard/SendableBuilder.h"
|
||||
#include "frc/smartdashboard/SendableRegistry.h"
|
||||
@@ -18,6 +19,12 @@ using namespace frc2;
|
||||
PIDController::PIDController(double Kp, double Ki, double Kd,
|
||||
units::second_t period)
|
||||
: m_Kp(Kp), m_Ki(Ki), m_Kd(Kd), m_period(period) {
|
||||
if (period <= 0_s) {
|
||||
frc::DriverStation::ReportError(
|
||||
"Controller period must be a non-zero positive number!");
|
||||
m_period = 20_ms;
|
||||
frc::DriverStation::ReportWarning("Controller period defaulted to 20ms.");
|
||||
}
|
||||
static int instances = 0;
|
||||
instances++;
|
||||
HAL_Report(HALUsageReporting::kResourceType_PIDController2, instances);
|
||||
|
||||
Reference in New Issue
Block a user