From af9138b1ea25d72e6c386f779a43d8b9214e94af Mon Sep 17 00:00:00 2001 From: Luca Warmenhoven Date: Wed, 15 May 2024 16:34:17 +0200 Subject: [PATCH 1/4] store changes --- .idea/workspace.xml | 31 +++++++++++++++---- .../motion-tracking-system-analysis.md | 4 +-- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 8668fe5..1beee62 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -14,10 +14,9 @@ - + - @@ -271,6 +288,8 @@ - \ No newline at end of file diff --git a/docs/documentation/research-questions/motion-tracking-system-analysis.md b/docs/documentation/research-questions/motion-tracking-system-analysis.md index bef7d99..9a349ea 100644 --- a/docs/documentation/research-questions/motion-tracking-system-analysis.md +++ b/docs/documentation/research-questions/motion-tracking-system-analysis.md @@ -46,5 +46,5 @@ acceleration vector `A(x, y, z)` and rotation vector `R(x, y, z)` to an accelera perpendicular to the normal vector of the earth. This is because the acceleration vector of the device is relative to its own axes, and not to the earth's normal vector. To convert this, we'll have to multiply the acceleration vector `A(x, y, z)` by the rotation matrix -with negative angles, to rotate it back to be perpendicular with the normal of the earth. -After \ No newline at end of file +with negative angles, to rotate it back to be perpendicular with the normal of the earth. +After this transformation \ No newline at end of file From ce5f50439a64b9ff36a526fc2efd6b6f3fc0edda Mon Sep 17 00:00:00 2001 From: Luca Warmenhoven Date: Wed, 15 May 2024 16:40:35 +0200 Subject: [PATCH 2/4] fixed --- .../com/example/fitbot/util/path/Point3D.java | 258 ------------------ .../util/processing/IMotionDataConsumer.java | 14 + .../util/processing/MotionProcessor.java | 16 +- 3 files changed, 15 insertions(+), 273 deletions(-) delete mode 100644 code/src/Fitbot/app/src/main/java/com/example/fitbot/util/path/Point3D.java create mode 100644 code/src/Fitbot/app/src/main/java/com/example/fitbot/util/processing/IMotionDataConsumer.java diff --git a/code/src/Fitbot/app/src/main/java/com/example/fitbot/util/path/Point3D.java b/code/src/Fitbot/app/src/main/java/com/example/fitbot/util/path/Point3D.java deleted file mode 100644 index de14c78..0000000 --- a/code/src/Fitbot/app/src/main/java/com/example/fitbot/util/path/Point3D.java +++ /dev/null @@ -1,258 +0,0 @@ -package com.example.fitbot.util.path; - -import java.util.Arrays; -import java.util.Comparator; - -public class Point3D { - - public double x, y, z; - - /** - * Constructor for creating a new vector. - * - * @param x The X component of the vector. - * @param y The Y component of the vector. - * @param z The Z component of the vector. - */ - public Point3D(double x, double y, double z) { - this.x = x; - this.y = y; - this.z = z; - } - - /** - * Copy the vector. - * - * @return A new vector with the same values. - */ - public Point3D copy() { - return new Point3D(this.x, this.y, this.z); - } - - /** - * Get the zero vector. - * - * @return The zero vector. - */ - public static Point3D zero() { - return new Point3D(0, 0, 0); - } - - /** - * Get the magnitude of the vector. - * - * @return The magnitude of the vector. - */ - public double magnitude() { - return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z); - } - - /** - * Normalize the vector. - * - * @return The normalized vector. - */ - public Point3D normalize() { - double mag = this.magnitude(); - if (mag == 0) throw new IllegalArgumentException("Cannot normalize the zero vector."); - return new Point3D(this.x / mag, this.y / mag, this.z / mag); - } - - /** - * Subtract the vector from another vector. - * - * @param other The other vector to subtract. - * @return The new vector. - */ - public Point3D subtract(Point3D other) { - return new Point3D(this.x - other.x, this.y - other.y, this.z - other.z); - } - - /** - * Add the vector to another vector. - * - * @param other The other vector to add. - * @return The new vector. - */ - public Point3D add(Point3D other) { - return new Point3D(this.x + other.x, this.y + other.y, this.z + other.z); - } - - /** - * Multiply the vector by a scalar. - * - * @param scalar The scalar to multiply by. - * @return The multiplied vector. - */ - public Point3D multiply(double scalar) { - return new Point3D(this.x * scalar, this.y * scalar, this.z * scalar); - } - - /** - * Divide the vector by a scalar. - * - * @param scalar The scalar to divide by. - * @return The divided vector. - */ - public Point3D divide(double scalar) { - if (scalar == 0) throw new IllegalArgumentException("Cannot divide by zero."); - return new Point3D(this.x / scalar, this.y / scalar, this.z / scalar); - } - - /** - * Negate the vector. - * - * @return The negated vector. - */ - public Point3D negate() { - return new Point3D(-this.x, -this.y, -this.z); - } - - /** - * Rotate the vector around the X, Y, and Z axes. - * - * @param radX Rotation around the X axis in radians. - * @param radY Rotation around the Y axis in radians. - * @param radZ Rotation around the Z axis in radians. - * @return The rotated vector. - */ - public Point3D rotate(double radX, double radY, double radZ) { - double cosX = Math.cos(radX); - double cosY = Math.cos(radY); - double cosZ = Math.cos(radZ); - double sinX = Math.sin(radX); - double sinY = Math.sin(radY); - double sinZ = Math.sin(radZ); - double newX = x * cosY * cosZ + y * cosY * sinZ - z * sinY; - double newY = x * (sinX * sinY * cosZ - cosX * sinZ) + y * (sinX * sinY * sinZ + cosX * cosZ) + z * sinX * cosY; - double newZ = x * (cosX * sinY * cosZ + sinX * sinZ) + y * (cosX * sinY * sinZ - sinX * cosZ) + z * cosX * cosY; - return new Point3D(newX, newY, newZ); - } - - /** - * Rotate the vector around the X, Y, and Z axes. - * - * @param rotation The rotation vector. - * @return The rotated vector. - */ - public Point3D rotate(Point3D rotation) { - return rotate(rotation.x, rotation.y, rotation.z); - } - - /** - * Rotate the vector around the X axis. - * - * @param angle Rotation around the X axis in radians. - * @return The rotated vector. - */ - public Point3D rotateX(double angle) { - double sinTheta = Math.sin(angle); - double cosTheta = Math.cos(angle); - return new Point3D( - x, - y * cosTheta - z * sinTheta, - y * sinTheta + z * cosTheta - ); - } - - /** - * Rotate the vector around the Y axis. - * - * @param angle Rotation around the Y axis in radians. - * @return The rotated vector. - */ - public Point3D rotateY(double angle) { - double sinTheta = Math.sin(angle); - double cosTheta = Math.cos(angle); - return new Point3D( - x * cosTheta + z * sinTheta, - y, - -x * sinTheta + z * cosTheta - ); - } - - /** - * Rotate the vector around the Z axis. - * - * @param angle Rotation around the Z axis in radians. - * @return The rotated vector. - */ - public Point3D rotateZ(double angle) { - double sinTheta = Math.sin(angle); - double cosTheta = Math.cos(angle); - return new Point3D( - x * cosTheta - y * sinTheta, - x * sinTheta + y * cosTheta, - z - ); - } - - /** - * Get the squared distance between this vector and another vector. - * - * @param compare The other vector. - * @return The squared distance between the two vectors. - */ - public double distanceSq(Point3D compare) { - return Math.pow(compare.x - x, 2) + Math.pow(compare.y - y, 2) + Math.pow(compare.z - z, 2); - } - - /** - * Get the distance between this vector and another vector. - * - * @param compare The other vector. - * @return The distance between the two vectors. - */ - public double distance(Point3D compare) { - return Math.sqrt(distanceSq(compare)); - } - - /** - * Calculate the distance to a line defined by two points. - * - * @param lineStart The starting point of the line. - * @param lineEnd The ending point of the line. - * @return The distance to the line. - */ - public double distanceToLine(Point3D lineStart, Point3D lineEnd) { - double lineDistance = lineStart.distanceSq(lineEnd); - if (lineDistance == 0) - return this.distanceSq(lineStart); - - double t = ((this.x - lineStart.x) * (lineEnd.x - lineStart.x) + - (this.y - lineStart.y) * (lineEnd.y - lineStart.y) + - (this.z - lineStart.z) * (lineEnd.z - lineStart.z)) / lineDistance; - - t = Math.max(0, Math.min(1, t)); - - return this.distanceSq(new Point3D( - lineStart.x + t * (lineEnd.x - lineStart.x), - lineStart.y + t * (lineEnd.y - lineStart.y), - lineStart.z + t * (lineEnd.z - lineStart.z)) - ); - } - - /** - * Retrieve the closest vector to this one given a list of vectors. - * - * @param vectors The list of vectors to compare. - * @return The closest vector. - */ - public Point3D closest(Point3D... vectors) { - return Arrays.stream(vectors).min(Comparator.comparingDouble(this::distanceSq)).orElse(null); - } - - public Point3D map(VectorMapFunction function) { - return function.apply(this); - } - - public interface VectorMapFunction { - Point3D apply(Point3D vector); - } - - @Override - public String toString() - { - return "Vector3(" + this.x + ", " + this.y + ", " + this.z + ")"; - } -} diff --git a/code/src/Fitbot/app/src/main/java/com/example/fitbot/util/processing/IMotionDataConsumer.java b/code/src/Fitbot/app/src/main/java/com/example/fitbot/util/processing/IMotionDataConsumer.java new file mode 100644 index 0000000..75def12 --- /dev/null +++ b/code/src/Fitbot/app/src/main/java/com/example/fitbot/util/processing/IMotionDataConsumer.java @@ -0,0 +1,14 @@ +package com.example.fitbot.util.processing; + +public interface IMotionDataConsumer { + + /** + * Function for accepting motion data and the transformed vector. + * @param transformedVector The transformed vector. + * @param motionData The input motion data. + * @param sampleIndex The index of the current sample + * @param sampleRate The sample rate. + */ + void accept(Vector3f transformedVector, MotionData motionData, int sampleIndex, double sampleRate); + +} \ No newline at end of file diff --git a/code/src/Fitbot/app/src/main/java/com/example/fitbot/util/processing/MotionProcessor.java b/code/src/Fitbot/app/src/main/java/com/example/fitbot/util/processing/MotionProcessor.java index edc8560..f79d129 100644 --- a/code/src/Fitbot/app/src/main/java/com/example/fitbot/util/processing/MotionProcessor.java +++ b/code/src/Fitbot/app/src/main/java/com/example/fitbot/util/processing/MotionProcessor.java @@ -22,7 +22,7 @@ public class MotionProcessor { private Vector3f ZERO = new Vector3f(0, 0, 0); private float sampleRate = 1.0F; // samples/second - private DataConsumer motionDataConsumer = (p1, p2, p3, p4) -> {}; + private IMotionDataConsumer motionDataConsumer = (p1, p2, p3, p4) -> {}; private GesturePath path; private WebSocket socket; @@ -245,19 +245,5 @@ public class MotionProcessor { Log.i("MotionProcessor", "Path length: " + relativePath.size()); Log.i("MotionProcessor", "Sample rate: " + sampleRate); Log.i("MotionProcessor", "Calibration point: " + ZERO.toString()); - - /** - * Interface that accepts motion data and the transformed vector. - */ - public interface DataConsumer { - - /** - * Function for accepting motion data and the transformed vector. - * @param transformedVector The transformed vector. - * @param motionData The input motion data. - * @param sampleIndex The index of the current sample - * @param sampleRate The sample rate. - */ - void accept(Vector3f transformedVector, MotionData motionData, int sampleIndex, double sampleRate); } } From 3ca982c36f62b984520a33a71a726f9509e4e713 Mon Sep 17 00:00:00 2001 From: SebasKoedam Date: Wed, 15 May 2024 16:41:32 +0200 Subject: [PATCH 3/4] feat: Add Bluetooth permissions and location permission to AndroidManifest.xml --- code/src/Fitbot/app/src/main/AndroidManifest.xml | 8 ++++---- .../com/example/fitbot/ui/activities/MainActivity.java | 4 ++-- .../research-questions/position-tracking-research.md | 6 +++++- docs/teamdocumentatie/sprint-reports/sprint-report-s1.md | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/code/src/Fitbot/app/src/main/AndroidManifest.xml b/code/src/Fitbot/app/src/main/AndroidManifest.xml index 2c2784b..23755ba 100644 --- a/code/src/Fitbot/app/src/main/AndroidManifest.xml +++ b/code/src/Fitbot/app/src/main/AndroidManifest.xml @@ -4,6 +4,10 @@ + + + + - - diff --git a/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/activities/MainActivity.java b/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/activities/MainActivity.java index 1ed3962..9b92474 100644 --- a/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/activities/MainActivity.java +++ b/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/activities/MainActivity.java @@ -1,4 +1,4 @@ -package com.example.fitbot; +package com.example.fitbot.ui.activities; import android.annotation.SuppressLint; import android.content.Intent; @@ -16,7 +16,7 @@ import com.example.fitbot.util.processing.GesturePath; import com.example.fitbot.util.processing.MotionProcessor; import com.example.fitbot.util.processing.Vector3; -public class MainScreen extends AppCompatActivity { +public class MainActivity extends AppCompatActivity { //Variables DrawerLayout drawerLayout; diff --git a/docs/documentation/research-questions/position-tracking-research.md b/docs/documentation/research-questions/position-tracking-research.md index 9aa5001..f9edfa8 100644 --- a/docs/documentation/research-questions/position-tracking-research.md +++ b/docs/documentation/research-questions/position-tracking-research.md @@ -55,7 +55,8 @@ The software of the system will consist of the following: The Wii Fit Board will be connected to Pepper using the Wiiboard-simple library. The library will be used to read the sensor data from the Wii Fit Board and transfer it to Pepper. The position tracking algorithm will process the sensor data and determine the user's position. -Challenge: +Challenge: + - Connecting to the wii fit board. It is not possible to connect directly to the Wii Fit Board, it is necessary to use a library that can interpret the data sent by the Wii Fit Board. - The Wii Fit Balance Board sends data in a specific format. To interpret this data, it's necessary to understand the format and how to convert it to a usable format. - The Wii Fit Balance Board uses Bluetooth 2.0 to communicate. Pepper uses Bluetooth 4.0 this means that there might be compatibility issues/latancy issues. @@ -79,6 +80,9 @@ To be added ## References [Wiiboard lib](https://code.google.com/archive/p/wiiboard-simple/wikis/Documentation.wiki) +https://advanti-lab.sb.dfki.de/?page_id=64 +https://github.com/paulburton/fitscales +https://github.com/micromu/WiiRemoteJ ## Appendices diff --git a/docs/teamdocumentatie/sprint-reports/sprint-report-s1.md b/docs/teamdocumentatie/sprint-reports/sprint-report-s1.md index a9120f1..61889f5 100644 --- a/docs/teamdocumentatie/sprint-reports/sprint-report-s1.md +++ b/docs/teamdocumentatie/sprint-reports/sprint-report-s1.md @@ -80,6 +80,6 @@ Wat moet er beter? Wat ging er goed? Welke SMART leerdoelen hebben jullie voor d We zijn samen gaan zitten voor de retrospective, hier uit is het volgende voort gekomen (we hebben gebruik gemaakt van the 4 L's): -![alt text](Sprint1Retro.png) +![Retro](Sprint1Retro.png) De leerdoelen zet iedereen in zijn eigen scorion formulier. \ No newline at end of file From 32020ce801b26ff3f088825817c8435a1a9bb583 Mon Sep 17 00:00:00 2001 From: SebasKoedam Date: Wed, 15 May 2024 16:42:21 +0200 Subject: [PATCH 4/4] feat: Add Java build configuration update to .vscode/settings.json --- .vscode/settings.json | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..c5f3f6b --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "java.configuration.updateBuildConfiguration": "interactive" +} \ No newline at end of file