blob: 19cd214ead564cd7737091705f47d36f735e5f61 [file] [log] [blame]
Austin Schuh812d0d12021-11-04 20:16:48 -07001// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#include "frc/MathUtil.h"
6
7#include <cmath>
8
9namespace frc {
10
11double ApplyDeadband(double value, double deadband) {
12 if (std::abs(value) > deadband) {
13 if (value > 0.0) {
14 return (value - deadband) / (1.0 - deadband);
15 } else {
16 return (value + deadband) / (1.0 - deadband);
17 }
18 } else {
19 return 0.0;
20 }
21}
22
23} // namespace frc