Skip to content

Commit

Permalink
Non stop mode for strength endurance exercises
Browse files Browse the repository at this point in the history
For endurance exercises, detection of the end of the exercise breaks the
measures, stopping the analysis.

Created a new command to tell the backend that it should not detected
the end of the exercise.
This allows to run endurance exercises where the strength is released
completly during short intervals.

Removed some old references to body weight in the backend

Fix open browser
  • Loading branch information
adrianlzt committed Jun 2, 2020
1 parent 101c5c3 commit 5b64532
Show file tree
Hide file tree
Showing 13 changed files with 170 additions and 132 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# 0.2.0
* Add "non stop" mode for strength, to measure time, average force and FTI in endurance exercises
* Fix auto open browser
35 changes: 0 additions & 35 deletions app/frontend/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,6 @@ exports.onCreateWebpackConfig = ({ stage, loaders, plugins, actions }) => {
test: /react-ace/,
use: loaders.null(),
},
/* TODO if this two are commented, the graphs do not work in build
{
test: /immutable-devtools/,
use: loaders.null(),
},
{
test: /pondjs/,
use: loaders.null(),
},
{
test: /react-timeseries-charts/,
use: loaders.null(),
},
*/
],
},
plugins: [
Expand All @@ -39,24 +25,3 @@ exports.onCreateWebpackConfig = ({ stage, loaders, plugins, actions }) => {
});
}
};

// TODO gatbsy build does not know this api
/*
exports.modifyBabelrc = ({ babelrc }) => ({
...babelrc,
plugins: babelrc.plugins.concat(['transform-regenerator']),
});
*/

/*
exports.modifyWebpackConfig = function(config, env) {
if (env === 'build-javascript' || env === 'develop') {
const previous = config.resolve().entry;
config._config.entry = [];
config.merge({
entry: ['babel-polyfill'].concat(previous),
});
}
return config;
};
*/
36 changes: 33 additions & 3 deletions app/frontend/src/components/strength/coach_command.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { EuiText, EuiButton, EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import { useMutation, useSubscription } from '@apollo/react-hooks';
import gql from 'graphql-tag';
import { setTimeout } from 'timers';
import { EuiCheckbox } from '@elastic/eui';

const CoachCmd = ({ climberStatus, setClimberStatus }) => {
// TODO parametrize calibrate command. One command for both mutations
Expand Down Expand Up @@ -47,6 +48,14 @@ const CoachCmd = ({ climberStatus, setClimberStatus }) => {
}
`;

const RESTART_NON_STOP_CMD = gql`
mutation {
strengthCommand(params: { command: RESTART_NON_STOP }) {
message
}
}
`;

const SIMULATE_CMD = gql`
mutation {
strengthCommand(params: { command: SIMULATE }) {
Expand All @@ -65,13 +74,15 @@ const CoachCmd = ({ climberStatus, setClimberStatus }) => {
`;

const [restartButton, {}] = useMutation(RESTART_CMD);
const [restartNonStopButton, {}] = useMutation(RESTART_NON_STOP_CMD);
const [pauseButton, {}] = useMutation(PAUSE_CMD);
const [tareButton, {}] = useMutation(TARE_CMD);
const [simulateButton, {}] = useMutation(SIMULATE_CMD);
const [calibratePlusButton, {}] = useMutation(CALIBRATE_PLUS_CMD);
const [calibrateLessButton, {}] = useMutation(CALIBRATE_LESS_CMD);
const [lastStop, setLastStop] = useState(0);
const [startButton, setStartButton] = useState('Start');
const [nonStopSlider, setNonStopSlider] = useState(false);

// Give 5" to get ready
// Start capturing data one sec before, to avoid loosing first measures
Expand All @@ -88,8 +99,13 @@ const CoachCmd = ({ climberStatus, setClimberStatus }) => {
}, 3000);
setTimeout(() => {
setStartButton('Start ... 1');
restartButton();
console.log('coach cmd activar climber');
if (nonStopSlider) {
restartNonStopButton(); // Start without automatic end detection
console.log('coach cmd start non stop mode');
} else {
restartButton(); // Start with automatic end detection
console.log('coach cmd start with automatic end');
}
setClimberStatus(true);
}, 4000);
setTimeout(() => {
Expand Down Expand Up @@ -123,6 +139,7 @@ const CoachCmd = ({ climberStatus, setClimberStatus }) => {

// https://reactjs.org/blog/2020/02/26/react-v16.13.0.html#warnings-for-some-updates-during-render
useEffect(() => {
// Auto pause if we receive and "end" event from the backend
// Each new render get the data from the last subscription message
// Only execute pause() once
if (
Expand All @@ -131,7 +148,11 @@ const CoachCmd = ({ climberStatus, setClimberStatus }) => {
data.strengthBackendCommands.command === 'end' &&
data.strengthBackendCommands.value !== lastStop
) {
pause();
// In non stop mode, the climber will stop manually when the exercise has finished
// Avoid auto detecting and end while doing a short release of the grip in endurance exercises
if (!nonStopSlider) {
pause();
}
setLastStop(data.strengthBackendCommands.value);
}
});
Expand Down Expand Up @@ -178,6 +199,15 @@ const CoachCmd = ({ climberStatus, setClimberStatus }) => {
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
<EuiFlexGroup>
<EuiFlexItem>
<EuiCheckbox
id="nonStop"
checked={nonStopSlider}
onChange={e => setNonStopSlider(e.target.checked)}
label="Non stop mode" />
</EuiFlexItem>
</EuiFlexGroup>
</>
);
};
Expand Down
2 changes: 2 additions & 0 deletions app/frontend/src/components/strength/graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ const Graph = ({ events, unit }) => {
timerange = new TimeRange(0, 1);
}

// TODO add a line with the average value

// TODO add marker to show the value where the mouse is
// https://github.com/esnet/react-timeseries-charts/blob/master/src/website/packages/charts/examples/wind/Index.js#L90
return (
Expand Down
2 changes: 1 addition & 1 deletion app/frontend/src/pages/configuration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ const StrengthExpectedPct = ({ strength_expected_pct, changeStrengthExpectedPct
<EuiFormRow
label="Expected force margin"
style={{ marginTop: '16px' }}
helpText="Margin to consider the strength value to be the expected">
helpText="Margin to consider the strength value in the expected range">
<EuiFieldNumber
value={strength_expected_pct}
onChange={changeStrengthExpectedPct}
Expand Down
1 change: 1 addition & 0 deletions app/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/adrianlzt/gqlgen v0.11.3-1 h1:8qoxpsePizzNvm+Pnbbqkc73j6SOdubfrK4/bvqOwYM=
github.com/adrianlzt/gqlgen v0.11.3-1/go.mod h1:RgX5GRRdDWNkh4pBrdzNpNPFVsdoUFY2+adM6nb1N+4=
github.com/adrianlzt/piclimbing v0.0.0-20200520071258-101c5c3a3b6a h1:8pb5wrfGybqZPm6TxoSnyGJzXS68b6Or/6sO1AqxUsQ=
github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM=
github.com/agnivade/levenshtein v1.0.3 h1:M5ZnqLOoZR8ygVq0FfkXsNOKzMCk0xRiow0R5+5VkQ0=
github.com/agnivade/levenshtein v1.0.3/go.mod h1:4SFRZbbXWLF4MU1T9Qg0pGgH3Pjs+t6ie5efyrwRJXs=
Expand Down
Loading

0 comments on commit 5b64532

Please sign in to comment.