I need code samples of a Wall Following Robot using PID, with ultrasonic sensors. Or maybe some bibliography for studyng. Please
That is coincidence, I am working on exactly that since some time: http://forum.arduino.cc/index.php?topic=462107.msg3193700#msg3193700
I do use 2 sideways ultrasonic distance sensors to get an idea of distance to wall, and the angle wrt wall. The 3rd front ultrasonic distance sensor is used for full stop after high speed parallel to wall run:
My original task was "drive parallel in a given distance to wall". A PID controller for this (I have only done one simple PID before) would have 2 inputs (sideway distances measured) and 2 outputs (PWM signals for left and right motor.
I plan to have only one output value and interpret it as offset of the speed PWM values:
- 0 means both motors are set to s
- -x means left motor is set to s+x, right to s
- +x means left motor is set to s, right to s-x
This should eleminiate one output dimension.
Just today I relaxed my plan and modified the task to "drive parallel
in a given distance to wall". That way I can reduce to just one input value, difference of front and back sideways distances.
So with these modifications a simple 1 input 1 ouput PID could be used. This PID should fix easily, if caterpillar robot does drive a curve with both motors getting same PWM value – we will see.
It seems to me that the problem relaxation should better do than the original problem, since I only want to run robot(s) at maximal speed for measuring of that maximal speed. And that should be independent of the used distance to the wall [as long as the distance will not get too close to 0 ;-)].
P.P.S: I plan to use well documented Arduino PID library: https://forum.arduino.cc/index.php?topic=378555.msg2650641#msg2650641