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:
SebasKoedam
2024-06-03 14:55:14 +02:00
6 changed files with 322 additions and 34 deletions

View File

@@ -21,7 +21,7 @@ void Connectivity::connectWiFi(char* ssid, char* pass){
// }
const char* getServerURL = "http://145.92.8.132:443/get-ip";
char* ipAddress = "";
String ipAddress = ""; // string that will hold the server's IP address
const char* Connectivity::fetchIPAddress() {
if (WiFi.status() == WL_CONNECTED) {
@@ -32,7 +32,8 @@ const char* Connectivity::fetchIPAddress() {
int httpCode = http.GET();
if (httpCode > 0) {
if (httpCode == HTTP_CODE_OK) {
ipAddress = strdup(http.getString().c_str());
// If successful (code 200), read the response body and store the IP address
ipAddress = http.getString();
}
} else {
Serial.printf("GET request failed, error: %s\n", http.errorToString(httpCode).c_str());

View File

@@ -173,7 +173,7 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
Pepper.provideContext(null, this.getClass()); // Remove the context (unavailable)
// Go to the main screen
NavigationManager.navigateToActivity(this, MainActivity.class);
// NavigationManager.navigateToActivity(this, MainActivity.class);
}
@Override

View File

@@ -86,40 +86,9 @@ public class ExerciseStatusElement extends View implements IInputHandler {
Pepper.say(STARTING_PHRASES[(int) Math.floor(Math.random() * STARTING_PHRASES.length)]);
// Handler that is called every time the motion processor receives new data.
this.motionProcessor.setInputHandler((rotationVector, deviceId) -> {
Log.i("MotionProcessor", "Rotation vector received: " + rotationVector);
Log.i("MotionProcessor", "Last error offset:" + this.motionProcessor.getError(deviceId, this.motionProcessor.secondsPassed()));
// Check whether the current exercise has been completed.
// This is determined by the duration of the exercise, and the amount of time that has passed.
// The duration of the exercise originates from the database, and is stored in seconds.
// Whenever 'useExercise' is called, the timer resets and this method will be called again.
if (this.motionProcessor.hasFinished()) {
// If for some reason the parent activity is not defined,
// move back to the main screen.
if (this.parentActivity == null) {
// Move to main screen
NavigationManager.navigateToActivity(getContext(), MainActivity.class);
return;
}
// Move on to the next exercise, or finish.
if (this.exerciseCount > 0) {
this.exerciseCount--;
this.parentActivity.fetchExerciseAsync((newExercise) -> {
this.motionProcessor.useExercise(newExercise);
// Whenever the database retrieval failed, we return to the main screen.
}, (failed) -> {
// Move to main screen
NavigationManager.navigateToActivity(parentActivity, MainActivity.class);
});
} else {
// Finish the exercise.
NavigationManager.navigateToActivity(parentActivity, EndScreenActivity.class);
}
}
});
}
/**
@@ -130,6 +99,7 @@ public class ExerciseStatusElement extends View implements IInputHandler {
public void setExercise(Exercise exercise) {
this.motionProcessor.useExercise(exercise);
this.exercise = exercise;
Log.i("MotionProcessor", "Updating exercise in ExerciseStatusElement");
}
@Override
@@ -157,6 +127,40 @@ public class ExerciseStatusElement extends View implements IInputHandler {
@Override
public void accept(Vector3f rotationVector, int sensorId) {
Log.i("MotionProcessor", "Rotation vector received: " + rotationVector);
Log.i("MotionProcessor", "Last error offset:" + this.motionProcessor.getError(sensorId, this.motionProcessor.secondsPassed()));
// Check whether the current exercise has been completed.
// This is determined by the duration of the exercise, and the amount of time that has passed.
// The duration of the exercise originates from the database, and is stored in seconds.
// Whenever 'useExercise' is called, the timer resets and this method will be called again.
if (this.motionProcessor.hasFinished() && !this.motionProcessor.isRecording()) {
// If for some reason the parent activity is not defined,
// move back to the main screen.
if (this.parentActivity == null) {
// Move to main screen
Log.i("MotionProcessor", "Parent activity was null.");
NavigationManager.navigateToActivity(getContext(), MainActivity.class);
return;
}
// Move on to the next exercise, or finish.
if (this.exerciseCount > 0) {
this.exerciseCount--;
this.parentActivity.fetchExerciseAsync((newExercise) -> {
this.motionProcessor.useExercise(newExercise);
// Whenever the database retrieval failed, we return to the main screen.
}, (failed) -> {
// Move to main screen
Log.i("MotionProcessor", "Failed to fetch exercise from database");
NavigationManager.navigateToActivity(parentActivity, MainActivity.class);
});
} else {
// Finish the exercise.
Log.i("MotionProcessor", "Exercise has finished");
NavigationManager.navigateToActivity(parentActivity, EndScreenActivity.class);
}
}
}
}

View File

@@ -335,4 +335,8 @@ public class InputProcessor {
public float secondsPassed() {
return (float) secondsPassed;
}
public boolean isRecording() {
return this.recordingMovement;
}
}

View File

@@ -0,0 +1,275 @@
<?xml version="1.0" encoding="UTF-8"?>
<Animation xmlns:editor="http://www.ald.softbankrobotics.com/animation/editor" typeVersion="2.0" editor:fps="25">
<ActuatorCurve fps="25" actuator="HeadYaw" mute="false" unit="degree">
<Key value="-0.439454377" frame="101">
<Tangent side="right" abscissaParam="32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="-0.439454377" frame="199">
<Tangent side="left" abscissaParam="-32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="-0.439454377" frame="299">
<Tangent side="left" abscissaParam="-33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="-0.439454377" frame="401">
<Tangent side="left" abscissaParam="-34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
</ActuatorCurve>
<ActuatorCurve fps="25" actuator="HeadPitch" mute="false" unit="degree">
<Key value="-12.1289139" frame="101">
<Tangent side="right" abscissaParam="32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="-12.1289139" frame="199">
<Tangent side="left" abscissaParam="-32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="-12.1289139" frame="299">
<Tangent side="left" abscissaParam="-33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="-12.1289139" frame="401">
<Tangent side="left" abscissaParam="-34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
</ActuatorCurve>
<ActuatorCurve fps="25" actuator="LShoulderPitch" mute="false" unit="degree">
<Key value="-119.500008" frame="101">
<Tangent side="right" abscissaParam="32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="119.500008" frame="199">
<Tangent side="left" abscissaParam="-32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="119.500008" frame="299">
<Tangent side="left" abscissaParam="-33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="119.500008" frame="401">
<Tangent side="left" abscissaParam="-34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
</ActuatorCurve>
<ActuatorCurve fps="25" actuator="LShoulderRoll" mute="false" unit="degree">
<Key value="6.67969275" frame="101">
<Tangent side="right" abscissaParam="32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="6.67969275" frame="199">
<Tangent side="left" abscissaParam="-32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="6.67969275" frame="299">
<Tangent side="left" abscissaParam="-33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="6.67969275" frame="401">
<Tangent side="left" abscissaParam="-34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
</ActuatorCurve>
<ActuatorCurve fps="25" actuator="LElbowYaw" mute="false" unit="degree">
<Key value="-69.7851486" frame="101">
<Tangent side="right" abscissaParam="32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="-69.7851486" frame="199">
<Tangent side="left" abscissaParam="-32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="-69.7851486" frame="299">
<Tangent side="left" abscissaParam="-33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="-69.7851486" frame="401">
<Tangent side="left" abscissaParam="-34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
</ActuatorCurve>
<ActuatorCurve fps="25" actuator="LElbowRoll" mute="false" unit="degree">
<Key value="-29.7070332" frame="101">
<Tangent side="right" abscissaParam="32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="-29.7070332" frame="199">
<Tangent side="left" abscissaParam="-32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="-29.7070332" frame="299">
<Tangent side="left" abscissaParam="-33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="-29.7070332" frame="401">
<Tangent side="left" abscissaParam="-34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
</ActuatorCurve>
<ActuatorCurve fps="25" actuator="LWristYaw" mute="false" unit="degree">
<Key value="-1.76023543" frame="101">
<Tangent side="right" abscissaParam="32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="-1.76023543" frame="199">
<Tangent side="left" abscissaParam="-32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="-1.76023543" frame="299">
<Tangent side="left" abscissaParam="-33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="-1.76023543" frame="401">
<Tangent side="left" abscissaParam="-34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
</ActuatorCurve>
<ActuatorCurve fps="25" actuator="LHand" mute="false" unit="dimensionless">
<Key value="0.589630966" frame="101">
<Tangent side="right" abscissaParam="32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="0.589630966" frame="199">
<Tangent side="left" abscissaParam="-32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="0.589630966" frame="299">
<Tangent side="left" abscissaParam="-33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="0.589630966" frame="401">
<Tangent side="left" abscissaParam="-34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
</ActuatorCurve>
<ActuatorCurve fps="25" actuator="HipRoll" mute="false" unit="degree">
<Key value="-0.26367262" frame="101">
<Tangent side="right" abscissaParam="32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="-0.26367262" frame="199">
<Tangent side="left" abscissaParam="-32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="-0.26367262" frame="299">
<Tangent side="left" abscissaParam="-33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="-0.26367262" frame="401">
<Tangent side="left" abscissaParam="-34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
</ActuatorCurve>
<ActuatorCurve fps="25" actuator="HipPitch" mute="false" unit="degree">
<Key value="-1.49414492" frame="101">
<Tangent side="right" abscissaParam="32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="-1.49414492" frame="199">
<Tangent side="left" abscissaParam="-32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="-1.49414492" frame="299">
<Tangent side="left" abscissaParam="-33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="-1.49414492" frame="401">
<Tangent side="left" abscissaParam="-34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
</ActuatorCurve>
<ActuatorCurve fps="25" actuator="KneePitch" mute="false" unit="degree">
<Key value="0" frame="101">
<Tangent side="right" abscissaParam="32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="0" frame="199">
<Tangent side="left" abscissaParam="-32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="0" frame="299">
<Tangent side="left" abscissaParam="-33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="0" frame="401">
<Tangent side="left" abscissaParam="-34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
</ActuatorCurve>
<ActuatorCurve fps="25" actuator="RShoulderPitch" mute="false" unit="degree">
<Key value="119.500008" frame="101">
<Tangent side="right" abscissaParam="32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="-119.500008" frame="199">
<Tangent side="left" abscissaParam="-32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="112.970039" frame="299">
<Tangent side="left" abscissaParam="-33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="112.970039" frame="401">
<Tangent side="left" abscissaParam="-34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
</ActuatorCurve>
<ActuatorCurve fps="25" actuator="RShoulderRoll" mute="false" unit="degree">
<Key value="-0.5" frame="101">
<Tangent side="right" abscissaParam="32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="-0.5" frame="199">
<Tangent side="left" abscissaParam="-32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="-0.5" frame="299">
<Tangent side="left" abscissaParam="-33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="-0.5" frame="401">
<Tangent side="left" abscissaParam="-34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
</ActuatorCurve>
<ActuatorCurve fps="25" actuator="RElbowYaw" mute="false" unit="degree">
<Key value="70.2246094" frame="101">
<Tangent side="right" abscissaParam="32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="70.2246094" frame="199">
<Tangent side="left" abscissaParam="-32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="70.2246094" frame="299">
<Tangent side="left" abscissaParam="-33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="70.2246094" frame="401">
<Tangent side="left" abscissaParam="-34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
</ActuatorCurve>
<ActuatorCurve fps="25" actuator="RElbowRoll" mute="false" unit="degree">
<Key value="29.7070332" frame="101">
<Tangent side="right" abscissaParam="32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="29.7070332" frame="199">
<Tangent side="left" abscissaParam="-32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="29.7070332" frame="299">
<Tangent side="left" abscissaParam="-33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="29.7070332" frame="401">
<Tangent side="left" abscissaParam="-34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
</ActuatorCurve>
<ActuatorCurve fps="25" actuator="RWristYaw" mute="false" unit="degree">
<Key value="1.57964516" frame="101">
<Tangent side="right" abscissaParam="32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="1.57964516" frame="199">
<Tangent side="left" abscissaParam="-32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="1.57964516" frame="299">
<Tangent side="left" abscissaParam="-33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="1.57964516" frame="401">
<Tangent side="left" abscissaParam="-34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
</ActuatorCurve>
<ActuatorCurve fps="25" actuator="RHand" mute="false" unit="dimensionless">
<Key value="0.588752136" frame="101">
<Tangent side="right" abscissaParam="32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="0.588752136" frame="199">
<Tangent side="left" abscissaParam="-32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="0.588752136" frame="299">
<Tangent side="left" abscissaParam="-33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="0.588752136" frame="401">
<Tangent side="left" abscissaParam="-34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
</ActuatorCurve>
</Animation>