I think my little car needs to know where it is relative to the wall it is trying to follow and what maneuver it is presently trying. Right now the code has three states:
1. Trying to go straight along the wall.
2. Trying to turn left sharply because something is in front, but not close enough for state #3.
3. Trying to brake and backup and turn to the left enough so it can return to #1 above.
There is a forth unofficial state in which it is completely lost. It usually gets there from state #2 by turning too successfully. It thinks it is in state #1 but is too far from the wall. If the room is too big it just keeps turning right making a big circle.
It has problems in each case.
In #1 it swerves rather than going straight. If it knew better its rate and angle of approach it could better decide how hard to make its corrective turn.
In #2 if it turns too hard and too successfully it becomes lost. If it does not turn hard enough it finds itself in state #3.
#3 works pretty well except when the front of the car is touching the wall. Something strange sometimes happens then. It just stops. I am not sure why.
My model level car has a POT with which I tell the PIC how fast to go. The top POT position is no where near top speed for this particular model. Associated with each of the seven POT positions are three distances: The ideal distance from the wall. The distance at which the car must enter state #2. The distance at which the car must go to state #3.
I have SONARs, PICBASIC PRO, and 16F887 to work with. Can my cars race inside a hockey rink?
Ken
Bookmarks