PID or auto correcting turn system help

Hi, this is my first year in vex robotics and I am new to any coding besides blocks. I know the basics of c++ and not much more.

As I’ve constructed a skills autonomous this season, I’ve noticed that my program is extremely inconsistent no matter what I do to the code. It can be so inconsistent that it almost scores different goals during different runs with the same exact code (even though all I do is change the battery and let the motors rest).

Anyway, I have been looking into creating a PID or some sort of auto-correcting turn system to make my runs more accurate. I have tried to find resources to help me with starting, but most teams keep their code to themselves so there isn’t a lot of examples or tutorials out there. If you could help me find resources, give me tips, or even show me an example program, that would be extremely helpful.

Thanks!

Edit: I would like to use the inertial sensor and c++ coding if possible.

Here is a document by George Gillard that goes over the basics of a PID control loop with pseudocode
http://georgegillard.com/documents/2-introduction-to-pid-controllers

And here is an example P loop in vexcode c++

2 Likes

Thank you! I’ll take a look at it.

Here is how you do forward/backward and turn PID:

for your turning, replace the variable from rightencoder-leftencoder to the inertial sensor heading

1 Like