do some stuff and stuff

This commit is contained in:
ary 2023-10-14 16:32:32 -04:00
parent 63cc52ef1e
commit 4db0295f42
3 changed files with 4 additions and 3 deletions

View File

@ -89,7 +89,7 @@ extern bool AUTON_RAN;
/** /**
* Returns 1 if input is positive and -1 if input is negative * Returns 1 if input is positive and -1 if input is negative
*/ */
int sgn(double input); int signum(double input);
/** /**
* Returns true if the input is < 0 * Returns true if the input is < 0

View File

@ -2,6 +2,7 @@
#include "util.hpp" #include "util.hpp"
using namespace ary; using namespace ary;
using namespace util;
void PID::reset_variables() { void PID::reset_variables() {
output = 0; output = 0;
@ -59,7 +60,7 @@ double PID::calculate(double dist) {
if (constants.ki != 0) { if (constants.ki != 0) {
integral += error; integral += error;
if (util::sgn(error) != util::sgn(lastError)) if (signum(error) != signum(lastError))
integral = 0; integral = 0;
} }

View File

@ -131,7 +131,7 @@ bool is_reversed(double input) {
return false; return false;
} }
int sgn(double input) { int signum(double input) {
if (input > 0) if (input > 0)
return 1; return 1;
else if (input < 0) else if (input < 0)