Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -189,6 +189,8 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
|
||||
EXERCISE_VIDEO_REPETITION++;
|
||||
if (progress >= 10) {
|
||||
runOnUiThread(() -> NavigationManager.navigateToActivity(this, EndScreenActivity.class));
|
||||
InputProcessor.exercisesRemaining = 1;
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@@ -25,11 +25,13 @@ import java.util.List;
|
||||
|
||||
public class InputProcessor {
|
||||
|
||||
private List<Vector3f>[] selfRotationVectorPaths = null; // Relative path of the motion data
|
||||
private List<Vector3f>[] selfRotationVectorPaths = null;
|
||||
|
||||
// Relative path of the motion data
|
||||
private Vector3f[][] targetRotationVectorPaths; // Target path of the motion data
|
||||
|
||||
private float exerciseRepetitionDurationInSeconds = 0.0f;
|
||||
private int exercisesRemaining = 1;
|
||||
public static int exercisesRemaining = 1;
|
||||
|
||||
private float errorCheckInterval_s;
|
||||
private int checksPerformed = 0;
|
||||
@@ -77,6 +79,10 @@ public class InputProcessor {
|
||||
*/
|
||||
public InputProcessor(FitnessActivity parentActivity) {
|
||||
this.parentActivity = parentActivity;
|
||||
|
||||
// Initialize each ArrayList in the array
|
||||
this.selfRotationVectorPaths[0] = new ArrayList<>();
|
||||
this.selfRotationVectorPaths[1] = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,11 +95,13 @@ public class InputProcessor {
|
||||
*
|
||||
* @param exercise The exercise to use the paths for.
|
||||
*/
|
||||
|
||||
|
||||
public void useExercise(Exercise exercise) {
|
||||
if (this.recordingMovement)
|
||||
throw new IllegalStateException("Cannot change exercise while recording movement.");
|
||||
|
||||
this.exercisesRemaining = 1;
|
||||
exercisesRemaining = 1;
|
||||
this.nextExercise(exercise);
|
||||
Pepper.say(STARTING_PHRASES[(int) Math.floor(Math.random() * STARTING_PHRASES.length)]);
|
||||
}
|
||||
@@ -107,32 +115,32 @@ public class InputProcessor {
|
||||
// Error checking thread.
|
||||
(new Thread(() -> {
|
||||
Log.i("InputProcessor", "Movement Checking Thread started");
|
||||
|
||||
while (this.exercisesRemaining > 0) {
|
||||
|
||||
|
||||
while (exercisesRemaining > 0) {
|
||||
|
||||
if ( this.totalChecks == 0 || this.selfRotationVectorPaths == null
|
||||
|| this.selfRotationVectorPaths.length == 0
|
||||
|| this.selfRotationVectorPaths[0].size() == 0
|
||||
|| this.selfRotationVectorPaths[1].size() == 0)
|
||||
|| this.selfRotationVectorPaths[1].size() == 0)
|
||||
continue;
|
||||
|
||||
|
||||
boolean isFaulty = this.isFaultyMovement();
|
||||
|
||||
|
||||
Log.i("InputProcessor", "Movement checked: " + (isFaulty ? "Faulty" : "Good"));
|
||||
|
||||
|
||||
if (isFaulty) {
|
||||
this.onInadequateRepetition();
|
||||
} else this.onAdequateRepetition();
|
||||
|
||||
|
||||
this.checksPerformed++;
|
||||
|
||||
|
||||
if (this.checksPerformed >= this.totalChecks)
|
||||
{
|
||||
this.checksPerformed = 0;
|
||||
this.exercisesRemaining--;
|
||||
acquireExercise();
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
Thread.sleep((long) (this.errorCheckInterval_s * 1000));
|
||||
} catch (InterruptedException e) {
|
||||
@@ -420,10 +428,10 @@ public class InputProcessor {
|
||||
* Function for checking whether the last movement was faulty
|
||||
*/
|
||||
public boolean isFaultyMovement() {
|
||||
boolean[] deviceMovementStatus = new boolean[selfRotationVectorPaths.length];
|
||||
boolean upMovementDetected = false;
|
||||
boolean downMovementDetected = false;
|
||||
|
||||
for (int i = 0; i < selfRotationVectorPaths.length; i++) {
|
||||
List<Vector3f> path = selfRotationVectorPaths[i];
|
||||
for (List<Vector3f> path : selfRotationVectorPaths) {
|
||||
if (path.size() < 2) {
|
||||
continue; // Skip if there are not enough points to compare
|
||||
}
|
||||
@@ -434,17 +442,16 @@ public class InputProcessor {
|
||||
float y1 = firstPoint.y;
|
||||
float y2 = lastPoint.y;
|
||||
|
||||
// Assuming that a good movement is when y2 is greater than y1
|
||||
deviceMovementStatus[i] = y2 > y1;
|
||||
}
|
||||
if (y2 > y1) {
|
||||
upMovementDetected = true;
|
||||
} else if (y2 < y1) {
|
||||
downMovementDetected = true;
|
||||
}
|
||||
|
||||
// Return true for faulty movement if any device has faulty movement
|
||||
for (boolean isGood : deviceMovementStatus) {
|
||||
if (!isGood) {
|
||||
return true;
|
||||
if (upMovementDetected && downMovementDetected) {
|
||||
return false; // Return false for faulty movement if both up and down movements are detected
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true; // Return true for faulty movement if only up or down movement is detected
|
||||
}}
|
||||
|
Reference in New Issue
Block a user