If you use machine learning in the broader sense. You include a larger area around the car or truck. Then the battery would be aware of the road ahead. Like a stomach feeling. It knows all the bumps along the road or at least the probability of the road properties. Every road is then iterated in a algorithm to find the best updated settings at the needed time.