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 1350a78..a890a4c 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 @@ -134,7 +134,7 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall // the canvas properly. this.fetchExerciseAsync((exercise) -> { // Acquire paths from the exercise and provide them to the motion processor - motionProcessor = new InputProcessor(SENSOR_SAMPLE_RATE, this); + motionProcessor = new InputProcessor(this); motionProcessor.useExercise(exercise); /* TODO: Remove if not needed */ motionProcessor.setRecording(true, 10); @@ -162,8 +162,8 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall if (exercise == null) { runOnUiThread(() -> onFailedFetch.handle(null)); } else { + onSuccessfulFetch.handle(exercise); runOnUiThread(() -> { - onSuccessfulFetch.handle(exercise); exerciseNameTextView.setText(exercise.name); exerciseShortDescriptionTextView.setText(exercise.shortDescription); // exerciseDescriptionTextView.setText(exercise.description); @@ -196,6 +196,9 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall Log.e("FitnessActivity", "VideoView is null. Check your layout XML."); } + // Start checking for user movement once the video has loaded + this.motionProcessor.startCheckingUserMovement(); + return true; } return false; 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 8b0224f..5905d11 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 @@ -27,9 +27,7 @@ public class InputProcessor { //private Vector3f[][] selfRotationVectorPaths; // Relative path of the motion data private Vector3f[][] targetRotationVectorPaths; // Target path of the motion data - private final float sampleRate; // The sample rate of the motion sensor private float exerciseRepetitionDurationInSeconds = 0.0f; - private int repetitionsRemaining = 0; private int exercisesRemaining = 0; private float errorCheckInterval_s; @@ -75,11 +73,8 @@ public class InputProcessor { /** * Constructor for the motion processor. - * - * @param inputSampleRate The sample rate of the motion sensor. */ - public InputProcessor(float inputSampleRate, FitnessActivity parentActivity) { - this.sampleRate = inputSampleRate; + public InputProcessor(FitnessActivity parentActivity) { this.parentActivity = parentActivity; } @@ -100,7 +95,15 @@ public class InputProcessor { this.exercisesRemaining = 1; this.nextExercise(exercise); Pepper.say(STARTING_PHRASES[(int) Math.floor(Math.random() * STARTING_PHRASES.length)]); + } + /** + * Function that starts checking for user movement. + * 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() + { // Error checking thread. (new Thread(() -> { while (this.exercisesRemaining > 0)