Forget PID at first. If we assume PID, we're skipping steps.
Write down what we know. From your description:
process variable : position
input : (other robot's position - following distance)
loop output : this robot's position
plant input : velocity
plant output : this robot's position
plant dynamics : simple integrator
Now we can draw a system diagram:
Let me just reiterate some points that I understood from your problem:
e(t) is the distance from the target distance. So if e(t) = 0.5 and you want to maintain
1m distance b/w robots current distance is 1.5m correct?
You said PID is giving this error which I didn't understand. I believe your approach is correct just needs some corrections.
Instead of using ...