Fixed issues

This commit is contained in:
Luca Warmenhoven
2024-06-05 14:50:05 +02:00
parent 2b631bd600
commit cca91461f3
2 changed files with 8 additions and 16 deletions

View File

@@ -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;

View File

@@ -101,12 +101,10 @@ 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) {
@@ -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;
}