Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Drive_PID_Tuner {
- public:
- Drive_PID_Tuner (pros::Controller* controller, lemlib::PID* pid);
- void print_values ();
- void change_values ();
- pros::Controller* controller;
- lemlib::PID* pid;
- };
- void Drive_PID_Tuner::print_values () {
- this->controller->print(0, 0, "P: %f", this->pid->p_gain);
- this->controller->print(1, 0, "I: %f", this->pid->i_gain);
- this->controller->print(2, 0, "D: %f," this->pid->d_gian);
- }
- void Drive_PID_Tuner::change_values () {
- double p = this->pid->p_gain;
- double i = this->pid->i_gain;
- double d = this->pid->d_gain;
- if (this->controller->get_digital(pros::E_CONTROLLER_DIGITAL_UP)) {
- p += 0.1;
- pros::delay(100);
- } else if (this->controller->get_digital(pros::E_CONTROLLER_DIGITAL_DOWN)) {
- p -= 0.1;
- pros::delay(100);
- } else if (this->controller->get_digital(pros::E_CONTROLLER_DIGITAL_Y)) {
- i += 0.01;
- pros::delay(100);
- } else if (this->controller->get_digital(pros::E_CONTROLLER_DIGITAL_X)) {
- i -= 0.01;
- pros::delay(100);
- } else if (this->controller->get_digital(pros::E_CONTROLLER_DIGITAL_A)) {
- d += 1.0;
- pros::delay(100);
- } else if (this->controller->get_digital(pros::E_CONTROLLER_DIGITAL_B)) {
- d -= 1.0;
- pros::delay(100);
- }
- if (p < 0.0) p = 0.0;
- if (i < 0.0) i = 0.0;
- if (d < 0.0) d = 0.0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement