[wpimath] ApplyDeadband: add a scale param (#3865)

Also templates it in C++ so it can work with both doubles and units.
This commit is contained in:
Oblarg
2022-04-30 23:29:48 -04:00
committed by GitHub
parent 03230fc842
commit 09cf6eeecb
5 changed files with 176 additions and 39 deletions

View File

@@ -1,23 +0,0 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include "frc/MathUtil.h"
#include <cmath>
namespace frc {
double ApplyDeadband(double value, double deadband) {
if (std::abs(value) > deadband) {
if (value > 0.0) {
return (value - deadband) / (1.0 - deadband);
} else {
return (value + deadband) / (1.0 - deadband);
}
} else {
return 0.0;
}
}
} // namespace frc