Differential Drive Steering and PID
I have heard many times that "the system won't converge using the P term alone".
After working out the maths for the forward kinematics of differential drives, here's some results:
The Primitive Solution
The algorithm: curve to the left if it's too far to the right, and vice versa. It's not even a P-controller because the amount of correction is not proportional to how far it is away from the center. It works, but it wobbles:
... and clearly does not converge - it is unstable. If this trend continues, the bot will hit the wall eventually.
A controller with a proper P term (and P term only):
It can't even complete the track before hitting the wall. Let alone the fact that a real ultrasonic sensor won't work during those sections with 45 degree heading.
The "proper" way: add a differential term.
It quickly settles to the center and stays there. Magic.