Real-Time Python Data Visualization
This project is the PC software that goes to this project, a racecar telemetry system. The goal is to take data from the PC/laptop's COM port and display it in real time for viewing in the pit lane at an endurance race. I considered doing this project in MATLAB as it is good at handling arrays of data like what this project requires, and I am more capable in MATLAB than in Python. I chose to use Python so that I could learn more about it and so I could use the program on any computer without needing a license. This project taught me mainly about Python and Object-Oriented programming.
Visualization window produced (car not connected) |
To start, I knew that I wanted to have a rolling graph of the last ~30 seconds of data received as well as a table with other values that need not be graphed. Like mentioned in the hardware part of the project, displaying the car's fuel consumption is the main goal with added benefit from also displaying other car variables as well.
The car currently does not have a GPS connected to the telemetry system, but I wanted to have functionality for a future addition. With this, there were three things to have onscreen: Time-graphs, a table of current values, and a map.
I chose to use Matplotlib for this project after some research into good visualization libraries for Python. It turns out not to be the best at animations and updating plots quickly but was mostly simple to use and intuitive.
I also chose to make a class for each major part of the program: Data collection from the serial port, data calculation to convert data to meaningful values, and visualization to plot those values onscreen.
The program is also multithreaded to make handling the serial port and updating the screen easier to manage together.
Here is the program, most of the important parts are documented with comments for your viewing pleasure.