From cca91461f3108497dea36f71d326499eb8f645e1 Mon Sep 17 00:00:00 2001 From: Luca Warmenhoven Date: Wed, 5 Jun 2024 14:50:05 +0200 Subject: [PATCH] Fixed issues --- .../fitbot/ui/activities/FitnessActivity.java | 5 +---- .../util/processing/InputProcessor.java | 19 +++++++------------ 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/activities/FitnessActivity.java b/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/activities/FitnessActivity.java index a890a4c..93fa8db 100644 --- a/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/activities/FitnessActivity.java +++ b/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/activities/FitnessActivity.java @@ -136,10 +136,6 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall // Acquire paths from the exercise and provide them to the motion processor motionProcessor = new InputProcessor(this); motionProcessor.useExercise(exercise); - /* TODO: Remove if not needed */ - motionProcessor.setRecording(true, 10); - motionProcessor.startListening(); - }, (n) -> { int randomMessageIndex = (int) Math.floor(Math.random() * EXERCISE_NOT_FOUND_MESSAGES.length); @@ -197,6 +193,7 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall } // Start checking for user movement once the video has loaded + this.motionProcessor.startListening(); this.motionProcessor.startCheckingUserMovement(); return true; diff --git a/code/src/Fitbot/app/src/main/java/com/example/fitbot/util/processing/InputProcessor.java b/code/src/Fitbot/app/src/main/java/com/example/fitbot/util/processing/InputProcessor.java index 7b0bb13..180c1c4 100644 --- a/code/src/Fitbot/app/src/main/java/com/example/fitbot/util/processing/InputProcessor.java +++ b/code/src/Fitbot/app/src/main/java/com/example/fitbot/util/processing/InputProcessor.java @@ -101,21 +101,19 @@ public class InputProcessor { * This function will start a thread that will check for user movement * and compare the last rotation vectors to the target rotation vectors. */ - public void startCheckingUserMovement() - { + public void startCheckingUserMovement() { // Error checking thread. (new Thread(() -> { - while (this.exercisesRemaining > 0) - { + while (this.exercisesRemaining > 0) { boolean isFaulty = this.isFaultyMovement(); - if ( isFaulty ) { + if (isFaulty) { this.onInadequateRepetition(); } else this.onAdequateRepetition(); this.checksPerformed++; - if ( this.checksPerformed >= this.totalChecks ) + if (this.checksPerformed >= this.totalChecks) acquireExercise(); try { @@ -230,8 +228,7 @@ public class InputProcessor { * Function for acquiring the next exercise from the database. * Upon successful retrieval, it will call the nextExercise method. */ - private void acquireExercise() - { + private void acquireExercise() { this.exercisesRemaining--; this.parentActivity.fetchExerciseAsync(this::nextExercise, (nil) -> { @@ -397,8 +394,7 @@ public class InputProcessor { int i, referenceIndex; float distance; - for ( i = 0; i < selfRotationVectorPaths.length; i++) - { + for (i = 0; i < selfRotationVectorPaths.length; i++) { referenceIndex = (int) (Math.round( ((this.secondsPassed % this.exerciseRepetitionDurationInSeconds) / (this.exerciseRepetitionDurationInSeconds)) * this.targetRotationVectorPaths[i].length)) @@ -407,8 +403,7 @@ public class InputProcessor { distance = this.selfRotationVectorPaths[i].get(this.selfRotationVectorPaths[i].size() - 1).distance( this.targetRotationVectorPaths[i][referenceIndex]); - if (distance > ExerciseManager.EXERCISE_ERROR_MARGIN) - { + if (distance > ExerciseManager.EXERCISE_ERROR_MARGIN) { Log.i("MotionProcessor", "Faulty movement detected: " + distance + " > " + ExerciseManager.EXERCISE_ERROR_MARGIN); return true; }