Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 1 | // 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 | |
| 9 | namespace frc { |
| 10 | |
| 11 | double 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 |