Trying to write a unique obstacle avoiding car

consider adding something like the following (some what edited to exercise the different parts of your code. Add an autoFlag to en/disable your existing code