Commit Graph

124 Commits

Author SHA1 Message Date
Jaap van Ekris 57cde02953
Improvement of the FullTS performance
Improvement of the Full Theil-Sen performance by using a Binary Search Tree for the Median Calculation, which is much more efficient for larger values of maxSeriesLength
2023-12-03 20:32:29 +01:00
Jaap van Ekris f6573cb0d6
Improvement of the FullTS performance
Improvement of the Full Theil-Sen performance by using a Binary Search Tree for the Median Calculation, which is much more efficient for larger values of maxSeriesLength
2023-12-03 20:30:27 +01:00
Jaap van Ekris 6681cfcc5e
Create BinarySearchTree.test.js
Added Binary Search Tree to improve the perfomance of the Median calculation
2023-12-03 20:26:05 +01:00
Jaap van Ekris f342e6691e
Create BinarySearchTree.js
Added the Binary Search Tree to greatly improve the performance of the Median calculation
2023-12-03 20:24:28 +01:00
Jaap van Ekris 26d41b8dd5
Removed unneeded command 2023-07-05 00:06:51 +02:00
Jaap van Ekris 43f337c6ce
Fix a reset bug
Fixes a reset bug
2023-07-04 23:57:50 +02:00
Jaap van Ekris 31fdb87eab
Fixes reset bug
Fixes a bug where a reset will not clear the timer
2023-07-04 23:56:31 +02:00
Jaap van Ekris 43d7e45aee
Fix a state machine bug
Fixed a bug where allowMovement() would be called at the start of the first drive, which would force it back to a paused state, causing all kind of weird metrics.
2023-04-28 20:22:14 +02:00
Jaap van Ekris a72fe3f017
Added interval number to RowingData
Added the interval number to the RowingData, allowing RowingData to recognize the intervals.
2023-04-24 13:26:02 +02:00
Jaap van Ekris b5e439cd50
Fixed typo's 2023-04-24 10:26:39 +02:00
Jaap van Ekris 41cee87b6b
Fix for HRR data
Fixed the wrong definition of HRR data
2023-04-23 22:12:56 +02:00
Jaap van Ekris 597ec7c765
Adoption to RowsAndAll timestamp spec change
Adoption to RowsAndAll timestamp spec change for the ElapsedTime
2023-04-22 20:34:43 +02:00
Jaap van Ekris 87a22795e4
Adoption to RowsAndAll timestamp spec change
RowsAndAll changed the specification of the timestamp, which caused the total rowing time to be inaccurate.
2023-04-21 19:27:32 +02:00
Abász dfc2881f36 Make changes to GUI to better support intervals
Change distance, timer and calories tile to change behaviour when
current workout is an interval session (i.e. not JustRow).
Expose data necessary for this in RowingStatistics. Remove miles option
from formatter.
2023-04-18 23:19:53 +02:00
Abász 918c9b53fa Remove formatting logic from RowingStatistics
Remove logic of formatting metrics in RowingStatistics and move these to
the consuming end (e.g. client).
2023-03-25 21:00:33 +01:00
Abász a1068cf77f Fix type conversion in the curveMetrics
Fix the string conversion of the curveMetrics and push the formatting
logic to the consumer that require this (eg. WorkoutRecorder). This
enables other consumers of curveMetrics to use non-rounded, "raw" data
instead of preformatted as well as avoid potential future bugs from the
type conversion.
2023-03-25 21:00:33 +01:00
Abász e7c40873cd Fix HR battery level not showing (fixes: #132)
Fix the HR battery level not showing on the HR metric tile (ANT and BLE)
For ANT handle case when BatteryLevel is not present only BatteryStatus.
BLE devices do not necessarily send battery level with all HR broadcast so
read the battery level on connect.
2023-03-25 21:00:33 +01:00
Jaap van Ekris bd97723f8b
Cut/copy/paste error in log message 2023-03-09 10:55:45 +01:00
Jaap van Ekris 97c1da96d6
Dealt with an edge case
Dealt with an edge case where there are no strokes detected, but a number of impulses is recorded (Typically during first calibration).
2023-03-02 11:25:20 +01:00
Jaap van Ekris 3e3cd7b838
Added ANT+ functionality and BLE improvements
Extend ANT+ peripherals and redesign inner structure of the peripheral management
2023-02-15 14:28:39 +01:00
Abász 7ef338d856 Refactor heart rate peripherals
Refactor ANT manager to be a central class managing the ANT stick state.
This state could be used for future implementation of other ANT profiles
and the peripheralManager should be responsible for creating once needed
2023-02-12 22:40:16 +01:00
Jaap van Ekris 6eed136caf
Move functionality to the Finite State Machine
On hindsight, the approach of letting the FSM handle all state transitions explicitly is much clearer
2023-01-16 12:18:46 +01:00
Jaap van Ekris e5696378b0
Fixed a Lint error 2023-01-15 17:34:25 +01:00
Jaap van Ekris 37edd0290b
Update to facilitate more complex workouts
Update to facilitate more complex workouts. RowingStatistics will now manage the intervals completely independently and alert server.js only when the session has ended.
2023-01-15 17:29:58 +01:00
Jaap van Ekris 3364ef38a8
Centralising parameter check
Removed sanity checks in RowingStatistics, as the configmanager centralises the parameter check
2023-01-11 23:30:11 +01:00
Jaap van Ekris ce9294dfb8
Centralising parameter check
Removed sanity checks in RowingStatistics, as the configmanager centralises the parameter check
2023-01-11 23:29:52 +01:00
Jaap van Ekris 11ff22eca1
Fixed a missing bracket 2023-01-11 10:15:48 +01:00
Jaap van Ekris b4e8f16b3c
Improvement of code quality
Replaced the horrible ested If...then....else with a much more readable case statement to implement the Concept 2 table
2023-01-11 10:12:54 +01:00
Jaap van Ekris 35ff3489a5
Fixed a typo in function name
To add insult to injury: by a typo in the error logging function, the app would crash if there was a recoverable error
2023-01-10 11:44:37 +01:00
Jaap van Ekris 062faa0190
A bit more defensive programming
A bit more defensive programming as one bad (NaN) measurement of CurrentDt will kill all metrics for the entire session.
2023-01-10 11:34:00 +01:00
Jaap van Ekris 6623aa2f86
Several bugfixes and improvements
Bugfix: Fixed a bug where a new year or month would crash the workoutrecorder due to a missing data directory

Several improvements:
* Added possibility of only creating RowingData file
* Improved HRR data when restarting a workout
2023-01-10 11:27:13 +01:00
Jaap van Ekris 9422716dca
Redesign of the rowing engine (#84)
* Looks like dead code

Dead code?????

* Improvement of the MovingAverager startup

Improvement of the MovingAverager's startup-behaviour, to allow use for the dragcalculation. In this approach, the defaultValue is only used when the array isn't sufficiently filled (less then two pushed values), but after that it is directly released and the average only depends on pushed values. This is especially important for the drag calculation, as the drag calcuation is sufficiently robust in handling errornous values, and drag factors might make big jumps in the beginning (i.e. from the middle setting to a maximum value).

* Allow the settings to set a specific priority

The nice-level of -20 is arbitrary and very counterproductive, as it dwarfs OS processes including the internal timer. This results in a more noisy measurement, even on a high-speced Pi 4. As the priority is dependent on the hardware/software configuration of the Pi anyway, I made the configuration setting more granular.

* Added Concept2 PM5 wiring diagram

Added wiring diagram for the PM5 (with 18V generator)

* Update server.js

* Delete app/engine/averager directory

* Creation of the series.js

Creation of a series of values, as an abstraction away from the array, with added standard functionality. This is the basis for the more complex functions like the regression series.

* Update the server.js to adapt to new architecture

Server.js has been adapted to fit the new architecture. It is now in control of the session, directing others how to proceed.

* Deleted Timer.js as it has become obselete

Deleted Timer.js as it has become obselete

* Updated to more abstract Flywheel.js

Renamed and rewritten to Flywheel.js. It provides an abstraction from the individual currentDt's and provides a more abstract view of the flywheel and its current state, which can be interrogated by Rower.js

* Created an initial testset for Flywheel.js

An initial set of tests to check whether Flywheel.js works as expected.

* Renaming variables and added new functionality

Renamed variables to fit the naming scheme of Rower.js. Added the option to create a RowingData file, hich can be read by RowingData, RowsAndAll and Excel. Also added new fields in the notes of a TCX, including HRR.

* Update Pm5Constants.js

* Update to the constants

Update to the constants, to make them closer to the actual firmware options. Also I added the Row to the name, as Concept2 also seems to do this on their current firmware.

* Added additional defensive programming

Added additional defensive programming

* updated variable names

Updated variable names to keep them in sync with RowingStatistics

* Added metrics and updated variable names

Added new metrics, like projected time and distance, stroke calories
Updated variable names to keep them in sync with RowingStatistics

* Added metric, states and variable rename

Added the dragfactor metric, aded the state for the workoutType, workoutDurationType, workoutState, RowingState and strokeState
Renamed most variable to allign them with RowingStatistics

* Added metrics, rename variables

Added several metrics (driveLength, driveTime, strokeRecoveryTime, strokeDistance, peakDriveForce, averageDriveForce and workPerStroke)
Alignment of variable names with RowingStatistics.js

* Renamed variables

Renamed variables to align them with the RowingStatistics naming convention

* Update variable definitions and naming

Update to the variable definition of speed: as almost all consumers use the m/s unit, we now use this internally, and only convert to km/h for the bike
Alignment with the naming scheme of RowingStatistics

* Update based on PM5 spec

workoutDurationType was a more complex enum

* Complete redesign

Complete redesign:
* Switched to a Finite State machine to maintain session state
* To reduce complexity, it directly inspects Rower.js, instead of awaiting messages to be processed
* Small snippets process all data, where updates are grouped based on their update moment
* Renaming all variables to clearly identify when they are updated (as determined by the state machine)
* Introduced a first version of interval management, as a preperation for future solutions with more complex training scheme's
This should help in reducing the code base while making the code easier to understand.

* Rename and adoptation to the new architecture

Split RowingEngine into two blocks:
* Rower (which represents the key metrics from the rower) and
* flywheel (which represents the key metrics of the flywheel, formally known as MovingFlankDetector). 
This should simplify the reading of the code, as Flywheel reports key metrics without the need to many specific configuration parameters.

Also added many metrics (including force curve, power curve and handle speed).

* Update and rename RowingEngine.test.js to Rower.test.js

Update to fit Rower.js better, includes testing with known rowers

* Introduction of VO2Max (Beta)

Introduction of a Beta-version of VO2-Max, which will be calculated each time a tcx-file is created.
It introduces two versions of VO2-Max calculation:
* extrapolation-based VO2Max: it extrapolates the power to maxpower based on MaxHR and the relation between HR and power in the session
* interpolation based VO2Max: it projects the session onto a 2K, and then calculates the VO2Max based on Concept2's research

* Beta version

Beta version of the BucketLinearSeries to accomodate VO2Max

* Create CurveAligner.js

CurveAligner for cleaning up the (power, force and handle velocity) curves

* Create Series.test.js

Added test-class to series.js, as it is so fundamental to OpenRowingMonitor

* Create StreamFilter.js

Streamfilter implements a running streamfilter. It is designed to be robust to outliers, and replaces all averaging functions.

* Create StreamFilter.test.js

Tests the steamfilter

* Create OLSLinearSeries.js

Creation of the OLSLinearSeries, to allow for drag calculation, VO2Max calculation and projecting calories, distance and time.

* Create OLSLinearSeries.test.js

Test of the Simple Linear Regression method

* Create FullTSQuadraticSeries.js

FullTSQuadraticSeries delivers Full Theil-Senn Quadratic regression, which is essential to determine Angular Velocity and Angular Acceleration in a noise-resistant way. These metrics are essential for force curve, power curve, handle velocity curve and stroke detection (as it is triggered by the force on the handle).

* Create FullTSQuadraticSeries.test.js

Test of the FullTSQuadraticSeries

* Create curveMetrics.js

Object to manage the specifics of curves

* Delete curveMetrics.js

* Create curveMetrics.js

Object to create curves and the associated curve metrics

* Update rowerProfiles.js

Update to accomodate the new RowingEngine, and its parameters

* Renaming variables

Renaming variables to align with the variable renaming in RowingStatistics.js

* Rename variables

Update variables to align with RowingStatistics naming conventions

* Update GpioTimerService.js

* Added example CurrentDt curve

Added example CurrentDt curve for explanation of good and bad noise.

* Testfile for Concept2 RowErg

Testfile for Concept2 RowErg, 2000 meters, for validation purposes

* Increasing consistency in logging

Increased consistency in logging specific messages

* Improved logging to facilitate configuration

Improved the logging of specific data to facilitate an easier setup for new rowers.

* Update backlog.md

* Update rower_settings.md

* Adaptation to the newly developed physics model

Adaptation of the text to the newly developed physics model.

* Removed the settings analysis as it isn't needed

Removed this tool, as it isn't up-to-date with the current physics model, and logging does a better job in helping the analysis.

* Updated to reflect the new approach

Updated the setup procedure to:

* Adapt it to the new physics model

* Adapt it to the new logging-based setup procedure.

* Added the Concept2 RowErg

Added the Concept2 RowErg configuration

* Added the Concept2 as test-object

Added the Concept2 as test-object

* Added the Concept2 as test-object

Added the Concept2 as test-object

* Update Rower.test.js

* Adaptation to C2 Flywheel Inertia change

Adaptation to C2 Flywheel Inertia change

* Created to explain the current architecture

Created an architecture document to explain the current architecture, as well as the major components in Open Rowing Monitor to maintainers and reviewers of the code.

* Create hardware_setup_Concept2_RowErg.md

* Added Concept 2 manual

Added concept 2 RowErg manual, as some minor updates

* Added performance improvement guide

Added a guide for improving the performance (Latency) of the Raspberry Pi.

* Fixed typos, filled in some blanks

Fixed some typos, improved some text for clarity and added some text to complete this description.

* Update to reflect new capabilities

Update to reflect new capabilities of OpenRowingMonitor and make the text easier to parse for novice users (make it less technical).

* Updated with new settings

Updated with the new settings available

* Update default.config.js

* Update to allow for the 64Bit PREEMPT kernel

Update of the install script to allow for the 64Bit PREEMPT kernel of Raspberry Pi, which handles low latency much better.

* Fixed a typo in a file reference

Thanks to @Abasz , dound a typo which i now fixed.

* Fixed typo

Fixed typo

Co-authored-by: Lars Berning <151194+laberning@users.noreply.github.com>

* Fixed a typo

Fixed a typo

Co-authored-by: Lars Berning <151194+laberning@users.noreply.github.com>

* Fixed a cut-copy-paste error

Fixed a cut-copy-paste error in the infinity symbol

* Fixed error in repo-name

Fixed an error in the repo-name when moving for the experimental branch to the PR branch

* Fixed a copy error in the Repo-name

Missed updating the repo-name when moving the code from private experimental branch to a production PR repo

* Updated ToDo descriptions

Updated ToDo descriptions

* Added more detailed ToDo's

Added more detailed ToDo's

* Better explanation of design issue

A much better (and English) and updated explanation of the open design issues in Flywheel.js

* Fixed a bug in the strokecount reinitialization

Fixed a bug in the stroke count reinitialization (great find by @Abasz), which was inconsistent with the normal init.

* Graphic showing systematic error

File showing systematic (periodic) deviations in the magnet placement

* Added an image of misaligned magnets

* Removed non-working code

Removed the trimmedMedian function, as its design contains fundamental mathematical errors. The initially proposed way is the only good way of doing it.

* Added observation about noise overfitting

Added a note about Noise overfitting, based on the Concept2 and the observation of Gordon_Shumway (see https://github.com/laberning/openrowingmonitor/discussions/87)

* Added the pigpio library

Added the pigpio library

* Added an explanation into the GPIO settings

Added an explanation of the GPIO settings

* Added the settings for the new GPIO library

Added the settings to configure the new GPIO library

* Replaced onoff with pigpio, added debounce param.

Replaced the onoff library (goodbye my old loyal friend) with pigpio, to facilitate much more accurate timing calculations and add more flexibility to the flank detection (including debounce)

* Replaced onoff with pigpio

Replaced onoff with pigpio library

* Replaced onoff with pigpio

Replaced onoff with pigpio

* Install and config pigpio dependency

Added the installation of the pigpio C-library and setting the key parameters.

* Added a bit clarification about the setup guide

Added a bit better description about the setup guides.

* Removed and added spaces....

* Remove an unnecessary space....

* Resolved open design issue in noise filter

In the previous design, we were uncertain that the noise filter would handle all cases. With pigpio, we are quite certain it will handle all cases internally, and here we detect any deviations. Please note, startup-behaviour after a cold or warm (re)start still has to be handled as time since the privious pulse tends to be in the minutes, throwing off all timekeeping functions.

* Removed obsolete variables

Removed two obsolete variables: lastKnownGoodDatapoint and numberOfErrorsAllowed

* Removed obsolete variable

Removed the now defunct variable numberOfErrorsAllowed

* Changes in startup and config

Due to changes in the gpio library, the startup behaviour of flywheel.js has changes, as have the Concept2 configuration settings. These changes modify the results of the testcase accordingly.

* Updated testcases after update pigpio

Due to changes in the gpio library, the startup behaviour of flywheel.js has changed, as have the Concept2 configuration settings. These changes modify the results of the testcase accordingly.

* Update testcase to accomodate lib change

Update testcase to accomodate lib change

* Update due to lib modification

Update due to lib modification

* Update Rower.test.js

* Update Rower.test.js

* Update Rower.test.js

* Update Rower.test.js

* Update due to gpio library change

* Update due to removal obsolete parameter

Update due to the removal of numberOfErrorsAllowed

* Removed obsolute parameter

Removed the numberOfErrorsAllowed parameter

* Performance improvement

A small performance improvement: by moving the evaluation of the flywheel.isPowered(), flywheel.isUnpowered() and flywheel.isDwelling() backwards, we move these potentially expensive operations further in the evaluation. As Javascript is using lazy evaluation, it won't be called unless all other conditions are true. Especially flywheel.isDwelling() checks if the entire flank is above maximumTimeBetweenImpulses, which is expensive (flywheel.isPowered() and flywheel.isUnpowered() are actually quite simple, but are moved along to maintain symmetry).

* Fixed a missing bracket

Fixed a missing bracket

* Allignment with main branch (64Bit support)

Alignment with the improvement of the install script of the main branch to support the 64 bit version of the Lite kernel.

* removes some obsolete variables

* adds a missing async statement

Signed-off-by: Lars Berning <151194+laberning@users.noreply.github.com>

* pin dependency

Signed-off-by: Lars Berning <151194+laberning@users.noreply.github.com>

* default setting should not fiddle with nice levels of os, otherwise we require root permissions by default

Signed-off-by: Lars Berning <151194+laberning@users.noreply.github.com>

* prettyfies a log message

Signed-off-by: Lars Berning <151194+laberning@users.noreply.github.com>

* unifies VO2max namings

Signed-off-by: Lars Berning <151194+laberning@users.noreply.github.com>

* Introduced appPriority as setting

Added the appPriority setting, to allow a clear entry to set the priority for the main process.

* Removed some obscure priority behaviour

Removed the obscure approach of using the gpio-priority to set the main app priority.

* Added a distinction between stop and pause

Based on a bugreport by @Carlito1979 about the pause behaviour, added a distinction between the stopMoving() and pauseMoving() command, as a pause would lead to an undesired stop state.

* Added a distinction between stop and pause

Based on a bugreport by @Carlito1979 about the pause behaviour, added a distinction between the stopMoving() and pauseMoving() command, as a pause would lead to an undesired stop state.

* Improved description of the various states

Based on bugs reported, and some internal soul searching, improved the description of states.

* Removed a trailing space

* Added profiles, put them in alphabetic order

Added the Force USA R3 Air Rower, and put the rowers in alphabetic order

* Removal of surplus comma

* Improvement of pause-behaviour

Improvement of the pause behaviour based on feedback from @Carlito1979

* Improved RestingHR behaviour, clarifications

Improvement of the resting HR functionality, it will now also trigger when rowing is paused
Clarification of "Stopped" sessionState behavior: this is a less than obvious but deliberate approach.

* Change to const postExerciseHR

Due to Lint error, changed postExerciseHR from "let" to "const"

* Create and advertising data builder

Since Bleno library does not provide a way to set/tweak appearance data
implement a builder that enables to add name and appearance information
to the advertisement data.

* Expose time of last completed stroke

For the CPS and CSC BLE Services the time stamp of the last stoke event
is necessary. This is available in the Rower as `drivePhaseStartTime` so
expose it

* Add 32bit capability to BufferBuilder

Since the wheel revolution count in the CSC and CPS measurement service
is a 32bin UINT extend the BufferBuilder to be able to handle it.

* Add static data and functions used in CSCS and CPS

Implement device information service (necessary for garmin to recognise
the device as sensor) a wrapper around static read characteristics to
ease creation.

* Add cycling speed and cadence profile

Add necessary services and related characteristics.
Implement CscPeripheral interface to be able to properly communicate to
the PeripheralManager.

* Add cycling power profile

Add necessary services and related characteristics.
Implement CpsPeripheral interface to be able to properly communicate to
the PeripheralManager.

* Wire up PeripheralManager with the new profiles

Add the new CSCP and CPP profiles to the PeripheralManager.
Update comments in settings and front end web view with the new profiles

* Add new Rower Profile Zoco Body Fit

Add a rowing profile for a Concept2 clone air rower

* Update FTMS profile with new services

Add device information service to the FTMS peripheral and move to the
new advertising data builder.

* Improvement of startup behaviour

Modification of the startup behaviour: now unrealistic values (i.e. above maximumTimeBetweenImpulses) are ignored. The rower will only start when all values in the flank are above the minmumSpeed (i.e. all currentDt's are below maximumTimeBetweenImpulses).

* Improvement of startup behaviour

Modification of the startup behaviour: now unrealistic values (i.e. above maximumTimeBetweenImpulses) are ignored. The rower will only start when all values in the flank are above the minmumSpeed (i.e. all currentDt's are below maximumTimeBetweenImpulses).

* Improvement of startup behaviour

Modification of the startup behaviour: now unrealistic values (i.e. above maximumTimeBetweenImpulses) are ignored. The rower will only start when all values in the flank are above the minmumSpeed (i.e. all currentDt's are below maximumTimeBetweenImpulses).

* Improvement of startup behaviour

Modification of the startup behaviour: now unrealistic values (i.e. above maximumTimeBetweenImpulses) are ignored. The rower will only start when all values in the flank are above the minmumSpeed (i.e. all currentDt's are below maximumTimeBetweenImpulses).

* Finalize Generic Air Rower profile

* Change name of displayed name of new profiles

* Rename lastStrokeTime to driveLastStartTime

* Fixed some small bugs

Fixed
* the missing pause command
* a small typo in the totalmovingtime

* Fixed a small bug

Fixed a small bug

* Improvement of browser performence

Improved some startup settings to increase browser performance (disables some security settings as they are not needed at a local system). Please note these settings are NOT RECOMENDED for general purpose browsers, but as we run on a localhost machine only, showing our GUI, this is quite acceptable.

* Update due to increased BLE profiles

Thanks to @Abasz, we can now use BLE Cycling Power Profile and the Cycling Speed and Cadence Profile.

* Added Abasz to the list of great contributors

* More expanded explanation of BLE profiles

* Update of the testfile to align with new GPIO conf

Update of the testfile to reflect the new GPIO-module

* Introduction of supporting Linear TS

Introduction of the Linear Theil-Senn algorithm to improve the Quadratic Theil-Senn algorithm

* Improvement of the Quad. Theil-Senn Algorithm

Improvement of the accuracy and robustness of the Quadratic Theil-Senn algorithm, as well as improving (reducing) the CPU load. It employs the Linear Theil-Senn Algorithm to calculate the optimal B and C for the selected A (instead of a marginally related B and C in the older algoithm).

* Update of the stroke detection algorithm

Update of the stroke detection algorithm: as the Qudratic Theil-Senn algorithm is more robust, we can rely on the sole combination of dragslope being gone and seeing torque.

* Updated to reflect more accurate algorithm

Updated the testscript to reflect the much more accurate and robust algorithm.

* Updated to reflect more improved algorithms

Updated test scripts to reflect the improvements in the Quadratic Theil-Senn algorithm and the Flywheel stroke detection algorithm.

* Updated to reflect more improved algorithms

Updated test scripts to reflect the improvements in the Quadratic Theil-Senn algorithm and the Flywheel stroke detection algorithm.

* Removed dead code

Removal of dead code

* Improvement of Code quality

* Improvement of code quality

Improvement of code quality

* Added space to survive Lint

Added space to survive Lint

* Addition of the isAboveMinimumSpeed function

Addition of the isAboveMinimumSpeed function

* Removed unused variable

* Add modification for new startup behaviour

Add modification for new startup behaviour

* Update to fix regression issues

Update to fix regression issues

* Update Rower.test.js

* Update of the C2 testcase

Update of the C2 testcase due to GPIO update

* Update of the C2 testcase due to GPIO changes

Update of the C2 testcase due to changing the testdata due to GPIO changes

* fixes some review findings

Signed-off-by: Lars Berning <151194+laberning@users.noreply.github.com>
Co-authored-by: Lars Berning <151194+laberning@users.noreply.github.com>
Co-authored-by: Abász <>
Co-authored-by: Abasz <32517724+Abasz@users.noreply.github.com>
2022-12-15 21:33:42 +01:00
Lars Berning 8dc8146abf
fixes #69 error in angularDisplacement calculation 2022-03-08 20:09:42 +01:00
Lars Berning 943518b986
implements confirmation dialogs, improvements to strava upload 2022-02-11 22:37:36 +00:00
Lars Berning dfc17c09b2
wires strava authorization to the web ui 2022-02-05 21:54:15 +01:00
Lars Berning 15cdf2e22f
adds initial strava integration to upload activities 2022-02-05 13:15:43 +01:00
Lars Berning a4a7a1b0a0
adds features to store recordings with gzip compression, fixes a bug with the recording config 2022-02-01 20:20:32 +01:00
Lars Berning 2ccd54a65d
adds a constant metric stream for BLE devices to fix some connectivity issues 2022-02-01 19:25:51 +01:00
Lars Berning 2210c46162
improves metrics of first stroke by setting reasonable initial values 2022-01-31 19:55:27 +01:00
Lars Berning fc00c01e61
fixes a problem that prevented session recording from working 2022-01-30 13:52:17 +01:00
Lars Berning 8d634b0a65
updates eslint to v8, adds some more linting rules 2022-01-29 14:15:33 +01:00
Lars Berning 9471ff758b
fixes some code duplications in the engine initialization routine 2022-01-28 20:23:50 +01:00
Jaap van Ekris 335083c37d
Improvement of the startup behaviour and external stroke definition (#46)
* Improvement of the startup behaviour

These changes improve the startup behaviour: ORM will now always start with a detected drive-phase, which will trigger recording etc. This changes several initialisations of variables to make sure they enable the triggering of a "Drive" at the beginning of a stroke. Also workoutHandler.handleStrokeEnd has been renamed to workoutHandler.handleDriveEnd, as this is the clear end of that stroke-phase.

* Renamed handleStrokeEnd to handleDriveEnd

Renamed handleStrokeEnd to handleDriveEnd, as this is the clear end of that stroke-phase, as the current model alternates between Drive+Recovery and Recovery+Drive strokes to keep feeding the metrics, there isn't a very clear "End of the Stroke".

* Redefinition of a stroke

Traditionally, a stroke is defined as a Drive phase, followed by a Recovery Phase. This is also expected by Garmin and EXR as Concept2 implements it this way as well. This implementation makes it more consistent with that interpretation, while leaving room for intermediate updates. This should make Bluetooth behaviour and metrics recording more consistent.
2022-01-28 19:56:55 +01:00
Jaap van Ekris 47e71ea5ef
Drag poising bugfix (#44)
* Bugfix for dragfilter poisoning prevention

Implementation of a more refined version of the dragfactor calculation to prevent the dragfactor being stuck at certain values after pauses, etc.

* Addition of new settings

Implementation of a more refined version of the dragfactor calculation to prevent the dragfactor being stuck at certain values after pauses, etc.

Two changes:
* Made the smoothing function of the dragfactor configurable from the config-file (dampingConstantSmoothing) instead of hardcoded. as it should have been from day one
* Implementation of a new filter to prevent dragfactor poisoning by noisy data, based on another setting (dampingConstantMaxChange). The new filter will not get stuck but will follow the direction of the change but is limited to the setting..
2022-01-10 21:41:21 +01:00
Jaap van Ekris e85491acb9
More refined session state (#33)
* A more refined rowing session state (PM5)

Introduces a more refined session state needed for the PM5 rower session simulation, as well as a cleaner setup for the metrics to stop when the rower is stopped.

* Added the WorkoutState and rowingState

Added the WorkoutState and rowingState to the PM5 interface, to prevent EXR to start too early.

* Added a link to the brilliant work of Nomath

Added a link to Nomath's work, as it is a brilliant piece of work that independently verifies our calculations and provides a basis for support of the Concept2 rower.

* Bugfix in Instantanous Torque calculation

The Instantanous Torque calculation wasn't cleaned up sufficiently, causing issues in the powercurve.

* unifies reset of heartrate value at different places

* unifies naming with other variables status -> state

* just some minor link adjustments in documentation

Co-authored-by: Lars Berning <151194+laberning@users.noreply.github.com>
2022-01-09 12:09:02 +01:00
Jaap van Ekris 19ec4f28bb
Code Cleanup and Documentation Update (#30)
* Moved .doc to .md

Moved the Word document to a more open format

* Update of the file based on the new settings

Update of the settings documentation due to the introduction of the new RowingEngine

* Moved .doc to .md

Moved the information to the .md file, updated with the design decissions made in the new RowingEngine.

* Splitting the hardware set-ups for specific rowers

Split off the WRX700 hardware set-up from the generic setup, to allow for other rower-specific set-ups to be created (easier to read and better for search engines).

* Removal of generic text

* SPlit the generic from the WRX700

* Fixed a very rare bug

A very rare condition can cause the noise correction filter to get stuck and dismiss all subsequent values. Now the number of corrections is maximised preventing that situation.

* Code refactoring

Refactoring of the code (added calculateLinearVelocity(), calculateCyclePower(), calculateTorque() functions) to reduce code duplication across phases.

* Fixed a very rare bug

A very rare condition can cause the noise correction filter to get stuck and dismiss all subsequent values. Now the number of corrections is maximised preventing that situation.

* Code refactoring

Refactoring of the code (added calculateLinearVelocity(), calculateCyclePower(), calculateTorque() functions) to reduce code duplication across phases.

* fixes some typos, fixes some links, renames some files

Co-authored-by: Lars Berning <151194+laberning@users.noreply.github.com>
2021-12-13 20:01:28 +01:00
Lars Berning 68f4313518
Adds support for GitHub pages (#27)
* moves readme to docs folder

* Set theme jekyll-theme-cayman

* adjusts some colors

* adjusts image margin

* adds some styling and a navigation menu
2021-11-11 21:11:07 +01:00
Lars Berning 67e7dbb36c
unifies interface of averagers 2021-11-08 09:00:45 +01:00
Lars Berning 36fe899e81
adds more tests to averagers 2021-11-08 08:47:56 +01:00
Lars Berning 02359e819d
updates documentation, fixes typos 2021-11-07 21:51:11 +01:00
Lars Berning 8f064a0aab
fixes typos, updates documentation to new names 2021-11-07 15:14:51 +01:00
Jaap van Ekris 7ee25292fc
Improved Rowing Engine (#24)
* Update to accomodate the new RowingEngine

Update of the MovingFlankDetector to provide the values needed to determine the speeds at the beginning of the flank.

* Created the MovingAverager for RowingEngine 2.0

Added the MovingAverager to accomodate the RowingEngine 2.0

* Update to RowingEngine 2.0

Update based on the great theoretical work of Anu Dudhia and the practical experiences of Dave Venrooy.

* Added to explain RowingEngine 2.0 design

A rationale for explaining the RowingEngine 2.0 design, based on the great theoretical work of Anu Dudhia, and the practical work of Dave Venrooy and Marinus van Holst, as well as the great feedback from Lars Berning.

* Update to accomodate the new RowingEngine

Update to the rower settings to accommodate the new RowingEngine. Please note that the modifications need to be verified by the respective users.

* Modifications to the RX800 tests

Modifications to the RX800 to bring it in line with the Concept2 Power and distance measurements.

* BUGFIX: Prevent ghost-strokes at end of session

This change to isAccelerating prevents stroke-detection to detect a stroke when the currentDt "flatlines". This typically happens when the error correction kicks in when you quit rowing (and thus the rowerSettings.maximumTimeBetweenImpulses is exceeded). It is bad (flatlining isn't acceleration), and this ghost-stroke causes havoc in the GUI: all measurements are reset again to random values instead of the nice indicators normally used.

* BUGFIX: Prevent ghost-strokes at end of session

This change to isAccelerating prevents stroke-detection to detect a stroke when the currentDt "flatlines". This typically happens when the error correction kicks in when you quit rowing (and thus the rowerSettings.maximumTimeBetweenImpulses is exceeded). It is bad (flatlining isn't acceleration), and this ghost-stroke causes havoc in the GUI: all measurements are reset again to random values instead of the nice indicators normally used.

* Added defensive programming

In some rare cases not rounding led to a buffer overflow, so added defensive programming to prevent this.

* Update MovingFlankDetector.js

* Improved stroke detection algorithm accuracy

Improvement of the Stroke detection algorithm: when naturalDeceleration is specified in the settings, it will only consider something a Revocery when this level of deceleration is encountered for the FlankLength.

* Made the RowingEngine more stateful

Removed some bugs, added a lot of defensive programming and made the RowingEngine report the key statistics every impuls to create a more fluid experience on the monitor. To do this, the rowingEngine maintins and reports absolute values to rowingStatistics, instead of relative.

* Improved stroke detection algorithm accuracy

Improvement of the Stroke detection algorithm: when naturalDeceleration is specified in the settings, it will only consider something a Revocery when this level of deceleration is encountered for the FlankLength.

* Modification to fit new RowingEngine

* Addition of new parameters for stroke detection

Added new parameters for stroke detection and monitor fluidity

* Fixed missing bracket

* Updated to more fluid RowingStatistics

Moved the timer from a static timer to the raw measurements of the flywheel, and the distance more frequently updated, to keep all data consistent. Also made the GUI-updates more fluid, responsive and dependent on settings: this more fluid GUI update mechanism is dependent on the screenUpdateInterval setting and moving averager dependent on a setting (numOfPhasesForAveragingScreenData)

* Made all monitor updates consistent

* Accommodate more frequent update of the monitors

Update to accommodate the more frequent updates, and to accommodate the reset for the RowingEngine

* improves some testcases, fixes some minor code styling and duplicate definitions

* Fixed a comment about dragfactor

* Added parameters for the new RowingStatistics.js

Added screenUpdateInterval, numOfPhasesForAveragingScreenData and maxCycleTimeBeforePause as config parameters to remove statically determined parameters in RowingStatistics.js

* Added RX800 as second testbed

* fixes some problems that caused the engine to crash

* uses non sanitized durations for now

* updates some settings, fixes some typos

* wires the correct timer configuration, fixes a problem where SPM would not reset to 0

* fixes a crash problem in workout recorder, fixes fallback value for strokeTime

* relaxes constraint on stroke time

* updates some explanatory text, updates some rower parameters

Co-authored-by: Lars Berning <151194+laberning@users.noreply.github.com>
2021-11-07 14:53:11 +01:00
Lars Berning 3b6b42ec1a
extracts merge function into a helper module 2021-05-27 09:36:03 +02:00
Lars Berning 53ddec27da
fixes an issue with data types in tcx files 2021-05-21 10:06:39 +02:00
Lars Berning 602766c4a0
implements tcx and raw export 2021-05-20 13:40:42 +02:00
Lars Berning c87e78b000
fixes auto adjustment for rowed distance 2021-05-13 10:11:00 +02:00
Lars Berning d50b1b8c7c
speeds up updating by reusing existing dependencies 2021-05-05 12:32:57 +02:00
Lars Berning b019fb3bd4
adds more settings, adds auto adjust for damping 2021-05-05 12:16:04 +02:00
Jaap van Ekris 1b895972af
refactores FlankDetector, extracts some flank settings
* Improvement of the MovingflankDetector

Simplified the call of the moving flank detector, making it dependent on the settings

* Update MovingFlankDetector.js

Cleaned up the call to the MovingFlankDetector

* Added heartrate data to TCX

* Added parameters for the flankdetector

Added parameters for the flankdetector (flankLength and numberOfErrorsAllowed)

* Gave the RX800 some room as the settings haven't stabilised yet (and I think the recording is with a different damper setting than the source tree)
2021-05-05 05:41:11 +02:00
Lars Berning 475f0f4835
improves regression tests, renames some settings 2021-05-02 15:02:58 +02:00
JaapvanEkris 2c6819ca02
implements better flank detection, adds spreadsheet for analysis
Added the flankdetector, to reliably detect an acceleration or deceleration of the flywheel
Added extra metrics for the creation of TCX-files
Added extra metrics (speed in m/s and cadence) to allow future export of this data to Garmin TCX files, which everybody seems to love.
I increased the priority of the GPIO-service, as I noticed that much of the measurement noise originates from delayed read-outs of the GPIO.
An Excel tool to "play" with the settings of a rower, to adjust the settings found in the rowerprofiles.js
Adds test and data for RX800 rower
Lightweight version of Excel file

Co-authored-by: Lars Berning <151194+laberning@users.noreply.github.com>
2021-04-30 22:03:47 +02:00
JaapvanEkris 5c9630d0e5
This constant c isn't as constant....
The constant C isn't as constant as you'd hope it would be. As http://eodg.atm.ox.ac.uk/user/dudhia/rowing/physics/ergometer.html states: "The figure used for c is somewhat arbitrary - selected to indicate a 'realistic' boat speed for a given output power."
2021-04-29 14:29:54 +02:00
Lars Berning 5dddeb2ff5 adds unit tests to verify the rowing engine with real rower recordings 2021-04-21 19:56:42 +02:00
Lars Berning 55cde69ce6 moves rower configuration into a config file and adds rower presets 2021-04-20 21:48:34 +02:00
Lars Berning 43fa45bf29 adds support for BLE heart rate monitors 2021-04-14 22:13:24 +02:00
Lars Berning 1c135a0c1f replaces unit testing framework ava -> uvu 2021-03-26 23:37:36 +00:00
Lars Berning f358d06247 adds simulated heart rate 2021-03-26 22:35:17 +00:00
Lars Berning f1c0091a7a set split to infinity while pausing 2021-03-26 21:06:02 +00:00
Lars Berning e5e579f3fc notifies PM5 central when stroke state changes 2021-03-20 22:04:52 +00:00
Lars Berning d90fa9ea1f adds config file and additional metrics 2021-03-19 19:56:02 +00:00
Lars Berning 37c32829d8 implements PM5 protocol, simplifies code 2021-03-18 20:17:57 +00:00
Lars Berning 3d08f06336 implements handling of rowing pauses 2021-03-10 19:08:56 +00:00
Lars Berning 361e1c65f8 adds logging framework, cleans documentation 2021-03-09 19:39:42 +00:00
Lars Berning 6a4779dfa3 first commit 2021-03-06 21:15:37 +01:00