Page tree

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.

The ball physics model's main objective is to provide a point in time to the controller, when the ball is predicted to be hittable, in order to not let the ball fall into the drain.
The code for what is described in this section can be found in the files "physics.cpp" and "physics.h".

Table of Contents

Ball trajectory


The incline of the playfield causes a vertical acceleration, which is modeled via a graviatational pull with the factor g = sin(6°) * 9.81 m/s².
The value of 6° is the incline of the playfield  measured on the physical device.




The controller calls the function full_prediction passing it two subsequent ball positions with timestamps. From these a ball trajectory is infered as described above.
Along the trajectory future times  are stepwisetested for whether the corresponding predicted position is in the flipper range.
Once a position inside the flipper range is found the search is contiunued both forwards and backwards in smaller steps in order to find a good enough estimate of the first and last possible time to hit the ball.
If the trajectory does not intersect the flipper range within a certain prediction frame (see below "Prediction parameters") a value far enough into the future is returned, that will be overwritten by subsequent predictions.

With the current configuration the controller uses the middle point in time between the first and last possible time in order to be most positive to hit the ball.
The computed velocity is also passed to the controller and used is some more advanced  tactical decisions like catching balls.



Prediction parameters