Home / Blog / Measuring Soccer Ball Kick Accuracy with Machine Learning

Measuring Soccer Ball Kick Accuracy with Machine Learning

Dec 16, 2023Dec 16, 2023

Commercial, and therefore expensive, sports tracking solutions normally rely on computer vision in order to measure where a ball is located relative to a goal, such as in football, golf, or soccer. While quite useful, they are also quite finicky and are prone to disruptions caused by inclement weather, low levels of ambient light, and objects simply blocking the view of the cameras. Austin Allen wanted to make something more robust that would not have to rely on an expensive vision system, so he came up with a rebounder prototype that contains several accelerometers instead to determine where soccer balls are kicked.

A rebounder can be thought of as a springy net which acts like a trampoline for the ball. Baseball and soccer players use them to practice their accuracy, and their self-contained nature made them a great candidate. Allen's plan was to position four accelerometers- one at each corner, and use the differences in acceleration to calculate where the ball ended up, all without the need for a continuously running camera.

The metal frame of the rebounder was constructed from bent sections of electrical conduit due to its light weight and adequate strength. After joining the various pieces together with set screw couplings, a central tube was added down the middle to form part of the back brace and act as a mount for the electronics. Finally, a net was attached on each of the four sides with an elastic bungee cord to allow for the correct amount of bounce back.

Even though the MPU-6050 is an older sensor nowadays that has been outclassed by more modern designs, its reliability and inexpensive nature still made it a good choice for use in the project. Allen started by 3D printing a custom mount for each module and then zip tied the IMUs to the four corners before running the power bus and I2C bus lines up to the electronics enclosure. Once the base circuit had been verified with an ESP32 Dev Board and TCA9548 I2C multiplexer breakout, he designed a custom PCB that had connectors for the four MPU-6050s, an indicator LED, and the previously mentioned ESP32 and TCA9548.

Before any information could be read from the accelerometers, they had to first be configured to use the full +/- 16g scale and the fastest polling rate for getting new values as soon as possible. Grabbing the data from each MPU-6050 was accomplished by first telling the I2C multiplexer which I2C line should be active. Next, the ESP32 requests the values from the X, Y, and Z registers over I2C and stores them, with the final step involving a conversion from the raw ADC value into understandable units of acceleration. Lastly, the result is printed over Serial for a host script to store and process later.

The process of training a model to accurately determine a ball's position on the net began with collecting the raw training and testing datasets. A webcam set up below the net records where the ball has landed while the accelerometers are constantly being polled. Once a bounce is detected, the MPU-6050 data is labeled with the location of the ball as determined by the webcam, and everything is passed to a recurrent neural network in TensorFlow for training.

Overall, the model was able to guess the ball's position within 0.2 inches on average using just the accelerometers, and it could be further improved by collecting more data, having a faster polling rate, and increasing the camera's resolution/frame rate. This proof of concept shows much promise in the world of sports training, and more information about it can be found here in Allen's write-up.