30 requires std::is_arithmetic_v<T> || units::traits::is_unit_t_v<T>
33 if constexpr (std::is_arithmetic_v<T>) {
39 if (magnitude > deadband) {
40 if (maxMagnitude / deadband > 1.0E12) {
62 return maxMagnitude * (
value - deadband) / (maxMagnitude - deadband);
79 return maxMagnitude * (
value + deadband) / (maxMagnitude - deadband);
95 T modulus = maximumInput - minimumInput;
98 int numMax = (input - minimumInput) / modulus;
99 input -= numMax * modulus;
102 int numMin = (input - maximumInput) / modulus;
103 input -= numMin * modulus;
119 requires std::is_arithmetic_v<T> || units::traits::is_unit_t_v<T>
120constexpr bool IsNear(T expected, T actual, T tolerance) {
121 if constexpr (std::is_arithmetic_v<T>) {
122 return std::abs(expected - actual) < tolerance;
148 requires std::is_arithmetic_v<T> || units::traits::is_unit_t_v<T>
149constexpr bool IsNear(T expected, T actual, T tolerance, T
min, T
max) {
150 T errorBound = (
max -
min) / 2.0;
151 T error = frc::InputModulus<T>(expected - actual, -errorBound, errorBound);
153 if constexpr (std::is_arithmetic_v<T>) {
167 return InputModulus<units::radian_t>(angle,
#define WPILIB_DLLEXPORT
Definition: SymbolExports.h:36
UnitType abs(const UnitType x) noexcept
Compute absolute value.
Definition: math.h:721
@ value
the parser finished reading a JSON value
Definition: AprilTagPoseEstimator.h:15
WPILIB_DLLEXPORT constexpr units::radian_t AngleModulus(units::radian_t angle)
Wraps an angle to the range -pi to pi radians (-180 to 180 degrees).
Definition: MathUtil.h:166
constexpr bool IsNear(T expected, T actual, T tolerance)
Checks if the given value matches an expected value within a certain tolerance.
Definition: MathUtil.h:120
constexpr T InputModulus(T input, T minimumInput, T maximumInput)
Returns modulus of input.
Definition: MathUtil.h:94
T ApplyDeadband(T value, T deadband, T maxMagnitude=T{1.0})
Returns 0.0 if the given value is within the specified range around zero.
Definition: MathUtil.h:31
static constexpr const unit_t< PI > pi(1)
Ratio of a circle's circumference to its diameter.
UnitTypeLhs() max(const UnitTypeLhs &lhs, const UnitTypeRhs &rhs)
Definition: base.h:3417
UnitTypeLhs() min(const UnitTypeLhs &lhs, const UnitTypeRhs &rhs)
Definition: base.h:3409