How Regatta's IoT solution helps rowers work out and compete
The Regatta project is an effort by startup Regatta Fitness LLC, which is revolutionizing the way people work out by providing an integrative technology platform for use in group settings (fitness classes or competition teams) and at home. Whether you’re an Olympic rower, weekend warrior, or just someone looking to get into better shape, Regatta provides you with the complete experience: challenge yourself in competitive team-based classes, track your progress, improve at home, and stay accountable by connecting with friends.
In this project, Microsoft worked together with Regatta to create a software solution for its new group rowing studio.
Key technologies used
- Azure DocumentDB
- Azure IoT Hub
- Azure Stream Analytics
- Microsoft Power BI
- Web Apps feature of Azure App Service
Baiyin Zhou – Founder, Regatta
Stephanie Volftsun – Developer, Regatta
Jeremy Foster – Project Lead, Microsoft
Daniel Egan – Developer, Microsoft
Tim Reilly – UI Developer, Microsoft
Rachel Weil – UI Developer, Microsoft
Regatta provides classes and technology to help rowers and aspiring rowers exercise in a fun and productive way. The Regatta software allows rowers to track their progress, set goals, and motivate each other in a group setting.
One of the hottest exercise machines right now is the Water Rower. Many gyms have already implemented fleets of these machines, and they are selling out at exercise retailers around the world. One store in Seattle, WA, claims to sell more Water Rowers in one week than any other rower model it has sold since opening the store.
These exercise machines have an excellent reputation for facilitating individual workouts, but the opportunity is clear for digitally capturing rowing data and using it to visualize performance, create interactive exercise sessions, and even facilitate healthy competition.
Combined hardware and software solutions for facilitating such collaborative exercise does not currently exist. This fact, combined with the huge value of rowing as an exercise and the popularity of the Water Rower device specifically, leaves a massive opportunity to build something in this space.
Solution and steps
Microsoft and Regatta worked together on a project to use the power of IoT and the cloud to capture some of these new opportunities. The goal was to build the foundation for a technology solution that will be used in group rowing studios to facilitate exercise sessions.
The solution pulls in data from multiple rowing machines simultaneously in distributed exercise sessions, and aggregates the data into a graphical interface that allows rowers to visualize their performance and that of the other rowers in the same session. This visual feedback gives rowers the information they need about their progress and the remainder of their workout, but more importantly, it has the power to motivate them to compete with their own and their peers’ performance in the current session as well as historic sessions.
The Regatta solution is a new and complete application to act as a launch point for Regatta’s exercise studio. The application architecture is diverse and includes IoT devices as well as an API and a graphical front end.
Regatta project architecture
The Water Rower
waterrower npm module acts as the device driver in this project. It allows for easy, two-way communication between the exercise machine and the Raspberry Pi Zero (RPZ).
When a rower uses the machine, data is updated in the onboard S4 monitor and across the USB connection to the RPZ where memory locations can be read, projected, and then sent to IoT Hub.
This module was created using Rx.js and allows for modern stream consumption and manipulation by the consuming code (the
device project in this case).
The Water Rower
Water Rower S4 monitor
Device used and code artifacts
The device project
This project can be deployed on any IoT device that contains a USB host port and the ability to run Node.js. The target device for this project is the RPZ.
The device portion of the project can be executed on any device that a) has a USB port for connection to a Water Rower device and b) is capable of running Node.js v4+. Additionally, the project includes a device simulator making it possible to develop on the project without an actual Water Rower device, as well as allowing a developer to simulate multiple simultaneous rowers in a group session.
The device code is a Node.js application with a dependency on a separate Node.js module that acts as a USB driver for the Water Rower device. This separation allows for future expansion onto other exercise machines.
The API project
The API project runs in a Web App in Azure App Service and implements the vast majority of the business logic as well as application state. All data generated from each rower in a session is sent to the API project and never communicates directly with the interface. Similarly, the interface retrieves state and reports user interactions directly to the API and does not communicate directly to the individual rowing devices.
The API uses a hybrid approach to communication employing an HTTP REST interface, a socket channel, and an IoT Hub. The communication strategy for any given message depends on the strengths of each of these mediums.
In its current state, the app certainly does not need all three of these communication mediums, but they exist to provide a basis for future requirements.
The REST API exists to facilitate durable and less frequent communication for where an active socket connection might not make sense. For instance, if an app simply needs to fetch a list of active sessions from the server, a one-time REST request may be preferable to the establishment of a socket connection.
The websocket connection is technically capable of facilitating all of the communication for the app, but it would not scale to the planned multitenant solution this project intends to create. That’s why we have Azure IoT Hub.
Azure IoT Hub exists to facilitate device-to-cloud (D2C) messaging at great scale. It’s also capable of cloud-to-device (C2D) messaging.
The UI project
The interface has been implemented in a modern Angular 2.0 interface.
In this proof of concept project, the UI is somewhat minimal. Its primary function so far is to display a table of rowing data as it arrives through the API. Each rower’s distance, speed, and calorie count is displayed. Additionally, when any rower meets the race distance, that rower’s row in the table is highlighted.
Exercise activity is being sent from the rowing machines (the device project) through Azure IoT Hub to the API project. These exercise machines can be located anywhere in the world, so security is obviously a concern.
Security concerns in this solution include at the transport layer, in the device registry, and on the server in the case of a multitenant environment.
Thankfully, Azure IoT Hub forces us into a good security pattern by requiring secure AMQP communication for messages as well as device registration and authentication. That takes care of the requirements for transport layer security and the device registry.
Every rowing machine involved in the solution will be registered with Azure IoT Hub, and any attempts by fraudulent devices could be easily detected. Future iterations of this project should certainly add functionality to make device onboarding programmatic to minimize administration.
Security on the server from cross-tenant corruption or unauthorized access would have to depend on the business logic we end up implementing later in this project’s life cycle.
It’s likely that the websocket channel will be able to facilitate the very small C2D messages that are planned so far even when this project scales to a multitenant solution. If that proves to be untrue according to load testing, transitioning the C2D messages to IoT Hub would be a straightforward task.
Data processing, storage, and visualization
The data collected and reported by participating rowing machines is rather high resolution and is already being processed by the API web service and held in temporary state for visualization in the web UI.
We should not, however, overlook the potential value of this data. It represents the exercise behavior and performance of every participant in the program over time, and is likely rich with learnings that could steer the course of the business for the better.
For this reason, we are feeding the exercise data through Azure Stream Analytics and into a DocumentDB database for long-term storage as well as into Power BI for analytical data visualizations. Again, so much more could be done with the analysis of this raw data.
Conclusion and final words
This project represented the birth of a solution and a launching pad for future ideas and features for the Regatta platform. Because it was a greenfield application, the technology stack that was chosen and implemented is modern and ready to grow. The project has some extremely powerful cloud services at its disposal and is ready for prototyping on a tiny scale or massive loads for testing and scaling out.
Learnings from the IoT project with Regatta
- Choosing Angular 2.0 for the interface proved to be a good choice because it allowed the team to learn a new technology in addition to making it easy for new team members to come up to speed on the project.
- There are far more good ideas around this project than there is time, so we have depended on the scoping exercises and documentation we did in the beginning.
- The waterrower module has been published to GitHub as well as npm, and although it is a specific driver for a specific exercise machine, it contains some patterns and practices that may be beneficial to other projects. The module uses the serialport library for communication over USB via Node.js. It also implements RX.js for stream management.
- The UI project contains a good reference project for an Angular 2.0 application.