People do love their bicycles, whether they are used for fun or transportation, and spend lots of time riding them. Over 12 percent of Americans go cycling on a regular basis, and this figure is climbing. The number of regular cyclists increased from 43 million to 47.5 million Americans in the three years between 2014 and 2017. Biking is not always an option, but since it offers many health benefits for the rider, and is also good for the environment, it makes a lot of sense to encourage cycling. Getting the word out about the benefits of bike riding is one approach that could help to make this happen, but if you really want to get people interested in biking, the best path forward is to give them good reasons to want to choose to ride their bikes.
A very interesting idea developed by Jallson Suryo has real potential to make biking look a whole lot more appealing. He built a machine learning-powered bike suspension system, with the help of Edge Impulse, that automatically adjusts itself in real-time to provide the smoothest ride possible for the given terrain. The prototype developed by Suryo was built with just a few simple and inexpensive components, and by leveraging Edge Impulse Studio, no expertise in machine learning or software development was needed.
The battery-powered device consists of an Arduino Nano 33 BLE Sense development board and a common SG90 micro servo. A 3D-printed case was created to house and protect these few components, which was attached to a bike’s suspension system. The accelerometer onboard the Nano 33 BLE Sense was utilized to capture movement information as the bike is in motion. Suryo’s plan was to classify this movement data using a neural network that was trained to recognize different types of terrain, then use the micro servo to flip a switch on the suspension system that alters its behavior.
The first step in building the envisioned neural network was collecting the data that would be used to help that model learn. Arduino Science Journal was uploaded to the Nano 33 BLE Sense that had previously been mounted on a bicycle. This allowed Suryo to capture measurements from the accelerometer and transfer them to a companion smartphone app for storage. In this way, sample measurements were collected that represented the categories rough/gravel, medium/pavement, smooth/asphalt, and idle. The data files were uploaded to Edge Impulse Studio using the data acquisition tool, where they were automatically assigned labels and split into multiple samples.
The data was in good shape for further analysis at this point, so an impulse was created to perform the classifications. A spectral analysis block was added first, as this algorithm is well suited to extracting the most informative features from accelerometer data. These features were then input into a neural network classifier. The default hyperparameters looked just fine for this task, so Suryo kicked off the model training process.
The training classification accuracy was reported as being over 91%, so everything was looking good. But as a more stringent form of validation, the model was next tested against a set of data that was not involved in the training process. The result here was also quite good, coming in at a nearly 85% average classification accuracy. This was more than sufficient for a proof of concept, so the machine learning pipeline was ready to be deployed to the Arduino so that it could be used on the go.
Edge Impulse’s deployment tool allows the impulse to be deployed to dozens of hardware platforms with just a few clicks. For the hardware in this project, Suryo chose to deploy the model as an Arduino library. After downloading the compressed archive, it was imported into Arduino IDE and flashed to the board, just like any other Arduino sketch. The Arduino library option also offers a lot of flexibility — it enabled Suryo to add in his own code that controls the action of the servo based on the classifications made by the Edge Impulse model.
Suryo took the completed device out for a spin to see how it would fare in the real world. He found it to work so well that he thinks it might be useful for more than just casual biking and, with a bit more data collection and training, may be useful in sport cycling activities like cross country, trail, and downhill riding. By collecting the data as professional athletes ride, Suryo thinks there is potential to build some very smart bikes.
Pedal on over to the project write-up to learn how to add some smarts to your own bike, or, well, just about anything else that you have ever dreamed of improving with machine learning.
Want to see Edge Impulse in action? Schedule a demo today.