Differential Drive Steering and PID

PID Controller

I have heard many times that "the system won't converge using the P term alone".

"Maybe that's why the bot did the drunk walk". If I can simulate mobility models in MATLAB, I can probably simulate a differential drive robot too.

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 Proportional-Controller

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.

A PD-controller

The "proper" way: add a differential term.

It quickly settles to the center and stays there. Magic.