see more from the shoots! NSFW

Python – Following distance automotive system and braking system

Keeping an adequate following distance is the main priority of this system.

This post is merely a really neat project I thought of while looking down at the instrument cluster in vehicle I was driving. This functionality can show the distance from the vehicle in front of you and how long it may take to stop in seconds using a float e.g. 4.2s. What happens is if you get too close to the vehicle in front of you a warning will appear ‘Distance Warning’, if you get even closer the system will slow the vehicle down (make a notice ‘Slowing Vehicle’ message for our app) commonly used in ‘Adaptive Cruise Control’ systems.

So the idea is to break all this down into a Python script to accept some input like ‘speed distance’ and start from there to calculate the following distance. Next you will need some system defaults for minimum distance which could be a measure of speed and distance to an acceptable distance and if those are not met perform an action. Make this system first, below this becomes something more than what is even in most vehicles today so we are actually inventing stuff here.

Now above is the default system but this could be improved with future technologies to assist us to be more advanced and work for large commercial trucks using their weight because this will increase/decrease the stopping distance needed. Even better using weather and time of day data from the camera or sensors then even road layout like a straight/curvy road. For the input you will need to specify a generic vehicle type like car, car trailer, rv, rv trailer, pickup, pickup trailer, semi, semi trailer. Note ‘ car trailer’ is a car towing a trailer. Then empty, light load, heavy load if the vehicle has a trailer, all this advanced data will be added to the end of the default system input.

More on this later as I create my own system try making the default system first as this advanced stuff is still sloppy, I would suggest building this as a class with loop to make an active testing script so you can continuously input various vehicle setups, example look at my ‘DCSrape’ code here on this site for looping data which I need to convert to a class too.

Enhanced system scenarios with road types the best road being Interstate.. Dirt, Road, Highway, Interstate. When the weather or road is ‘worse’ you should have a larger following distance. If the road is flagged as ‘construction’ again more following distance.

  1. Dry afternoon straight interstate
  2. Snow, morning, curvy road
  3. Rain, night, straight highway
  4. Rain, afternoon, straight, construction

Leave a Comment