I want to steer a RC car in a straight line.The car has 4 sharp IR sensors on each corner of the car to help it steer the corridor.The corridor is irregular and looks something similar to the picture below.
The car needs to be stay exactly at the middle(shown by lighter line) and take help of the IR sensors to correct its path.
The car has a servo on the front wheel to steer and another that controls the speed.
I tried running it using a algorithm where it summed the values on each side of the car and took the difference.THe difference was then fed to a pid control the output of which went to steer the car.The greater the value from the pid (on either sides), the greater the value of the steering angle till it reaches the middle.
It works for the part where the walls are at similar distance from the center and even then it oscillates a lot around the center and fails miserably around the bumps in the corridor.
I need to make changes to the algorithm and need some help in steering me in the right direction.
The IR sensors are too finicky and is there a way to filter out the noise and make the readings more stable?
Any help regarding the changes that needs to be implemented is much appreciated.
Currently the car only uses 4 IR sensors to guide.I can also use 2 ultrasonic sensors.