Merge branch 'main' of https://gitlab.fdmci.hva.nl/propedeuse-hbo-ict/onderwijs/2023-2024/out-a-se-ti/blok-4/muupooviixee66
This commit is contained in:
@@ -76,7 +76,7 @@ public class ExerciseManager {
|
|||||||
content.get(PROPERTY_NAME).getAsString(),
|
content.get(PROPERTY_NAME).getAsString(),
|
||||||
content.get(PROPERTY_DESC).getAsString(),
|
content.get(PROPERTY_DESC).getAsString(),
|
||||||
gesturePathFromString(content.get(PROPERTY_VECTORS).getAsString()),
|
gesturePathFromString(content.get(PROPERTY_VECTORS).getAsString()),
|
||||||
DEFAULT_SEGMENT_SPEED
|
gesturePathFromString(content.get(PROPERTY_SEGMENT_SPEED).getAsString())
|
||||||
);
|
);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@@ -45,23 +45,22 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
|
|||||||
|
|
||||||
GesturePath.Builder gesturePathBuilder = new GesturePath.Builder();
|
GesturePath.Builder gesturePathBuilder = new GesturePath.Builder();
|
||||||
|
|
||||||
gesturePathBuilder.addVector(new Vector3f(-.5f, -.5f, -.5f));
|
for ( int i = 0; i < 40; i++)
|
||||||
gesturePathBuilder.addVector(new Vector3f(.5f, -.5f, -.5f));
|
{
|
||||||
gesturePathBuilder.addVector(new Vector3f(.5f, -.5f, .5f));
|
gesturePathBuilder.addVector(
|
||||||
gesturePathBuilder.addVector(new Vector3f(-.5f, -.5f, .5f));
|
new Vector3f(
|
||||||
gesturePathBuilder.addVector(new Vector3f(-.5f, -.5f, -.5f));
|
(float)Math.cos(Math.PI + (Math.PI / 40.0f) * i),
|
||||||
|
(float)Math.sin(Math.PI + (Math.PI / 40.0f) * i),
|
||||||
gesturePathBuilder.addVector(new Vector3f(-.5f, .5f, -.5f));
|
0
|
||||||
gesturePathBuilder.addVector(new Vector3f(.5f, .5f, -.5f));
|
)
|
||||||
gesturePathBuilder.addVector(new Vector3f(.5f, .5f, .5f));
|
);
|
||||||
gesturePathBuilder.addVector(new Vector3f(-.5f, .5f, .5f));
|
}
|
||||||
gesturePathBuilder.addVector(new Vector3f(-.5f, .5f, -.5f));
|
|
||||||
|
|
||||||
personalMotionPreviewElement = findViewById(R.id.personalMotionPreviewElement);
|
personalMotionPreviewElement = findViewById(R.id.personalMotionPreviewElement);
|
||||||
personalMotionPreviewElement.post(() -> {
|
personalMotionPreviewElement.post(() -> {
|
||||||
Log.i("FitnessActivity", "PersonalMotionPreviewElement.post()");
|
Log.i("FitnessActivity", "PersonalMotionPreviewElement.post()");
|
||||||
|
|
||||||
Exercise exercise = new Exercise(EMuscleGroup.ARMS, "Bicep Curls", "Oefening voor de biceps.", gesturePathBuilder.build(), 1);
|
Exercise exercise = new Exercise(EMuscleGroup.ARMS, "Bicep Curls", "Oefening voor de biceps.", gesturePathBuilder.build(), gesturePathBuilder.build());
|
||||||
|
|
||||||
personalMotionPreviewElement.initialize(exercise);
|
personalMotionPreviewElement.initialize(exercise);
|
||||||
});
|
});
|
||||||
|
@@ -86,6 +86,7 @@ public class PersonalMotionPreviewElement extends View {
|
|||||||
this.targetPath = new Path();
|
this.targetPath = new Path();
|
||||||
|
|
||||||
this.startingTime = System.nanoTime(); // Set the last time to the current time
|
this.startingTime = System.nanoTime(); // Set the last time to the current time
|
||||||
|
this.exerciseProgress = 0.0d;
|
||||||
|
|
||||||
this.exercise = exercise;
|
this.exercise = exercise;
|
||||||
this.paths = exercise.getPath();
|
this.paths = exercise.getPath();
|
||||||
@@ -107,7 +108,10 @@ public class PersonalMotionPreviewElement extends View {
|
|||||||
|
|
||||||
// Handler that is called every time the motion processor receives new data.
|
// Handler that is called every time the motion processor receives new data.
|
||||||
this.motionProcessor.setMotionDataEventHandler((processed, preprocessed, sampleIndex, sampleRate, deviceId) -> {
|
this.motionProcessor.setMotionDataEventHandler((processed, preprocessed, sampleIndex, sampleRate, deviceId) -> {
|
||||||
this.exerciseProgress = Math.min(1, this.motionProcessor.getAverageError(this.paths[0], 0) / 10);
|
double progress = this.motionProcessor.getAverageError(this.paths[0], 0);
|
||||||
|
this.exerciseProgress = Math.min(1, Math.max(0, progress));
|
||||||
|
this.invalidate();
|
||||||
|
Log.i("MotionProcessor", "Processed data: " + progress + " (" + preprocessed + ")");
|
||||||
});
|
});
|
||||||
saySomethingNice();
|
saySomethingNice();
|
||||||
}
|
}
|
||||||
@@ -154,7 +158,5 @@ public class PersonalMotionPreviewElement extends View {
|
|||||||
);
|
);
|
||||||
|
|
||||||
timePassed = (System.nanoTime() - startingTime) / 1E9D;
|
timePassed = (System.nanoTime() - startingTime) / 1E9D;
|
||||||
|
|
||||||
this.invalidate(); // Causes a redraw.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -78,10 +78,6 @@ public class MotionProcessor {
|
|||||||
|
|
||||||
JsonObject object = json.getAsJsonObject();
|
JsonObject object = json.getAsJsonObject();
|
||||||
|
|
||||||
// Object must contain device identifier
|
|
||||||
if (!object.has("deviceId"))
|
|
||||||
return;
|
|
||||||
|
|
||||||
String[] required = {
|
String[] required = {
|
||||||
"rotationX", "rotationY", "rotationZ",
|
"rotationX", "rotationY", "rotationZ",
|
||||||
"accelerationX", "accelerationY", "accelerationZ",
|
"accelerationX", "accelerationY", "accelerationZ",
|
||||||
|
Reference in New Issue
Block a user