So I have implemented PID control for a two wheeled drive robot with encoders on both motors. However I still havent achieved the robot to go dead straight. So my implementation is custom made. I m basically just getting the rate of change of each wheel and defining the error as the difference between their rate of change values. I then increment/decrement the speed of each wheel based on the error difference. So the robot can go straight but there is a little wobble that i m trying to get rid of.

I m wondering what the best implementation of PID control for a differential wheeled robot is? I had a look at the arduino PID library but this is for one input and one output. So you could use this library to define the input as the rate of change of the encoders, the setpoint as the desired rate of change of the encoders and the output as the speed of the wheel. So you could have two wheels trying to match a given set point. The only problem with this is the wheels are not compared to one another. So if there are any differences in the wheels allignment PID control wont compensate for any differences in wheel allignement. So my questions are the following,

• Can PID control be used to compensate for misalligned wheels so the robot can go dead straight?,

• Am i correct in defining my input of PID control to be the rate of change of the wheels from the encoders?,

• Is there an ideal way for PID control for a differential wheeled robot where you virtually have 2 inputs and two outputs?,

• Should the error between the two wheels be compared and effect the output or should PID just be applied individually to the wheels?