Merge branch 'main' of ssh://gitlab.fdmci.hva.nl/propedeuse-hbo-ict/onderwijs/2023-2024/out-a-se-ti/blok-4/muupooviixee66

This commit is contained in:
SebasKoedam
2024-06-05 13:43:39 +02:00
2 changed files with 13 additions and 12 deletions

View File

@@ -279,13 +279,10 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
public void triggerColorBurst(boolean isGoodRep) { public void triggerColorBurst(boolean isGoodRep) {
if (isGoodRep) { int circleId = isGoodRep ? R.drawable.progress_circle_good : R.drawable.progress_circle_bad;
progressCircle.setProgressDrawable(ContextCompat.getDrawable(this, R.drawable.progress_circle_good)); int soundId = isGoodRep ? R.raw.good_sound : R.raw.wrong_sound;
new MediaPlayer().create(this, R.raw.good_sound).start(); progressCircle.setProgressDrawable(ContextCompat.getDrawable(this, circleId));
} else { MediaPlayer.create(this, soundId).start();
progressCircle.setProgressDrawable(ContextCompat.getDrawable(this, R.drawable.progress_circle_bad));
new MediaPlayer().create(this, R.raw.wrong_sound).start();
}
ObjectAnimator animator = ObjectAnimator.ofFloat(progressCircle, "alpha", 1f, 0f, 1f); ObjectAnimator animator = ObjectAnimator.ofFloat(progressCircle, "alpha", 1f, 0f, 1f);
animator.setDuration(500); // Burst duration animator.setDuration(500); // Burst duration

View File

@@ -28,7 +28,7 @@ public class InputProcessor {
private Vector3f[][] targetRotationVectorPaths; // Target 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 final float sampleRate; // The sample rate of the motion sensor
private float exerciseDurationInSeconds; private float exerciseRepetitionDurationInSeconds = 0.0f;
private int repetitionsRemaining = 0; private int repetitionsRemaining = 0;
private int exercisesRemaining = 0; private int exercisesRemaining = 0;
private float exerciseScore = 0.0F; private float exerciseScore = 0.0F;
@@ -120,7 +120,7 @@ public class InputProcessor {
this.targetRotationVectorPaths = new Vector3f[2][exercise.rightPath.getAngleVectors().length]; this.targetRotationVectorPaths = new Vector3f[2][exercise.rightPath.getAngleVectors().length];
this.targetRotationVectorPaths[0] = exercise.leftPath.getAngleVectors(); this.targetRotationVectorPaths[0] = exercise.leftPath.getAngleVectors();
this.targetRotationVectorPaths[1] = exercise.rightPath.getAngleVectors(); this.targetRotationVectorPaths[1] = exercise.rightPath.getAngleVectors();
this.exerciseDurationInSeconds = exercise.exerciseTimeInSeconds; this.exerciseRepetitionDurationInSeconds = exercise.exerciseTimeInSeconds;
this.secondsPassed = 0.0D; this.secondsPassed = 0.0D;
this.lastTime = System.currentTimeMillis(); this.lastTime = System.currentTimeMillis();
} }
@@ -169,7 +169,7 @@ public class InputProcessor {
public boolean hasFinished() { public boolean hasFinished() {
return this.recordingMovement ? return this.recordingMovement ?
(this.secondsPassed >= this.recordingDurationInSeconds) : (this.secondsPassed >= this.recordingDurationInSeconds) :
(this.secondsPassed >= this.exerciseDurationInSeconds); (this.secondsPassed >= this.exerciseRepetitionDurationInSeconds);
} }
/** /**
@@ -366,6 +366,10 @@ public class InputProcessor {
// Ensure the sensor ID is within the bounds of the array // Ensure the sensor ID is within the bounds of the array
if (sensorId < 0 || sensorId >= selfRotationVectorPaths.length) if (sensorId < 0 || sensorId >= selfRotationVectorPaths.length)
return 0.0d; return 0.0d;
// Calculate the index of the rotational vector where we're currently at
int targetRotationIdx =
/* /*
// Index of the current rotation vector // Index of the current rotation vector
@@ -393,10 +397,10 @@ public class InputProcessor {
*/ */
public double getAverageError(int sensorId) { public double getAverageError(int sensorId) {
double error = 0; double error = 0;
for (int i = 0; i < this.exerciseDurationInSeconds; i++) { for (int i = 0; i < this.exerciseRepetitionDurationInSeconds; i++) {
error += getError(sensorId, i); error += getError(sensorId, i);
} }
return error / this.exerciseDurationInSeconds; return error / this.exerciseRepetitionDurationInSeconds;
} }
public float secondsPassed() { public float secondsPassed() {