diff --git a/include/gamepad/drive_curve.hpp b/include/gamepad/drive_curve.hpp index 96182d6..8d9c80a 100644 --- a/include/gamepad/drive_curve.hpp +++ b/include/gamepad/drive_curve.hpp @@ -35,7 +35,6 @@ class ExpoDriveCurve : public DriveCurve { * see https://www.desmos.com/calculator/umicbymbnl for an interactive graph * see https://www.vexforum.com/t/expo-drive-lemlibs-implementation for a detailed explanation * - * @param deadband range where input is considered to be input * @param minOutput the minimum output that can be returned * @param curve how "curved" the graph is * @@ -48,7 +47,7 @@ class ExpoDriveCurve : public DriveCurve { * lemlib::ExpoDriveCurve driveCurve(5, 12, 1.132); * @endcode */ - ExpoDriveCurve(float deadband, float minOutput, float curve); + ExpoDriveCurve(float minOutput, float curve); /** * @brief curve an input * @@ -70,7 +69,6 @@ class ExpoDriveCurve : public DriveCurve { */ float curve(float input); private: - const float deadband = 0; const float minOutput = 0; const float curveGain = 1; }; diff --git a/src/gamepad/drive_curve.cpp b/src/gamepad/drive_curve.cpp index 61ece3f..2d4f17a 100644 --- a/src/gamepad/drive_curve.cpp +++ b/src/gamepad/drive_curve.cpp @@ -2,22 +2,15 @@ #include namespace Gamepad { -ExpoDriveCurve::ExpoDriveCurve(float deadband, float minOutput, float curve) - : deadband(deadband), +ExpoDriveCurve::ExpoDriveCurve(float minOutput, float curve) : minOutput(minOutput), curveGain(curve) {} float ExpoDriveCurve::curve(float input) { - // return 0 if input is within deadzone - if (std::abs(input) <= deadband) return 0; // g is the output of g(x) as defined in the Desmos graph - const float g = std::abs(input) - deadband; - // g127 is the output of g(127) as defined in the Desmos graph - const float g127 = 127 - deadband; + const float g = std::abs(input); // i is the output of i(x) as defined in the Desmos graph const float i = std::copysign(std::pow(curveGain, g - 127) * g, input); - // i127 is the output of i(127) as defined in the Desmos graph - const float i127 = std::pow(curveGain, g127 - 127) * g127; - return (127.0 - minOutput) / (127) * i * 127 / i127 + std::copysign(minOutput, input); + return (127.0 - minOutput) / (127) * i + std::copysign(minOutput, input); } } // namespace Gamepad \ No newline at end of file