Predicting Formula 1 Champions with a TinyML Model
Motorsport is quite a data-driven field that embraces technologies like machine learning, as each racing car is equipped with various sensors, collecting enormous quantities of data in real time. This experiment is aimed at predicting the fastest F1 car, based on accelerometer and gyroscope sensors. Since there’s no opportunity to use real cars for the project, the mentioned sensors will be fixed on a miniature F1 car.
The experiment consists of data collection, TinyML model training, and model deployment on a microcontroller.
Software Components
The code developed for this project was designed in Visual Studio Code with the extension Platformio.Platformio is a collaborative platform for embedded software development that supports a lot of boards of different vendors. It has a user-friendly interface with code completion and an integrated debugger.
For building the TinyML model to detect the fastest F1 car, the Neuton Platform was used. Neuton enables the fast and seamless creation of optimal models, offering a high level of automation in data processing and neural network pipeline generation.
Hardware Components
For this project, a completely new board on a well-known form factor, Arduino Nano 33 BLE Sense, was used. It comes with a series of embedded sensors:
- 9 axes inertial sensor: (it was used to detect the car movement behavior)
- Humidity and temperature sensor
- Barometric sensor
- Microphone
- Gesture, proximity, light color, and light intensity sensor
Procedure
Collecting data
To create a good dataset, measurements are collected by placing an MCU on a car and moving it at a different speed. The firmware makes readings on the accelerometer and gyroscope sensors to collect the data. It reads 2 seconds of data and calculates the statistics of those reading values. After that, it prints the statistics in CSV format to upload to the Neuton platform.
Training the model
Once the dataset is collected, you are ready to train the model. This project detects one of four possible targets, so it is a multiclassification problem. Neuton can automatically detect a task type based on the target variable values. You need to select the best metric to represent the model quality. For this project, “Accuracy” was selected, and the TinyML mode was enabled. Additionally, Neuton makes it possible to evaluate the quality of the trained models by visualizing the metrics.
Out of curiosity, it was decided to build a model on TensorFlow Light to figure out whether Neuton’s model had the smallest size or not. However, upon comparing the metrics, it turned out that Neuton’s model was 4 times smaller.
Deploying on a microcontroller
Neuton automatically generates the C library after clicking on the “Download” button.Once the library is downloaded, it’s time to run inference on a microcontroller. You need to set the input for your model with the same format you have trained it.
Explore more details by checking out the full project by Leonardo Goncalves!
Got inspired? Try Neuton for free right now!