Differential drive is one of the configurations for robot mobility. It consists of two driven wheels on each side of the robot, and maybe some free wheels for stability. Each of the driven wheels has encoders that are able to count the revolutions in terms of angles or that are derived to speed with simple geometric equations.
The first task is to convert the pulses of the encoder into a linear displacement. This can be done with the following equation, which will give us a result of a factor that we’ll call
The following steps, which are not within the scope of this document, include the implementation of a PID controller with a constant linear velocity and setting a goal at a desired theta, which is taken from the following equation.
θdes=ArcTan[Sin[Ygoal-Y]/Cos[Xgoal-X]]
Now theta is the desired setpoint for the PID controller, and it is subtracted from the current theta, generating the error e(t) for the controller.