PID Control is a deep subject. It is a key area in self-balancing robots, drones, and other autonomous control systems. Here is a great video series so that you can explore these further:
- Youtube: Brian Douglas - PID Control - A brief introduction
I've greatly simplified some of the corner turning algorithms. A very in-depth article on how this was used for a competition winning Lego Mindstorms robot holds a more detailed method:
- G W Lucas - Using a PID-based Technique For Competitive Odometry and Dead-Reckoning
- http://www.seattlerobotics.org/encoder/200108/using_a_pid.html