Saturday, April 23. 2016
RunnerUpWeb
The last project I am involved is RunnerUpWeb. A few hours ago I uploaded to github the first bits of the application. More or less it is usable right now although still in its infancy. Today's entry is the presentation of the application and my motivation to implement a project like this.
As you should already now I am a common runner / jogger since I was a teenager. Several years ago I usually wore the typical watch to measure time and heartbeat rate (using the associated belt) but the watch finally broke up and I did not replace it. That watch was just that, you could check the data at the moment, no traceability was done. Nowadays it is quite typical to see people running with the phone attached to their shoulder. I usually laughed about that situation (I thought that that was ridiculous) but some months ago I decided to buy a new watch. I painfully realized that all of them upload all your activities to their private cloud system (garmin, polar or whatever). I quickly understood that it would be a nightmare to block that and a hell to upload the data to one of my machines and not to other people's systems. (Remember we are talking about personal data like your heartbeat rate. I can hardly understand how people upload this kind of data to whatever place and without even reading the conditions. And the situation is even worse with those wristbands that monitors absolutely all your daily activity like sleep hours, steps, heartbeat... Please imagine how that data can be used by insurance companies or the value of the data itself if stolen.) Now I laugh no more about wearing the phone at the shoulder and I think that this is the only way you can use some trustable (opensource) application. I finally bought a bluetooth heartbeat-rate belt and another belt to carry the phone while running.
There are several apps to be used in the phone but I installed RunnerUp. Published in F-Droid RunnerUp is quite simple to use and it can connect to bluetooth smart devices like the heartrate belt. So eventually I had a working solution for the phone part of the problem. But... What about the server part? Can I upload my activity data to a private machine? The answer is nope. There is no application for that purpose (or I was not able to find one) and RunnerUp (or any other phone application) cannot upload to any other place than private services (endomondo, facebook runner, garmin, runtastic and so on). RunnerUp has a runneruplive service but this is just to show your race live in a map, not to store all your data for a later review. So I finally started a little application called RunnerUpWeb which is exactly that, an application to store and show your running activities that can be installed in your own machine.
What was my idea? The following basic lines were followed:
The application is a LAMP. The reason is quite prosaic. I have also owncloud installed in my machine and the box is old and not very powerful, so I wanted the same technology in order to reuse resources. I usually do not develop in PHP, so please be merciful.
As I commented RunnerUp only lets you configure some known private services. For that reason I decided to emulate one of them with my application. Digifit was chosen because it is a typical username/password service (which does not use even https I have to say) instead of OAUTH like the others. In order to send the files to my app for the moment you have to change the hosts file of the phone and point my.digifit.com to your intranet/internet machine IP. This way the phone RunnerUp application thinks that it is using common Digifit service instead of RunnerUpWeb. Emulating Digifit also needs some rewrite rules in the Apache server to complete the trick. I will need to talk with the RunnerUp devs in order to convince them about including my service (in theory easy to implement because it is the same than current Digifit).
Digifit uses garmin TCX files to record your activities. After this project I have realized that there are two main methods to store your activities and both use XML and garmin XSD (XML Schema Definition) files. The other option is using GPX which uses the standard format for displaying GPS data but using some garmin extensions to display specific training information (cadence, heartbeat rate and so on). For the moment my application just knows about TCX files.
RunnerUpWeb uses leaflet to show your routes and maps. The app is an opensource application so better to be attached to free maps (not google) like OSM.
RunnerUpWeb changed the way I usually code. I am not very good with User Interfaces so I decided to be stick to the roots. The PHP code just gives some RESTful Web Services and all the processing is done in the browser using javascript (JQuery). The pages are pure HTML that calls the WS and prints data using javascript (I do not know if I have taken the correct path cos some parts should be coded twice, in javascript and PHP, for example the TCX parsing).
For the moment the app is simple, it just shows your activities and show the map and some graphics for each one. Minimal configuration and user management have also been integrated. The application only works with modern browsers and currently is not very tested.
Finally I am going to show two videos. The first one shows how the phone application uses the Digifit service in order to upload some of my last activities. Please remember that right now I am cheating to make the phone to connect to my app (my phone is rooted with cyanogenmod).
The second video shows the use of the application with a sample file I downloaded from internet. Using my ADMIN user I create another test user. Once the user is created I log in the application. RunnerUpWeb can also upload TCX files directly (without the phone) and the sample is uploaded. The activity is located in the year 2007 and it is displayed using OSM maps by default. Some graphics (average speed and altitude) are also shown. Finally I change the user options to select a terrain model provider (this model sadly has detailed tiles only for the U.S.).
RunnerUpWeb is just a simple application to save your running activities (I suppose that it can also be used for cycling but for sure there are issues with non-running data). For the moment it is just the basics to store and display the activity in a map. The application can be extended in several ways (sharing, comparing activities, managing GPX files, localization,...) and a lot of testing is still needed (mainly with the javascript / browser part which I have no idea how to test automatically). But I have very little time these days so I cannot promise anything. I have the intention to document briefly how to install and configure the application in github. If you think it is useful for you please give it a try then and comment me about your experience.
Please watch your data!
Comments