diff --git a/code/arduino/Movement-sensor-code/Connectivity.cpp b/code/arduino/Movement-sensor-code/Connectivity.cpp index 955d7d0..1f7252d 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"; -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()); 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 67d4d31..fb84abd 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 @@ -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 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; + } } 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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