in short, I want to implement a PID controller that takes in distance and returns velocity.
Details: I am simulating robots following each other. I wish to maintain a constant distance,
d between these robots. I can obtain the distance between the robots at any time and then I can adjust the velocity of the following robot accordingly. My problem is the formulation that achieves the transformation of the information provided by the PID to velocity so as to achieve this constant distance. My current attempt is to use the error provided by the PID as the velocity for the following robot, that is;
v2 = e(t)
v2 is the velocity of the second/following robot and
e(t) is the error yielded by the PID at time
The problem with this approach is that it vehicle velocity is only as big as the error, so that way velocity only increases if the error increases, so if the constant distance I want is relatively small. I can never achieve this.
I also tried using the error as the acceleration, with the idea that the velocity should only grow as error grows and decrease in a similar fashion according to:
v2 = v2 + e(t) * dt
where 'dt' is the change in time.
But then when I get negative errors. I wish to avoid reversing or backward motion. So we can call it a stop-go implementation if possible. But ideally when the error in the desired distance reduces ultimately both velocities will be moving with the same velocity. Any approaches and suggestions will be highly appreciated. Thanks very much. I am doing all implementation tests in python. If more clarification is needed please let me know.