Here is an awesome paper by Wesley Aptekar on the subject of PID:
I could not have explained this as well as he did so I think ill leave it at that!
Clearly the hard part is picking the kP kI and kD values for your PID loop. These values change from system to system and sometimes even robot to robot despite being identical copies. Here is an awesome interactive post by Wesley so you can hopefully get a feel of what is like to tune a PID loop:
It’s important to understand the concepts of PID however we hardly ever use them by themselves on our robot, they just don’t give you enough control. Say we want to accurately control the motion of a system at all times. This is where Motion Profiles come into play.
Heres Wesleys blog on the subject, you can ignore everything that says “state space” and just read it as “PID”, also the math gets kinda gnarly so just skip over that part:
Fortunatly for us, there is a ton of code already out there that does all of this for you! Talon SRXs are particularly special because they have all these methods of control built right in! We just need to plug in the constants and tune the values. Even tho it‘s incredibly easy to implement PID, its important to understand the fundamentals so you can better understand how and why a system acts the way it does.
So to sum it up, you should understand the concept of error and that we want to bring the error of a system to 0. A PID loop is a great way to achive this because it accounts for the momentum of a system (doesn’t assume you can instantly decelerate). However, we can take this one step further and implement a motion profile. This is essentially changing the set point of a PID loop to controll its motion more closely. There is a lot of math that goes into finding the right constants for things however we can normally just guess and check to find them pretty quick.