Skate Tricks Recognition Using Gyroscope
In this article, we’ll describe how to recognize skateboard tricks using a gyroscope. This sensor is already present in most smartphones, but if you’re not familiar with it, here is a description.
Before we dive in, a small disclaimer: This project originated as part of a Slido hackathon with the goal of demonstrating that it’s possible to recognize skateboard tricks using a gyroscope. For simplicity, we’ll focus on recognizing just two basic tricks and won’t consider the skater’s stance on the board.
Recording the Trick
Let’s start with trick recording. To obtain precise data, the device with the gyroscope needs to be attached directly to the skateboard. Place it on the bottom of the board to avoid interfering with the execution of the trick. The device should also be compact and lightweight to avoid altering the board’s center of gravity.
Here are a few setups to achieve this:
a) Two Devices:
One device records and sends the data, while the main device stores and processes it.
- Pros: The recording device can be very small and lightweight due to fewer components.
- Cons: More complex setup, requiring management of data transmission.
b) One Device:
A single device handles recording, storing, recognizing, and displaying the output.
- Pros: Simpler setup with no need for data transmission management.
- Cons: The device may be larger and heavier and requires additional hardware to display the output.
For my initial approach, I chose the two-device setup. The simple device consisted of an Arduino Nano with an MPU-6050 Accelerometer and Gyroscope module, a Bluetooth HC-06 module, and a small battery. The main device was an Android smartphone that received data via Bluetooth.
The communication process is quite straightforward. Once the devices are paired via Bluetooth, the Android phone sends a message to start recording (1). The simple device then begins recording data from the gyroscope for 10 seconds (2) and sends it back to the Android phone (3). The data is subsequently stored in a file.
During this process, I encountered several issues:
- Device restarts due to poor connections between components, which was caused by shocks when landing tricks (I was using jumper cables).
- Bluetooth range limitations.
- The gyroscope occasionally stopped working after some time.
- Difficulties with debugging.
Due to time constraints, I also tested the second approach. In this setup, I used printed holders to attach the phone to the bottom of the board. While this setup was slightly larger and heavier, it was sufficient for testing purposes. Using this method, I was able to record two tricks (kickflip and shovit) multiple times.
Understanding Tricks
Gyroscopes provide various types of data, such as acceleration and rotation. For this project, I chose rotation as the primary data source. Each recording session lasted 10 seconds. Here’s how it works:
The raw rotation data initially appear messy because when the rotation reaches 180° or -180°, it flips to the opposite side of the axis (e.g., a value of 182° is converted to -178°). To clean the data while preserving its function, I added 360° to all negative values.
A simple formula was used to address rotation jumps by identifying large differences between consecutive values. Here’s how the cleaned data can be interpreted:
- In the first 2 seconds, I placed the board down, so this initial segment can be ignored.
- All three axes remain still during this period.
- The red axis represents vertical changes. A small ollie (jump) is visible here.
- The yellow axis shows flip rotation. For this trick (a shovit), there was minimal flip rotation.
- The blue axis indicates turning rotation. The data shows a rotation change of about 180 degrees in the middle of the graph, which corresponds to the shovit we were looking for.
The shovit was extracted around the 0.5-second mark.
To ensure consistent interpretation of rotation data, every change in direction on the board requires normalizing the rotation value so the graph remains centered around zero.
Trick Recognition
I had several ideas for recognizing the tricks, each described by three vectors (x, y, z axes). I started with the Dynamic Time Warping (DTW) algorithm, which essentially searches for the minimal distance between two time-series data sets.
I applied DTW to all my recorded samples and found a threshold that met my needs. Given that I only had six samples, I was able to use a brute-force approach to compare each sample against all the others. This method might not be practical with a larger dataset.
Summary
As a prototype, I consider it a success and had a lot of fun with the project. However, if I were to delve deeper into this subject, I would definitely take a different approach. The optimal solution would involve creating a large dataset containing numerous tricks recorded by multiple skaters. Additionally, I would record all available data types from the gyroscope, such as acceleration. For the hardware setup, I would opt for two simple devices installed under each skate truck, which would help differentiate between tricks like nollie and ollie. For recognition, I would likely use machine learning and offload the processing to a server, as the brute-force approach on the phone was time-consuming.
After completing my prototype, I researched similar topics and found several papers discussing the same problem with various algorithmic approaches:
- Development of a Skateboarding Trick Classifier Using Accelerometry and Machine Learning
- IMU-Based Trick Classification in Skateboarding
- Classification of Skateboarding Tricks via Transfer Learning Pipelines
As mentioned at the beginning, this project was initially part of a hackathon using Slido. Here is a short presentation with a demo at the end.
Comments
Post a Comment