The reopening of public gyms has attracted an influx of fitness lovers as the world gradually recovers from the effects of the pandemic. In particular, we saw a massive wave of fitness craze among our peers while transitioning into university as workout sessions became integral to many students’ daily routines. As frequent gym-goers, we were inspired by this phenomenon to create “4Gains”—a product that targets the growing fitness demographic and improves the gym experience for all fitness lovers, beginners, and pro athletes alike.
Easily mounted onto any weight stack, the 4Gains unit provides immediate feedback to the user on the quality of their workout sessions through its various sensors. Upon a button press on the device, the program begins to track a variety of metrics, including session duration, number of reps performed, movement distance, acceleration, and stability. The program then offers the user a visual representation of their fitness progress, which they can access through a web application. We envision 4Gains as a tool that makes fitness more accessible to novice gym-goers while providing valuable personalized suggestions to veterans. Demo video: Introducing 4GAINS | 4FUN - 2022 SE101 Project
The 4Gains personal trainer comprises three key modules: a hardware component that consists of sensors collecting data from the user’s workouts, backend programs and scripts that retrieve process, and store the collected data, and a frontend React web application that displays the processed data through graphical representations. In addition, the custom APIs we have designed and implemented allow these components to work together seamlessly. First and foremost, the hardware component consists of an Arduino Uno connected to an HC-SR04 ultrasonic distance sensor, an ESP8266 Wi-Fi module, a LED-light indicator, and a digital button through a BB830 solderless breadboard. The ultrasonic sensor collects distance over time data in intervals of 100-milliseconds and the collected data is first processed locally to count the number of repetitions completed during the set. The number of repetitions and the distance data is then concatenated into a singular string and sent to a web server on the local network through the Wi-Fi module and concluding the hardware component.
The string sent to the local web server is then parsed by the python script ParseGraphForDistance.py, which scrapes the HTML web page for distance values over time in an integer variable length array by utilizing the BeautifulSoup python library. It reads the specified text from the HTML page and stores it in a list, which gets uploaded to the MongoDB distributed database which is then fetched through a custom API by the dataProcessing.py python file. The file iterates through the parsed list and implements data smoothing, removing any outlier points and reducing the overall noise of the dataset through an anomaly recognition algorithm. The data is then iterated through again and the velocity, acceleration, and stability over time datasets are determined by taking derivatives. Additionally, the distance data is parsed to count “good” reps. The clean distance, velocity, acceleration, stability, and rep data is reuploaded to the MongoDB database using dynamic paths in Flask to save each set of data in its respective table, able to be fetched by the front-end component at any instance to display for the user.
Finally, once the data parsing and processing have been completed by the python scripts and the backend components, the front-end module fetches the final dataset from the MongoDB database through another API and displayed it to the user on a React-based web application hosted on one of our group member’s personal domains. The distance, acceleration, and stability data are displayed graphically to the users through the Victory wrapper component, and the web application is made much more visually appealing to the user through Tailwind.css.