Fixed issues
This commit is contained in:
@@ -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;
|
||||
|
@@ -101,21 +101,19 @@ 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 ) {
|
||||
if (isFaulty) {
|
||||
this.onInadequateRepetition();
|
||||
} else this.onAdequateRepetition();
|
||||
|
||||
this.checksPerformed++;
|
||||
|
||||
if ( this.checksPerformed >= this.totalChecks )
|
||||
if (this.checksPerformed >= this.totalChecks)
|
||||
acquireExercise();
|
||||
|
||||
try {
|
||||
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user