From f1464653b042155a1496d7ef2a3ab51b85d29e0a Mon Sep 17 00:00:00 2001 From: Niels Gras Date: Mon, 3 Jun 2024 14:31:39 +0200 Subject: [PATCH 1/4] added comments --- code/arduino/Movement-sensor-code/Connectivity.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/arduino/Movement-sensor-code/Connectivity.cpp b/code/arduino/Movement-sensor-code/Connectivity.cpp index bfc3c04..2e9b69d 100644 --- a/code/arduino/Movement-sensor-code/Connectivity.cpp +++ b/code/arduino/Movement-sensor-code/Connectivity.cpp @@ -21,7 +21,7 @@ void Connectivity::connectWiFi(char* ssid, char* pass){ // } const char* getServerURL = "http://145.92.8.132:443/get-ip"; -String ipAddress = ""; +String ipAddress = ""; // string that will hold the server's IP address String Connectivity::fetchIPAddress() { if (WiFi.status() == WL_CONNECTED) { @@ -32,6 +32,7 @@ String Connectivity::fetchIPAddress() { int httpCode = http.GET(); if (httpCode > 0) { if (httpCode == HTTP_CODE_OK) { + // If successful (code 200), read the response body and store the IP address ipAddress = http.getString(); } } else { From c0d002c46b9ff5e23eed07cb023baa3ce3e10544 Mon Sep 17 00:00:00 2001 From: Sam Hos Date: Mon, 3 Jun 2024 14:47:31 +0200 Subject: [PATCH 2/4] Luca's attempt at fixing app --- .../fitbot/ui/activities/FitnessActivity.java | 2 +- .../ui/components/ExerciseStatusElement.java | 66 ++++++++++--------- .../util/processing/InputProcessor.java | 4 ++ 3 files changed, 40 insertions(+), 32 deletions(-) diff --git a/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/activities/FitnessActivity.java b/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/activities/FitnessActivity.java index 1d74427..7d970db 100644 --- a/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/activities/FitnessActivity.java +++ b/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/activities/FitnessActivity.java @@ -162,7 +162,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 diff --git a/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/components/ExerciseStatusElement.java b/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/components/ExerciseStatusElement.java index c8b112b..e8b2351 100644 --- a/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/components/ExerciseStatusElement.java +++ b/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/components/ExerciseStatusElement.java @@ -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); + } + } } } diff --git a/code/src/Fitbot/app/src/main/java/com/example/fitbot/util/processing/InputProcessor.java b/code/src/Fitbot/app/src/main/java/com/example/fitbot/util/processing/InputProcessor.java index 66c6d94..52c8524 100644 --- a/code/src/Fitbot/app/src/main/java/com/example/fitbot/util/processing/InputProcessor.java +++ b/code/src/Fitbot/app/src/main/java/com/example/fitbot/util/processing/InputProcessor.java @@ -335,4 +335,8 @@ public class InputProcessor { public float secondsPassed() { return (float) secondsPassed; } + + public boolean isRecording() { + return this.recordingMovement; + } } From 902cc184ee6d9bcb158adf5384fa52b496bbe16f Mon Sep 17 00:00:00 2001 From: Niels Gras Date: Mon, 3 Jun 2024 14:47:51 +0200 Subject: [PATCH 3/4] added arm circle movement --- .../app/src/main/res/raw/armcircle.qianim | 275 ++++++++++++++++++ 1 file changed, 275 insertions(+) create mode 100644 code/src/Fitbot/app/src/main/res/raw/armcircle.qianim diff --git a/code/src/Fitbot/app/src/main/res/raw/armcircle.qianim b/code/src/Fitbot/app/src/main/res/raw/armcircle.qianim new file mode 100644 index 0000000..5d8005b --- /dev/null +++ b/code/src/Fitbot/app/src/main/res/raw/armcircle.qianim @@ -0,0 +1,275 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 9639d6ba3bd64b4e1bfd6eb5a2fbed5b37435eb1 Mon Sep 17 00:00:00 2001 From: Sam Hos Date: Mon, 3 Jun 2024 14:48:18 +0200 Subject: [PATCH 4/4] hardware docs update --- docs/documentation/hardware/pcb.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/documentation/hardware/pcb.md b/docs/documentation/hardware/pcb.md index 2142df2..80c28a0 100644 --- a/docs/documentation/hardware/pcb.md +++ b/docs/documentation/hardware/pcb.md @@ -20,5 +20,9 @@ We chose this pcb because its really small and it has a socket for a sensor and We are going to rotational data from the sensor and use that to give feedback to the user based on how well they did the exercise. ![alt text](../assets/pcbImage.png) +## How can i program this ESP? + +To program this you need to use the Arduino IDE. You need to install the ESP8266 board in the board manager. You need to go to File -> prefrences -> additional board manager url's. Then you need to add this link `https://arduino.esp8266.com/stable/package_esp8266com_index.json`. Then you can find the LOLIN(WEMOS) D1 mini lite. Thats the board you need to select. When compiling you will see a lot of warnings but you can ignore them. + ### Sources * https://github.com/Sorakage033/SlimeVR-CheeseCake \ No newline at end of file