Creating my own Cycling Trainer App

Creating my own Cycling Trainer App

I’m a big fan of Zwift, it’s a virtual cycling app that allows you to train and compete online in a virtual world.

I started training indoors in November 2018 when the weather was getting colder and I wanted a home setup that I could use if it was raining or snowing outside. Instead of buying an indoor cycling bike or spin bike, I invested in a smart bike trainer (Wahoo Kickr 2018) that I could use with my road bike (Trek Domane SL5). This would allow me to keep using my comfortable bike and it would allow an app to manage the resistance automatically (which isn’t common on a spinbike or a peleton).

The fun part is that Zwift would also allow you to train on courses inspired by real ones. For example, there is Alpe du Zwift which is a virtual copy of Alpe d’Huez in France:

Zwift only allows you to ride the courses they provide, some are made up, others are inspired by real cities/courses.

But… what if I want to ride somewhere that is more familiar to me? I spend some weeks understanding how to control the smart trainer via ANT+ / Bluetooth and started to create my own bike riding software using Unreal Engine 4.

It’s still WIP, doesn’t have pretty rider graphics but it does read the sensor data (Power in Watt), runs physics calculations on it and turns that into speed (similar to what Zwift does). It then applies the slope % to the Wahoo smart bike trainer for the appropriate resistance and also read the Cadence/Heart rate sensor data. During the ride it will record your stats into a fit file that you can upload to services like Strava.

Basically I created a flow (by writing custom UE4 plugins) where I can import an elevation map (DTM), road information and turn it into an UE4 landscape. This means that I don’t have to create the virtual world with too much manual effort and allows me to recreate a map of any place in the world as long as there is enough (elevation) data available. Fortunately for the Boston area, there is very precise data available (1 meter precision).

I took a ‘virtual ride’ at my old neighborhood. With the super steep Lowell St.:

Another experiment was Mount Greylock which is in Western Mass:

Creating my own Cycling Trainer App
Older post

NodeBeat featured on the BlackBerry Dev blog

Newer post

Inspecting Network Traffic of any Android App

Creating my own Cycling Trainer App

4 responses

  1. This was really interesting, is there anywhere to download it? I’m a game developer (mostly animation) as well who also loves Zwift and riding. I’d love to develop for them someday so right now I am researching ways to access the trainers etc. I have a few ideas I’d like to try. Well, thanks for sharing. Jim

    bagheeraphoto@gmail.com April 13th, 2022
  2. FYI - there are no field labelled here so a bit of guesswork to post a reply. Pretty cool. I am a retired engineer, and one of my sons is a software developer/programmer with some front end experience and back end experience and I think I might be able to interest him in putting something like this together collaboratively as I need some projects and I think it would be interesting/rewarding. My plan was initially do put together a structured training app that has limited control but would allow you to custom design some workouts to avoid having to manually control it while working out and then do something more gourmet similar to what you have done. I have a kicker as well and was wondering how to communicate with the smart trainer. Does wahoo have a manual (or something like that) for the data interchange? Bear in mind, I’m a structural engineer so my last bit of programming was about 25 years ago in crappy languages like fortran77 and even older. I’m assuming you did this on a laptop - can unreal be used to do some development on pc and port over to android or ios?

    Lyndon Trombley (trombleyfive@gmail.com) – December 30th, 2022
  3. It should be possible to port it to a mobile app (for now it’s separate apps/services because the signal processing from ANT+ was the trickiest bit). Ideally I would have everything in one app written in a crossplatform style. For a proof of concept i hacked things together though.

    Laurence Muller February 27th, 2023
  4. Unfortunately I dont have a binary that’s easy to be distributed. It requires a separate app to get the wireless signal and forward it to the game. And the game in unreal engine seems to only compile for x86 atm (I no longer have an intel mac, and on my m1 mac it wont build).

    Laurence Muller February 27th, 2023