# Cycling Motion Data Analysisby Omid Sarbishei, Ph.D.

Posted on March 30, 2017 at 8:38 pm8:38 pm

The Neblina™ motion tracking module can be used in a variety of applications related to health or sports. To showcase the applications of our technology, we hereby present an experiment we performed on a bicycle. Three Neblina ProMotion development kit boards have been used as well as a small magnet. The setup for our experiments is shown below:

As shown in the above figures, a GoPro camera has also been attached to the bike, while an external camera has been used to film the bicycle movements and correlate that with the motion data extracted from the ProMotion boards.

### Recording Motion Data using Neblina

After setting up the boards and the magnet, we have made use of our open-source Neblina Control Panel iOS application (available here) to do the following steps:

1) Connect to Board#1 using Bluetooth Low Energy (BLE) interface. You can see a list of available devices on the left panel when you run the iOS application. Next, enable all the motion streaming features by setting the “Motion Data Stream” button to ON. This will enable the streaming of both raw sensor data, and fused basic motion features. The streaming data includes raw accelerometer, gyroscope and magnetometer readings, as well as orientation quaternion found by our proprietary orientation filter, external force vector, rotation and pedometer information.

2) Start the recording on Board#1, by setting the “Flash Record” button to ON. Notice that one of the LEDs on the corresponding board will start blinking indicating that a recording session is in progress.

3) Repeat Steps 1-2 for the other two boards.

4) Perform the experiment with the bike…

5) Connect to Board#1 again and set the “Motion Data Stream” button to OFF.

6) Stop the recording for Board#1 by setting the “Flash Record” button to OFF. Notice that the blinking LED will go OFF to indicate that the recording session is stopped.

7) Repeat Steps 5-6 for the other two boards.

8) Connect Board#1 to PC using the micro USB cable. Make sure that you power the board down by holding the reset button for ~20 seconds before connecting it to PC.

9) Run our open-source “streammenu.py” Python application (available here):

10) Dump the recorded data to CSV files on your PC using the “storagePlayback” command:

sessionPlayback   // should be set to 1

Note that you can also check the total number of recorded sessions present in the on-chip recorder, as well as the length of each session using the following commands:

getSessionCount //gives the total number of sessions present in the recorder
getSessionInfo  //gives the length of 

The dump CSV files will be available in the “record” folder:

11) Exit the interactive shell using the “exit” command, unplug the ProMotion board, and turn it off by holding the reset button for ~20 seconds.

12) Repeat Steps 8-11 for the other two boards.

### Offline Data Analysis

After all the raw and fused motion data from Boards 1-3 were mapped to CSV files, we performed some offline analysis over the collected data to showcase the capabilities of Neblina using the Scilab tool. Each board can contribute to extracting certain motion features, which are explained below:

Board 1: This board is stationary (not rotating), and is placed next to the wheel. A magnet is attached to the wheel as well, which rotates with the wheel. This board is capable of capturing these features:

1. Wheel rotation count: As the magnet passes by the board, the magnetometer readings on this board will indicate a spike, which corresponds to a full rotation cycle.
2. Bike Speed: the rotation per minute speed for the wheel can be extracted from the rotation count values, and knowing the wheel diameter, one can accurately calculate the velocity of the bike in km/h, etc.
3. Bike tilt and overall balance: The roll angle on this board will accurately deliver the tilt angle of the bike. For instance, if going fast and on a left/right turn, the rider might tilt the bike towards left/right. This board will be capable of tracking that angle in real-time.
4. Going up/down slope: The pitch angle on this board is a direct indication of the bike’s overall elevation. Hence, if we are going up/down hill, the pitch angle will be increased/decreased. As the pitch angle exceeds a certain upper/lower bound, e.g., 15 degrees, one can categorize the biking activity as a up/down hill ride.
5. Jumps: The free-fall detection on this board can help to detect the potential short distance jumps, an adventurous rider might perform.

Board 2, 3: These two boards are mainly helpful in tracking the pedal rotation and cadence. With regards to the ProMotion board, these two nodes will provide similar information, and one could use either one based on personal preference and ease of use. We can combine the information from pedal cadence (Board 2 or 3), bike’s speed and elevation (slope angle) using Board 1, to calculate the cycling power.

It is worth noting that if someone aims to track muscle activities using another sensor, the best position to place the next node will be on the thigh. One can track cadence using the node on the thigh as well.

The boards have been time-synchronized by sending a command from the host application on PC to reset their timestamps. They have also been commanded to record their motion data on their on-chip NOR flash recorder. The motion data includes the raw 9-axis acclerometer, gyroscope and magnetometer data as well as some fused information including orientation quaternion found by our proprietary orientation filter, rotation count and rotation speed.

#### Tracking the Pedal Count and Cadence

The orientation filter on Board 2 delivers the pitch angle, which is a direct representation of the pedal cycles. Here is a snapshot of the pedal cycles, where cadence has gone up to 100 rpm.

At the beginning, the pedal has been stationary as can be shown in the above figure.

#### Tracking the Wheel Count and Speed

The magnetic field intensity on Board 1 delivers spikes indicating a full wheel rotation cycle. The magnetic field intensity is found by the magnetometer readings as follows: $$B = \sqrt[]{m_x^2+m_y^2+m_z^2}$$

Board 1 also delivers the wheel speed in revolutions per minute (rpm). Here is a snapshot of the magnetic field intensity representing wheel rotation cycles at a cadence around 100 rpm:

#### Tracking hill slope

The orientation filter on Board 1 delivers the pitch angle, which is a direct indication of going up/down hill. The snapshot below shows how the pitch angle matches the actual bicycle elevation. The rider first elevates the bike to pass the curb and then gets to a bumpy path and goes downwards. The elevation angle of the bike in degrees is shown in the picture. The little peaks and valleys that are observed in the pitch signal are due to the fact that the path was a bit bumpy and the sensor was pushed up/down by a few degrees.

#### Tracking Direction and Turns

The orientation filter on Board 1 computes the yaw angle in real-time, which can be used to detect taking turns and the direction of movement.

#### Tracking Bicycle Tilt and Balance

The orientation filter on Board 1 delivers the roll angle in real-time to track the bicycle’s overall tilt to the left/right. As the bicycle tilts to the left or right the roll angle will change accordingly. To showcase this feature, we have combined the results in a short video here. The video shows the GoPro camera capturing the tilt angle and the graph is the data coming from Board 1 and Board 2 to deliver real-time pedal count, wheel count, and the tilt angle. The tilt angle is visualized both numerically and graphically. The secondary external camera, which captures the movements of the bicycle and the rider, is also integrated in the video below:

If you require further information or assistance on how to perform the aforementioned offline data processing and visualization in Scilab, please do not hesitate to send us an email at (mailto://info@motsai.com) or drop us a line at +1-888 -849-6956.