Merge branch 'main' of ssh://gitlab.fdmci.hva.nl/propedeuse-hbo-ict/onderwijs/2023-2024/out-a-se-ti/blok-4/muupooviixee66
This commit is contained in:
@@ -56,6 +56,7 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
|
|||||||
private static String exerciseVideoUrl;
|
private static String exerciseVideoUrl;
|
||||||
private Animate animate;
|
private Animate animate;
|
||||||
private VideoView videoView;
|
private VideoView videoView;
|
||||||
|
private QiContext qiContext;
|
||||||
|
|
||||||
private final Object lock = new Object();
|
private final Object lock = new Object();
|
||||||
|
|
||||||
@@ -136,22 +137,6 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
|
|||||||
motionProcessor.setRecording(true, 10);
|
motionProcessor.setRecording(true, 10);
|
||||||
motionProcessor.startListening();
|
motionProcessor.startListening();
|
||||||
|
|
||||||
if ( videoView.isPlaying() )
|
|
||||||
{
|
|
||||||
Animation animationarmraise = AnimationBuilder.with(qiContext) // Create the builder with the context.
|
|
||||||
.withResources(R.raw.armraise) // Set the animation resource.
|
|
||||||
.build(); // Build the animation.
|
|
||||||
|
|
||||||
animate = AnimateBuilder.with(qiContext) // Create the builder with the context.
|
|
||||||
.withAnimation(animationarmraise) // Set the animation.
|
|
||||||
.build(); // Build the animate action.
|
|
||||||
|
|
||||||
Future<Void> animateFuture = animate.async().run();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Log.e("FitnessActivity", "VideoView is null. Check your layout XML.");
|
|
||||||
}
|
|
||||||
|
|
||||||
}, (n) -> {
|
}, (n) -> {
|
||||||
int randomMessageIndex = (int) Math.floor(Math.random() * EXERCISE_NOT_FOUND_MESSAGES.length);
|
int randomMessageIndex = (int) Math.floor(Math.random() * EXERCISE_NOT_FOUND_MESSAGES.length);
|
||||||
@@ -192,6 +177,25 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
|
|||||||
if (what == MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START) {
|
if (what == MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START) {
|
||||||
ProgressBar loadingCircle = findViewById(R.id.loadingCircle);
|
ProgressBar loadingCircle = findViewById(R.id.loadingCircle);
|
||||||
loadingCircle.setVisibility(View.GONE);
|
loadingCircle.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
if ( videoView.isPlaying() )
|
||||||
|
{
|
||||||
|
QiContext qiContext = null;
|
||||||
|
Animation animationarmraise = AnimationBuilder.with(qiContext) // Create the builder with the context.
|
||||||
|
.withResources(R.raw.armraise) // Set the animation resource.
|
||||||
|
.build(); // Build the animation.
|
||||||
|
|
||||||
|
animate = AnimateBuilder.with(qiContext) // Create the builder with the context.
|
||||||
|
.withAnimation(animationarmraise) // Set the animation.
|
||||||
|
.build(); // Build the animate action.
|
||||||
|
|
||||||
|
Future<Void> animateFuture = animate.async().run();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log.e("FitnessActivity", "VideoView is null. Check your layout XML.");
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@@ -112,6 +112,7 @@ public class InputProcessor {
|
|||||||
ExerciseManager.TOTAL_REPETITIONS_REQUIRED += ExerciseManager.DEFAULT_EXERCISE_REPETITIONS;
|
ExerciseManager.TOTAL_REPETITIONS_REQUIRED += ExerciseManager.DEFAULT_EXERCISE_REPETITIONS;
|
||||||
ExerciseManager.TOTAL_EXERCISES_PREFORMED++;
|
ExerciseManager.TOTAL_EXERCISES_PREFORMED++;
|
||||||
|
|
||||||
|
this.selfRotationVectorPaths = new ArrayList[2];
|
||||||
this.selfRotationVectorPaths[0] = new ArrayList<>();
|
this.selfRotationVectorPaths[0] = new ArrayList<>();
|
||||||
this.selfRotationVectorPaths[1] = new ArrayList<>();
|
this.selfRotationVectorPaths[1] = new ArrayList<>();
|
||||||
|
|
||||||
@@ -130,14 +131,14 @@ public class InputProcessor {
|
|||||||
*/
|
*/
|
||||||
public void onAdequateRepetition() {
|
public void onAdequateRepetition() {
|
||||||
ExerciseManager.TOTAL_REPETITIONS_PERFORMED++;
|
ExerciseManager.TOTAL_REPETITIONS_PERFORMED++;
|
||||||
new FitnessActivity().incrementProgress();
|
this.parentActivity.incrementProgress();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method that is called whenever the user performs a bad repetition.
|
* Method that is called whenever the user performs a bad repetition.
|
||||||
*/
|
*/
|
||||||
public void onInadequateRepetition() {
|
public void onInadequateRepetition() {
|
||||||
new FitnessActivity().triggerColorBurst(false);
|
this.parentActivity.triggerColorBurst(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -352,55 +353,33 @@ public class InputProcessor {
|
|||||||
}*/
|
}*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function for getting the error offsets of the user's path compared to the
|
|
||||||
* target path at a given point in time.
|
|
||||||
*
|
*
|
||||||
* @param sensorId The sensor ID to get the error offsets from.
|
|
||||||
* @param time The time to get the error offsets from.
|
|
||||||
* This value must be >= 0 && <= exerciseTime, otherwise
|
|
||||||
* the error will be 0 by default.
|
|
||||||
* @return A list of error offsets of the motion data compared to the reference path.
|
|
||||||
*/
|
*/
|
||||||
public double getError(int sensorId, float time) {
|
public boolean isFaultyMovement(int sensorId, float time) {
|
||||||
|
|
||||||
// Ensure the sensor ID is within the bounds of the array
|
// Ensure the sensor ID is within the bounds of the array
|
||||||
if (sensorId < 0 || sensorId >= selfRotationVectorPaths.length)
|
if (sensorId < 0 || sensorId >= selfRotationVectorPaths.length)
|
||||||
return 0.0d;
|
return false;
|
||||||
|
|
||||||
// Calculate the index of the rotational vector where we're currently at
|
// Calculate the index of the reference rotation vector
|
||||||
int targetRotationIdx =
|
// This is done by calculating the closest index of the last received vector
|
||||||
|
// to the current time.
|
||||||
|
// i = | (t % T) / T * N |
|
||||||
|
|
||||||
/*
|
int i, referenceIndex;
|
||||||
|
|
||||||
// Index of the current rotation vector
|
for ( i = 0; i < selfRotationVectorPaths.length; i++)
|
||||||
int targetIndex = (int) ((this.exerciseDurationInSeconds / this.targetRotationVectorPaths[sensorId].length) * time);
|
{
|
||||||
int selfIndex = (int) (this.selfRotationVectorPaths[sensorId].length / this.sampleRate * time);
|
referenceIndex = (int) (Math.round(
|
||||||
|
((time % this.exerciseRepetitionDurationInSeconds) /
|
||||||
// Ensure the indexes are within the bounds of the array
|
(this.exerciseRepetitionDurationInSeconds)) * this.targetRotationVectorPaths[i].length))
|
||||||
if (
|
% this.targetRotationVectorPaths[i].length;
|
||||||
targetIndex >= 0 && targetIndex <= this.targetRotationVectorPaths[sensorId].length - 1 &&
|
// If distance is greater than the threshold, return true
|
||||||
selfIndex >= 0 && selfIndex <= this.selfRotationVectorPaths[sensorId].length - 1 &&
|
if (this.selfRotationVectorPaths[i].get(this.selfRotationVectorPaths[i].size() - 1).distance(
|
||||||
this.selfRotationVectorPaths[sensorId][selfIndex] != null &&
|
this.targetRotationVectorPaths[i][referenceIndex]) > ExerciseManager.EXERCISE_ERROR_MARGIN)
|
||||||
this.targetRotationVectorPaths[sensorId][targetIndex] != null
|
return true;
|
||||||
) {
|
|
||||||
return this.selfRotationVectorPaths[sensorId][selfIndex].distance(this.targetRotationVectorPaths[sensorId][targetIndex]);
|
|
||||||
}*/
|
|
||||||
return 0.0d;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method for getting the average error of the motion data
|
|
||||||
* compared to the reference path.
|
|
||||||
*
|
|
||||||
* @param sensorId The sensor ID to get the error offsets from.
|
|
||||||
* @return The average error of the motion data compared to the reference path.
|
|
||||||
*/
|
|
||||||
public double getAverageError(int sensorId) {
|
|
||||||
double error = 0;
|
|
||||||
for (int i = 0; i < this.exerciseRepetitionDurationInSeconds; i++) {
|
|
||||||
error += getError(sensorId, i);
|
|
||||||
}
|
}
|
||||||
return error / this.exerciseRepetitionDurationInSeconds;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float secondsPassed() {
|
public float secondsPassed() {
|
||||||
|
Reference in New Issue
Block a user