diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 4020532..25b05d8 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -14,10 +14,9 @@
-
-
+
-
+
@@ -210,7 +209,11 @@
-
+
+
+
+
+ 1713528225837
@@ -384,7 +387,23 @@
1716891155110
-
+
+
+ 1716977853269
+
+
+
+ 1716977853269
+
+
+
+ 1716988959836
+
+
+
+ 1716988959836
+
+
@@ -424,6 +443,8 @@
-
+
+
+
\ No newline at end of file
diff --git a/code/arduino/Movement-sensor-code/Connectivity.cpp b/code/arduino/Movement-sensor-code/Connectivity.cpp
index bfc3c04..955d7d0 100644
--- a/code/arduino/Movement-sensor-code/Connectivity.cpp
+++ b/code/arduino/Movement-sensor-code/Connectivity.cpp
@@ -21,9 +21,9 @@ void Connectivity::connectWiFi(char* ssid, char* pass){
// }
const char* getServerURL = "http://145.92.8.132:443/get-ip";
-String ipAddress = "";
+char* ipAddress = "";
-String Connectivity::fetchIPAddress() {
+const char* Connectivity::fetchIPAddress() {
if (WiFi.status() == WL_CONNECTED) {
HTTPClient http;
WiFiClient client;
@@ -32,7 +32,7 @@ String Connectivity::fetchIPAddress() {
int httpCode = http.GET();
if (httpCode > 0) {
if (httpCode == HTTP_CODE_OK) {
- ipAddress = http.getString();
+ ipAddress = strdup(http.getString().c_str());
}
} else {
Serial.printf("GET request failed, error: %s\n", http.errorToString(httpCode).c_str());
diff --git a/code/arduino/Movement-sensor-code/Connectivity.h b/code/arduino/Movement-sensor-code/Connectivity.h
index 6de0109..37d528b 100644
--- a/code/arduino/Movement-sensor-code/Connectivity.h
+++ b/code/arduino/Movement-sensor-code/Connectivity.h
@@ -19,7 +19,7 @@ public:
void websocketSetup(char* ip, uint16_t port, char* adress);
void sendData(float roll, float pitch, float yaw);
int httpPost(const char *serverAddress, const char *serverSubPath, const unsigned short serverPort, const char *data, const size_t dataLength, const char *contentType);
- String fetchIPAddress();
+ const char* fetchIPAddress();
private:
ESP8266WiFiMulti wifi;
diff --git a/code/arduino/Movement-sensor-code/Movement-sensor-code.ino b/code/arduino/Movement-sensor-code/Movement-sensor-code.ino
index 061f12d..6540384 100644
--- a/code/arduino/Movement-sensor-code/Movement-sensor-code.ino
+++ b/code/arduino/Movement-sensor-code/Movement-sensor-code.ino
@@ -7,8 +7,6 @@ void setup() {
Serial.begin(9600);
}
-unsigned long lastTime = 0; // will store the last time the code was run
-
void loop() {
SensorManager::eulerAngles eulerRotation = sensorManager.getEulerAngles();
// SensorManager::acceleration rotationAcceleration = sensorManager.getAcelleration();
@@ -19,6 +17,11 @@ struct acceleration {
float z = 9;
} accelData;
+ if (!ipAquired) {
+ serverIp = connectivity.fetchIPAddress();
+ ipAquired = true;
+ }
+ unsigned long lastTime = 0; // will store the last time the code was run
unsigned long currentTime = millis();
if (currentTime - lastTime >= 100) { // 100 ms has passed
memset(buffer, 0, BUFFER_SIZE);
@@ -34,10 +37,10 @@ struct acceleration {
accelData.z,
"data");
// %d = int, %f = floatation, %s = string
- connectivity.httpPost(connectivity.fetchIPAddress(), "/", 3445, buffer, strlen(buffer), "application/json");
+ connectivity.httpPost(serverIp, "/", 3445, buffer, strlen(buffer), "application/json");
lastTime = currentTime;
}
}
//acceleration.X
//acceleration.Y
-//acceleration.Z
+//acceleration.Z
\ No newline at end of file
diff --git a/code/arduino/Movement-sensor-code/headerFIle.h b/code/arduino/Movement-sensor-code/headerFIle.h
index 8e3480e..bd6639b 100644
--- a/code/arduino/Movement-sensor-code/headerFIle.h
+++ b/code/arduino/Movement-sensor-code/headerFIle.h
@@ -15,3 +15,5 @@ WebSocketsClient webSocket;
#define IP_ADDRESS "192.168.137.12"
char *buffer = (char *)malloc(sizeof(char) * BUFFER_SIZE);
+const char* serverIp = NULL; // Declare serverIp here
+bool ipAquired = false;
\ No newline at end of file
diff --git a/code/server/incoming_request_handlers.js b/code/server/incoming_request_handlers.js
index 1f8d257..ef583a1 100644
--- a/code/server/incoming_request_handlers.js
+++ b/code/server/incoming_request_handlers.js
@@ -1,3 +1,6 @@
+
+const databaseQuery = 'SELECT * FROM `Exercise` ORDER BY RAND() LIMIT 1';
+
/**
*
* @param {Request} request The incoming request
@@ -8,45 +11,33 @@
function handleIncoming(request, response, app, pool)
{
- let query = 'SELECT * FROM Exercise WHERE ExerciseID = ?';
- let parameters = [];
-
- if (!request.hasOwnProperty('uid') || typeof request.uid !== 'number')
- {
- query = 'SELECT * FROM Exercise ORDER BY RAND() LIMIT 1';
- } else parameters.push(request.uid);
-
// Acquire database connection
pool.getConnection()
.then(conn => {
- conn.query(query, parameters)
+ conn.query(
+ databaseQuery)
.then(rows => {
if (rows.length === 0)
{
response
.status(404)
- .send(JSON.stringify({error: 'Exercise not found'}));
+ .send(JSON.stringify({error: 'No exercises found in the database.'}));
}
else
{
- // Send back the data in the right format
- let converted = rows.map(row => {
- return {
- exerciseId: row.ExerciseID,
- name: row.Name,
- muscleGroup: row.MuscleGroup,
- shortDescription: row.ShortDescription,
- description: row.Description,
- imageUrl: row.ImageURL,
- videoUrl: row.VideoURL,
- path: row.Path,
- duration: row.Duration
- };
- });
-
- response
- .status(200)
- .send(JSON.stringify(converted));
+ let row = rows[0];
+ response.status(200)
+ .send(JSON.stringify({
+ exerciseId: row['ExerciseID'],
+ name: row['Name'],
+ muscleGroup: row['MuscleGroup'],
+ shortDescription: row['ShortDescription'],
+ description: row['Description'],
+ imageUrl: row['ImageURL'],
+ videoUrl: row['VideoURL'],
+ path: row['Path'],
+ duration: row['Duration']
+ }))
}
})
.catch(error => {
diff --git a/code/src/Fitbot/.idea/misc.xml b/code/src/Fitbot/.idea/misc.xml
index a6192e8..b1965d6 100644
--- a/code/src/Fitbot/.idea/misc.xml
+++ b/code/src/Fitbot/.idea/misc.xml
@@ -35,13 +35,15 @@
-
+
+
+
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 f5422cb..01b4b20 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
@@ -1,10 +1,15 @@
package com.example.fitbot.ui.activities;
+import android.app.Dialog;
import android.content.Context;
+import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
+import android.view.View;
+import android.view.WindowManager;
+import android.widget.Button;
import android.widget.VideoView;
import com.aldebaran.qi.sdk.QiContext;
@@ -59,7 +64,17 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
VideoView videoView = findViewById(R.id.videoView);
playVideo(videoView, this);
NavigationManager.setupButtonNavigation(this, R.id.homeButtonFitness, MainActivity.class);
+ NavigationManager.setupButtonNavigation(this, R.id.skipButtonFitness, MainActivity.class); //Needs to skip exercises once those are implemented
+
NavigationManager.hideSystemUI(this);
+
+ Button infoButtonFitness = findViewById(R.id.infoButtonFitness);
+ infoButtonFitness.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ showInfoDialog();
+ }
+ });
}
@Override
@@ -163,4 +178,24 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
super.onDestroy();
}
+
+ private void showInfoDialog() {
+ final Dialog dialog = new Dialog(this);
+ dialog.setContentView(R.layout.dialog_info);
+
+ NavigationManager.hideSystemUI(this);
+
+ dialog.getWindow().setDimAmount(0.5f);
+ dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
+ dialog.setCancelable(true);
+
+ Button closeButton = dialog.findViewById(R.id.closeButtonDialog);
+ closeButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ dialog.dismiss();
+ }
+ });
+ dialog.show();
+ }
}
\ No newline at end of file
diff --git a/code/src/Fitbot/app/src/main/res/drawable/ic_baseline_close_48.xml b/code/src/Fitbot/app/src/main/res/drawable/ic_baseline_close_48.xml
new file mode 100644
index 0000000..72f8573
--- /dev/null
+++ b/code/src/Fitbot/app/src/main/res/drawable/ic_baseline_close_48.xml
@@ -0,0 +1,5 @@
+
+
+
diff --git a/code/src/Fitbot/app/src/main/res/layout/dialog_info.xml b/code/src/Fitbot/app/src/main/res/layout/dialog_info.xml
new file mode 100644
index 0000000..f64e32a
--- /dev/null
+++ b/code/src/Fitbot/app/src/main/res/layout/dialog_info.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/code/src/Fitbot/app/src/main/res/values/colors.xml b/code/src/Fitbot/app/src/main/res/values/colors.xml
index 7cb4f05..001b7ff 100644
--- a/code/src/Fitbot/app/src/main/res/values/colors.xml
+++ b/code/src/Fitbot/app/src/main/res/values/colors.xml
@@ -14,5 +14,6 @@
#FFFFFF#000000#000000
+ #00000000
diff --git a/code/src/Fitbot/app/src/main/res/values/strings.xml b/code/src/Fitbot/app/src/main/res/values/strings.xml
index ee81225..db32e16 100644
--- a/code/src/Fitbot/app/src/main/res/values/strings.xml
+++ b/code/src/Fitbot/app/src/main/res/values/strings.xml
@@ -26,4 +26,6 @@
TitleContextContextContext
+ Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
+ Description
\ No newline at end of file
diff --git a/code/web/pepper_data_test.js b/code/web/pepper_data_test.js
index 674aa18..222a394 100644
--- a/code/web/pepper_data_test.js
+++ b/code/web/pepper_data_test.js
@@ -1,24 +1,22 @@
-const address = 'http://145.92.8.135:3445/';
-
-const data = {
- rotationX: 1,
- rotationY: .4,
- rotationZ: .1,
- accelerationX: 1,
- accelerationY: 2,
- accelerationZ: 4,
- deviceId: 1,
- type: 'data'
-};
-
-for ( let i = 0; i < 10; i++)
+const address = 'http://192.168.137.45:3445';
+const amount = 10;
+for ( let i = 0; i < amount; i++)
{
setTimeout(() => {
console.log("Sending data");
fetch(address, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify(data)
+ body: JSON.stringify({
+ rotationX: 0,
+ rotationY: 0,
+ rotationZ: 0,
+ accelerationX: Math.PI / amount * i,
+ accelerationY: 0,
+ accelerationZ: 0,
+ type: 'data',
+ deviceId: 0
+ })
});
}, i * 1000);
}
\ No newline at end of file
diff --git a/docs/documentation/assets/knocksensor.png b/docs/documentation/assets/knocksensor.png
new file mode 100644
index 0000000..4a4907f
Binary files /dev/null and b/docs/documentation/assets/knocksensor.png differ
diff --git a/docs/documentation/hardware/Ideas.md b/docs/documentation/hardware/Ideas.md
new file mode 100644
index 0000000..8efdd05
--- /dev/null
+++ b/docs/documentation/hardware/Ideas.md
@@ -0,0 +1,17 @@
+# Ideas for hardware
+
+# making a balance bord
+
+Since We are not able to connect the wii fit bord we have to come up with a solution. We thought of it for some time and what we want to do with it. Origanlly we wanted to use the balance bord for excersises such as standing on one leg. This is a simple leg excersise we wanted to have. We thaugt of multiple solutions to still have this excersise. However we still needed to think of a design for the frame.
+
+# the frame
+
+We wanted it to have a similar style to the balance bord. howevere since we can make or own we wanted to make it a bit taller. This makes it easier to implement some other excersise such as the step up. This is na excersise that benefits from a taller box than the wii fit box.
+
+## LDR
+
+We can use a LDR to determine if someone is standing on the bord
+
+## Knock sensor
+
+
\ No newline at end of file