This commit is contained in:
2024-06-05 17:36:01 +02:00
parent 3b7352aa4c
commit 5537230b49
4 changed files with 31 additions and 20 deletions

View File

@@ -37,7 +37,7 @@ public class ExerciseManager {
};
public static final int DEFAULT_EXERCISE_REPETITIONS = 10;
public static final float EXERCISE_ERROR_MARGIN = 1.0f;
public static final float EXERCISE_ERROR_MARGIN = 1.5f;
public static final float EXERCISE_TIME_SCALING_FACTOR = 1.0f;
// Fields representing the statistics of the user

View File

@@ -41,7 +41,7 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
// Progress circle for the exercises
private ProgressBar progressCircle;
private TextView progressText;
private int progress = 0;
private int progress = 1;
private final int maxProgress = 10;
// Exercise status element data
@@ -178,6 +178,7 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
// Start checking for user movement once the video has loaded
this.motionProcessor.startListening();
this.motionProcessor.startCheckingUserMovement();
// this.motionProcessor.setRecording(true, 4.f);
return true;
}
@@ -204,7 +205,7 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
public void playVideo(VideoView videoView, Context context) {
// Set up the video player
if (videoView != null) {
videoView.setVideoURI(Uri.parse("android.resource://" + context.getPackageName() + "/" + R.raw.arm_raises));
videoView.setVideoPath(exerciseVideoUrl);
videoView.start();
} else {
Log.e("FitnessActivity", "VideoView is null. Check your layout XML.");
@@ -273,6 +274,9 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
public void triggerColorBurst(boolean isGoodRep) {
Log.i("InputProcessor", "Color Burst");
try {
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));
@@ -287,5 +291,8 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
}
});
animator.start();
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -108,8 +108,11 @@ public class InputProcessor {
while (this.exercisesRemaining > 0) {
if ( this.totalChecks == 0)
if ( this.totalChecks == 0 || this.selfRotationVectorPaths == null
|| this.selfRotationVectorPaths.length == 0
|| this.selfRotationVectorPaths[0].size() == 0)
continue;
boolean isFaulty = this.isFaultyMovement();
Log.i("InputProcessor", "Movement checked: " + (isFaulty ? "Faulty" : "Good"));
@@ -170,7 +173,7 @@ public class InputProcessor {
Log.i("InputProcessor", "Repetition time: " + exercise.exerciseTimeInSeconds);
this.exerciseRepetitionDurationInSeconds = Math.max(this.exerciseRepetitionDurationInSeconds, 2);
this.errorCheckInterval_s = exercise.exerciseTimeInSeconds / 6.0f;
this.errorCheckInterval_s = exercise.exerciseTimeInSeconds / 3.0f;
Log.i("InputProcessor", "Exercise error checking interval: " + this.errorCheckInterval_s);
}
@@ -256,6 +259,7 @@ public class InputProcessor {
this.parentActivity.runOnUiThread(() -> {
NavigationManager.navigateToActivity(this.parentActivity, EndScreenActivity.class);
});
return;
}
Log.i("MotionProcessor", "Fetching exercise data.");

View File

@@ -113,7 +113,7 @@
android:layout_gravity="center"
android:indeterminate="false"
android:max="10"
android:progress="0"
android:progress="1"
android:progressDrawable="@drawable/progress_circle" />
<TextView
@@ -122,7 +122,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="0/10" />
android:text="1/10" />
</RelativeLayout>