From 8c462e9f48c96d3610e31da874ea7eb13c377e66 Mon Sep 17 00:00:00 2001 From: Luca Warmenhoven Date: Wed, 5 Jun 2024 13:31:21 +0200 Subject: [PATCH] Poekseps --- .../fitbot/ui/activities/FitnessActivity.java | 11 ++++------- .../fitbot/util/processing/InputProcessor.java | 14 +++++++++----- 2 files changed, 13 insertions(+), 12 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 e01867a..d9a8255 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 @@ -281,13 +281,10 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall private void triggerColorBurst(boolean isGoodRep) { - if (isGoodRep) { - progressCircle.setProgressDrawable(ContextCompat.getDrawable(this, R.drawable.progress_circle_good)); - new MediaPlayer().create(this, R.raw.good_sound).start(); - } else { - progressCircle.setProgressDrawable(ContextCompat.getDrawable(this, R.drawable.progress_circle_bad)); - new MediaPlayer().create(this, R.raw.wrong_sound).start(); - } + int circleId = isGoodRep ? R.drawable.progress_circle_good : R.drawable.progress_circle_bad; + int soundId = isGoodRep ? R.raw.good_sound : R.raw.wrong_sound; + progressCircle.setProgressDrawable(ContextCompat.getDrawable(this, circleId)); + MediaPlayer.create(this, soundId).start(); ObjectAnimator animator = ObjectAnimator.ofFloat(progressCircle, "alpha", 1f, 0f, 1f); animator.setDuration(500); // Burst duration 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 f5742de..5d1700d 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 @@ -28,7 +28,7 @@ public class InputProcessor { private Vector3f[][] targetRotationVectorPaths; // Target path of the motion data private final float sampleRate; // The sample rate of the motion sensor - private float exerciseDurationInSeconds; + private float exerciseRepetitionDurationInSeconds = 0.0f; private int repetitionsRemaining = 0; private int exercisesRemaining = 0; private float exerciseScore = 0.0F; @@ -120,7 +120,7 @@ public class InputProcessor { this.targetRotationVectorPaths = new Vector3f[2][exercise.rightPath.getAngleVectors().length]; this.targetRotationVectorPaths[0] = exercise.leftPath.getAngleVectors(); this.targetRotationVectorPaths[1] = exercise.rightPath.getAngleVectors(); - this.exerciseDurationInSeconds = exercise.exerciseTimeInSeconds; + this.exerciseRepetitionDurationInSeconds = exercise.exerciseTimeInSeconds; this.secondsPassed = 0.0D; this.lastTime = System.currentTimeMillis(); } @@ -170,7 +170,7 @@ public class InputProcessor { public boolean hasFinished() { return this.recordingMovement ? (this.secondsPassed >= this.recordingDurationInSeconds) : - (this.secondsPassed >= this.exerciseDurationInSeconds); + (this.secondsPassed >= this.exerciseRepetitionDurationInSeconds); } /** @@ -356,6 +356,10 @@ public class InputProcessor { // Ensure the sensor ID is within the bounds of the array if (sensorId < 0 || sensorId >= selfRotationVectorPaths.length) return 0.0d; + + // Calculate the index of the rotational vector where we're currently at + int targetRotationIdx = + /* // Index of the current rotation vector @@ -383,10 +387,10 @@ public class InputProcessor { */ public double getAverageError(int sensorId) { double error = 0; - for (int i = 0; i < this.exerciseDurationInSeconds; i++) { + for (int i = 0; i < this.exerciseRepetitionDurationInSeconds; i++) { error += getError(sensorId, i); } - return error / this.exerciseDurationInSeconds; + return error / this.exerciseRepetitionDurationInSeconds; } public float secondsPassed() {