fix some stuff

This commit is contained in:
ary 2023-10-10 21:56:16 -04:00
parent 6ea107bf4e
commit 63cc52ef1e
3 changed files with 9 additions and 9 deletions

View File

@ -98,7 +98,7 @@ class PID {
* \param current
* Current sensor library.
*/
double compute(double current);
double calculate(double current);
/**
* Returns target value.

View File

@ -48,7 +48,7 @@ void PID::set_exit_condition(int p_small_exit_time, double p_small_error, int p_
void PID::set_target(double input) { target = input; }
double PID::get_target() { return target; }
double PID::compute(double dist) {
double PID::calculate(double dist) {
error = target - dist; // Calculate the error
derivative = error - lastError; // Calculate the derivative term
@ -63,9 +63,9 @@ double PID::compute(double dist) {
integral = 0;
}
output = (error * constants.kp) + (integral * constants.ki) + (derivative * constants.kd);
output = (error * constants.kp) + (integral * constants.ki) + (derivative * constants.kd); // Combine all of the terms to get an output speed
lastError = error;
lastError = error; // Set the last error to the previously calculated error.
return output;
}

View File

@ -31,9 +31,9 @@ void Drive::ez_auto_task() {
// Drive PID task
void Drive::drive_pid_task() {
// Compute PID
leftPID.compute(left_sensor());
rightPID.compute(right_sensor());
headingPID.compute(get_gyro());
leftPID.calculate(left_sensor());
rightPID.calculate(right_sensor());
headingPID.calculate(get_gyro());
// Compute slew
double l_slew_out = slew_calculate(left_slew, left_sensor());
@ -58,7 +58,7 @@ void Drive::drive_pid_task() {
// Turn PID task
void Drive::turn_pid_task() {
// Compute PID
turnPID.compute(get_gyro());
turnPID.calculate(get_gyro());
// Clip gyroPID to max speed
double gyro_out = util::clip_num(turnPID.output, max_speed, -max_speed);
@ -77,7 +77,7 @@ void Drive::turn_pid_task() {
// Swing PID task
void Drive::swing_pid_task() {
// Compute PID
swingPID.compute(get_gyro());
swingPID.calculate(get_gyro());
// Clip swingPID to max speed
double swing_out = util::clip_num(swingPID.output, max_speed, -max_speed);