Attempt to make good
This commit is contained in:
@@ -45,23 +45,22 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
|
||||
|
||||
GesturePath.Builder gesturePathBuilder = new GesturePath.Builder();
|
||||
|
||||
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));
|
||||
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));
|
||||
gesturePathBuilder.addVector(new Vector3f(-.5f, .5f, .5f));
|
||||
gesturePathBuilder.addVector(new Vector3f(-.5f, .5f, -.5f));
|
||||
for ( int i = 0; i < 40; i++)
|
||||
{
|
||||
gesturePathBuilder.addVector(
|
||||
new Vector3f(
|
||||
(float)Math.cos(Math.PI + (Math.PI / 40.0f) * i),
|
||||
(float)Math.sin(Math.PI + (Math.PI / 40.0f) * i),
|
||||
0
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
personalMotionPreviewElement = findViewById(R.id.personalMotionPreviewElement);
|
||||
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);
|
||||
});
|
||||
|
@@ -86,6 +86,7 @@ public class PersonalMotionPreviewElement extends View {
|
||||
this.targetPath = new Path();
|
||||
|
||||
this.startingTime = System.nanoTime(); // Set the last time to the current time
|
||||
this.exerciseProgress = 0.0d;
|
||||
|
||||
this.exercise = exercise;
|
||||
this.paths = exercise.getPath();
|
||||
@@ -107,7 +108,9 @@ public class PersonalMotionPreviewElement extends View {
|
||||
|
||||
// Handler that is called every time the motion processor receives new data.
|
||||
this.motionProcessor.setMotionDataEventHandler((processed, preprocessed, sampleIndex, sampleRate, deviceId) -> {
|
||||
this.exerciseProgress = Math.min(1, this.motionProcessor.getAverageError(this.paths[0], 0) / 10);
|
||||
this.exerciseProgress = Math.min(1, Math.max(0, this.motionProcessor.getAverageError(this.paths[0], 0) / 10));
|
||||
this.invalidate();
|
||||
Log.i("MotionProcessor", "Processed data: " + processed);
|
||||
});
|
||||
saySomethingNice();
|
||||
}
|
||||
@@ -154,7 +157,5 @@ public class PersonalMotionPreviewElement extends View {
|
||||
);
|
||||
|
||||
timePassed = (System.nanoTime() - startingTime) / 1E9D;
|
||||
|
||||
this.invalidate(); // Causes a redraw.
|
||||
}
|
||||
}
|
||||
|
@@ -78,10 +78,6 @@ public class MotionProcessor {
|
||||
|
||||
JsonObject object = json.getAsJsonObject();
|
||||
|
||||
// Object must contain device identifier
|
||||
if (!object.has("deviceId"))
|
||||
return;
|
||||
|
||||
String[] required = {
|
||||
"rotationX", "rotationY", "rotationZ",
|
||||
"accelerationX", "accelerationY", "accelerationZ",
|
||||
|
Reference in New Issue
Block a user