Merge branch 'main' of https://gitlab.fdmci.hva.nl/propedeuse-hbo-ict/onderwijs/2023-2024/out-a-se-ti/blok-4/muupooviixee66
This commit is contained in:
9
.gitignore
vendored
9
.gitignore
vendored
@@ -1 +1,8 @@
|
||||
.DS_Store
|
||||
.DS_Store
|
||||
/.idea/.gitignore
|
||||
/.idea/dictionaries/lucawarm.xml
|
||||
/.idea/material_theme_project_new.xml
|
||||
/docs/documentation/assets/math-expression-location-calculation.png
|
||||
/.idea/modules.xml
|
||||
/.idea/muupooviixee66.iml
|
||||
/.idea/vcs.xml
|
||||
|
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/muupooviixee66-3.iml" filepath="$PROJECT_DIR$/.idea/muupooviixee66-3.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
9
.idea/muupooviixee66-3.iml
generated
Normal file
9
.idea/muupooviixee66-3.iml
generated
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
47
.idea/workspace.xml
generated
47
.idea/workspace.xml
generated
@@ -14,6 +14,7 @@
|
||||
</configurations>
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="00599d5b-7eb5-44da-ad7f-98bf42384c16" name="Changes" comment="Final update onderzoek-formulier.md" />
|
||||
<list default="true" id="00599d5b-7eb5-44da-ad7f-98bf42384c16" name="Changes" comment="Updated onderzoek-voorbeeld.md & motion-tracking-system-analysis.md">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/docs/documentation/research-questions/motion-tracking-system-analysis.md" beforeDir="false" afterPath="$PROJECT_DIR$/docs/documentation/research-questions/motion-tracking-system-analysis.md" afterDir="false" />
|
||||
@@ -26,6 +27,7 @@
|
||||
<component name="ClangdSettings">
|
||||
<option name="formatViaClangd" value="false" />
|
||||
</component>
|
||||
<component name="ExecutionTargetManager" SELECTED_TARGET="device_and_snapshot_combo_box_target[C:\Users\Niels\.android\avd\Pepper_1.9_API_29.avd]" />
|
||||
<component name="ExternalProjectsData">
|
||||
<projectState path="$PROJECT_DIR$">
|
||||
<ProjectState />
|
||||
@@ -73,10 +75,6 @@
|
||||
<component name="MarkdownSettingsMigration">
|
||||
<option name="stateVersion" value="1" />
|
||||
</component>
|
||||
<component name="ProjectColorInfo">{
|
||||
"customColor": "",
|
||||
"associatedIndex": 7
|
||||
}</component>
|
||||
<component name="ProjectId" id="2fE3N2CwEPDo9wBtexBLxU20tCJ" />
|
||||
<component name="ProjectLevelVcsManager">
|
||||
<ConfirmationsSetting value="2" id="Add" />
|
||||
@@ -85,6 +83,13 @@
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
|
||||
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
|
||||
<property name="RunOnceActivity.cidr.known.project.marker" value="true" />
|
||||
<property name="cidr.known.project.marker" value="true" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$/code/src/Fitbot" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
@@ -101,6 +106,13 @@
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
}
|
||||
}</component>
|
||||
<component name="PropertiesComponent">
|
||||
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
|
||||
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
|
||||
<property name="RunOnceActivity.cidr.known.project.marker" value="true" />
|
||||
<property name="cidr.known.project.marker" value="true" />
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$/code/src/Fitbot" />
|
||||
</component>
|
||||
<component name="RecentsManager">
|
||||
<key name="MoveFile.RECENT_KEYS">
|
||||
<recent name="$PROJECT_DIR$/code/src/app/src/main/java/com/fitbot" />
|
||||
@@ -115,16 +127,40 @@
|
||||
<option name="PM_INSTALL_OPTIONS" value="" />
|
||||
<option name="ALL_USERS" value="false" />
|
||||
<option name="ALWAYS_INSTALL_WITH_PM" value="false" />
|
||||
<option name="CLEAR_APP_STORAGE" value="false" />
|
||||
<option name="DYNAMIC_FEATURES_DISABLED_LIST" value="" />
|
||||
<option name="ACTIVITY_EXTRA_FLAGS" value="" />
|
||||
<option name="MODE" value="default_activity" />
|
||||
<option name="CLEAR_LOGCAT" value="false" />
|
||||
<option name="SHOW_LOGCAT_AUTOMATICALLY" value="false" />
|
||||
<option name="SKIP_NOOP_APK_INSTALLATIONS" value="true" />
|
||||
<option name="FORCE_STOP_RUNNING_APP" value="true" />
|
||||
<option name="INSPECTION_WITHOUT_ACTIVITY_RESTART" value="false" />
|
||||
<option name="TARGET_SELECTION_MODE" value="SHOW_DIALOG" />
|
||||
<option name="SELECTED_CLOUD_MATRIX_CONFIGURATION_ID" value="-1" />
|
||||
<option name="SELECTED_CLOUD_MATRIX_PROJECT_ID" value="" />
|
||||
<option name="DEBUGGER_TYPE" value="Java" />
|
||||
<Auto>
|
||||
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
|
||||
<option name="SHOW_STATIC_VARS" value="true" />
|
||||
<option name="WORKING_DIR" value="" />
|
||||
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
|
||||
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
|
||||
</Auto>
|
||||
<Hybrid>
|
||||
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
|
||||
<option name="SHOW_STATIC_VARS" value="true" />
|
||||
<option name="WORKING_DIR" value="" />
|
||||
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
|
||||
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
|
||||
</Hybrid>
|
||||
<Java />
|
||||
<Native>
|
||||
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
|
||||
<option name="SHOW_STATIC_VARS" value="true" />
|
||||
<option name="WORKING_DIR" value="" />
|
||||
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
|
||||
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
|
||||
</Native>
|
||||
<Profilers>
|
||||
<option name="ADVANCED_PROFILING_ENABLED" value="false" />
|
||||
<option name="STARTUP_PROFILING_ENABLED" value="false" />
|
||||
@@ -275,6 +311,7 @@
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
<option name="oldMeFiltersMigrated" value="true" />
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="Changes" />
|
||||
|
2
code/src/Fitbot/.gitignore
vendored
2
code/src/Fitbot/.gitignore
vendored
@@ -13,3 +13,5 @@
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
local.properties
|
||||
.idea
|
||||
.vscode
|
8
code/src/Fitbot/.idea/misc.xml
generated
8
code/src/Fitbot/.idea/misc.xml
generated
@@ -4,9 +4,17 @@
|
||||
<option name="filePathToZoomLevelMap">
|
||||
<map>
|
||||
<entry key="../../../../../../../../layout/custom_preview.xml" value="0.35989583333333336" />
|
||||
<entry key="..\:/Users/31687/muupooviixee66-1/code/src/Fitbot/app/src/main/res/drawable/button_background.xml" value="0.128" />
|
||||
<entry key="..\:/Users/31687/muupooviixee66-1/code/src/Fitbot/app/src/main/res/drawable/rectangle.xml" value="0.128" />
|
||||
<entry key="..\:/Users/31687/muupooviixee66-1/code/src/Fitbot/app/src/main/res/layout/activity_bicepvideo.xml" value="0.2015625" />
|
||||
<entry key="..\:/Users/31687/muupooviixee66-1/code/src/Fitbot/app/src/main/res/layout/activity_end_screen.xml" value="0.18" />
|
||||
<entry key="..\:/Users/31687/muupooviixee66-1/code/src/Fitbot/app/src/main/res/layout/activity_main.xml" value="0.2015625" />
|
||||
<entry key="..\:/Users/31687/muupooviixee66-1/code/src/Fitbot/app/src/main/res/layout/activity_main_screen.xml" value="0.358695652173913" />
|
||||
<entry key="..\:/Users/Niels/muupooviixee66-3/code/src/Fitbot/app/src/main/res/drawable/rectangle.xml" value="0.1665" />
|
||||
<entry key="..\:/Users/Niels/muupooviixee66-3/code/src/Fitbot/app/src/main/res/layout/activity_end_screen.xml" value="0.165" />
|
||||
<entry key="..\:/Users/Niels/muupooviixee66-3/code/src/Fitbot/app/src/main/res/layout/activity_endscreen.xml" value="0.1" />
|
||||
<entry key="..\:/Users/Niels/muupooviixee66-3/code/src/Fitbot/app/src/main/res/layout/activity_main.xml" value="0.1" />
|
||||
<entry key="..\:/Users/Niels/muupooviixee66-3/code/src/Fitbot/app/src/main/res/layout/header.xml" value="0.1234375" />
|
||||
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/drawable-v24/ic_launcher_foreground.xml" value="0.25" />
|
||||
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/drawable/darkred_button_gradient.xml" value="0.346" />
|
||||
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/drawable/ic_baseline_home_48.xml" value="0.25" />
|
||||
|
@@ -34,8 +34,13 @@ dependencies {
|
||||
implementation 'com.android.support.constraint:constraint-layout:2.0.4'
|
||||
implementation 'com.android.support:cardview-v7:28.0.0'
|
||||
implementation 'com.android.support:design:28.0.0'
|
||||
implementation 'com.android.support:support-v4:+'
|
||||
implementation 'org.joml:joml:1.10.5'
|
||||
implementation 'com.google.code.gson:gson:2.8.6'
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter'
|
||||
androidTestImplementation 'com.android.support.test:runner:1.0.2'
|
||||
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
|
||||
implementation 'com.aldebaran:qisdk:1.7.5'
|
||||
|
@@ -15,9 +15,16 @@
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.Fitbot" >
|
||||
<activity
|
||||
android:name=".EndScreenActivity"
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".ui.activities.FitnessActivity"
|
||||
android:exported="true" />
|
||||
<activity
|
||||
android:name=".ui.activities.MainActivity"
|
||||
android:exported="true" >
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
|
@@ -0,0 +1,22 @@
|
||||
package com.example.fitbot;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.widget.Button;
|
||||
|
||||
public class EndScreenActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_end_screen);
|
||||
Button homeButton = findViewById(R.id.homeButton);
|
||||
|
||||
homeButton.setOnClickListener(v -> {
|
||||
Intent intent = new Intent(EndScreenActivity.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
finish();
|
||||
});
|
||||
}
|
||||
}
|
@@ -0,0 +1,104 @@
|
||||
package com.example.fitbot.exercise;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.example.fitbot.util.path.GesturePath;
|
||||
import com.example.fitbot.util.server.IWebSocketHandler;
|
||||
import com.example.fitbot.util.server.WebSocket;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public abstract class AbstractExercise implements IWebSocketHandler {
|
||||
|
||||
private EMuscleGroup muscleGroup;
|
||||
private GesturePath path;
|
||||
|
||||
// Static fields.
|
||||
private static WebSocket webSocket;
|
||||
private static AbstractExercise currentExercise = null;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for the AbstractExercise class.
|
||||
*
|
||||
* @param muscleGroup The muscle group of the exercise.
|
||||
* @param path The path of the exercise.
|
||||
*/
|
||||
public AbstractExercise(EMuscleGroup muscleGroup, GesturePath path) {
|
||||
this.muscleGroup = muscleGroup;
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the exercise.
|
||||
* This method starts a WebSocket server
|
||||
*/
|
||||
public final void startExercise() {
|
||||
|
||||
// Ensure no other exercise is active.
|
||||
if (currentExercise != null && currentExercise != this) {
|
||||
currentExercise.__stopExercise();
|
||||
Log.i("Exercises", "Another exercise was started when another was still running.");
|
||||
}
|
||||
|
||||
// If a WebSocket server is already running, change the event handler to be this class.
|
||||
if (webSocket != null && webSocket.isConnected()) {
|
||||
webSocket.setEventHandler(this);
|
||||
}
|
||||
|
||||
try {
|
||||
webSocket = WebSocket.createServer();
|
||||
Objects.requireNonNull(webSocket, "WebSocket server could not be created.");
|
||||
|
||||
webSocket.startListening();
|
||||
webSocket.setEventHandler(this);
|
||||
currentExercise = this;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for ending this exercise and returning the grade of the performance
|
||||
* of this activity.
|
||||
*/
|
||||
public final double finishExercise() {
|
||||
this.__stopExercise();
|
||||
|
||||
// TODO: Implement grade calculation
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stop the exercise.
|
||||
* This method stops the WebSocket server.
|
||||
*/
|
||||
private void __stopExercise() {
|
||||
if (webSocket != null && webSocket.isConnected()) {
|
||||
webSocket.stop();
|
||||
webSocket = null;
|
||||
}
|
||||
currentExercise = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the current exercise is the current activity.
|
||||
*/
|
||||
public final boolean isCurrentActivity() {
|
||||
return currentExercise == this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the muscle group of the exercise.
|
||||
*/
|
||||
public EMuscleGroup getMuscleGroup() {
|
||||
return muscleGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the path of the exercise.
|
||||
*/
|
||||
public GesturePath getPath() {
|
||||
return path;
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
package com.example.fitbot.exercise;
|
||||
|
||||
public enum EMuscleGroup {
|
||||
// TODO: Implement
|
||||
|
||||
TORSO(0),
|
||||
ARMS(1),
|
||||
LEGS(2),
|
||||
BALANCE(3);
|
||||
|
||||
int muscleGroupIdentifier;
|
||||
|
||||
EMuscleGroup(int identifier) {
|
||||
this.muscleGroupIdentifier = identifier;
|
||||
}
|
||||
|
||||
public int getIdentifier() {
|
||||
return this.muscleGroupIdentifier;
|
||||
}
|
||||
|
||||
public static EMuscleGroup parse(int identifier) {
|
||||
for (EMuscleGroup muscleGroup : EMuscleGroup.values()) {
|
||||
if (muscleGroup.getIdentifier() == identifier) {
|
||||
return muscleGroup;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
package com.example.fitbot.exercise;
|
||||
|
||||
|
||||
/**
|
||||
* The ExerciseUser class represents a user of the exercise application.
|
||||
* This contains all necessary information of the current user.
|
||||
*/
|
||||
public class ExerciseUser {
|
||||
|
||||
public float upperArmLength;
|
||||
public float lowerArmLength;
|
||||
public float upperLegLength;
|
||||
public float lowerLegLength;
|
||||
public float height;
|
||||
|
||||
/**
|
||||
* Constructor for the ExerciseUser class.
|
||||
* @param upperArmLength The length of the upper arm.
|
||||
* @param lowerArmLength The length of the lower arm.
|
||||
* @param height The height of the user.
|
||||
* @param upperLegLength The length of the upper leg.
|
||||
* @param lowerLegLength The length of the lower leg.
|
||||
*/
|
||||
public ExerciseUser(float upperArmLength, float lowerArmLength, float height, float upperLegLength, float lowerLegLength) {
|
||||
this.upperArmLength = upperArmLength;
|
||||
this.lowerArmLength = lowerArmLength;
|
||||
this.upperLegLength = upperLegLength;
|
||||
this.lowerLegLength = lowerLegLength;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for the ExerciseUser class.
|
||||
* @param height The height of the user.
|
||||
*/
|
||||
public ExerciseUser(float height) {
|
||||
this.height = height;
|
||||
this.upperArmLength = height * 0.2f;
|
||||
this.lowerArmLength = height * 0.2f;
|
||||
this.upperLegLength = height * 0.3f;
|
||||
this.lowerLegLength = height * 0.3f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default constructor for the ExerciseUser class.
|
||||
* This sets the default height to 180.0f. (1.80m)
|
||||
*/
|
||||
public ExerciseUser() {
|
||||
this(180.0f);
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,113 @@
|
||||
package com.example.fitbot.exercise;
|
||||
|
||||
import com.example.fitbot.util.path.GesturePath;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
import org.joml.Vector3f;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
public class FitnessManager {
|
||||
|
||||
private static final String HOST_ADDRESS = "http://145.92.8.132";
|
||||
|
||||
private static final String PROPERTY_DESC = "description";
|
||||
private static final String PROPERTY_VECTORS = "vector_data";
|
||||
private static final String PROPERTY_NAME = "name";
|
||||
private static final String PROPERTY_MUSCLE_GROUP = "muscle_group";
|
||||
|
||||
private static String sendHTTP(String url, String method, String contentType, String body) {
|
||||
try {
|
||||
URLConnection connection = new URL(url).openConnection();
|
||||
connection.addRequestProperty("Content-Type", contentType);
|
||||
connection.addRequestProperty("Request-Method", method);
|
||||
connection.getOutputStream().write(body.getBytes());
|
||||
connection.connect();
|
||||
InputStream stream = connection.getInputStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
builder.append(line);
|
||||
}
|
||||
return builder.toString();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for retrieving an exercise from the Raspberry Pi Database.
|
||||
*
|
||||
* @param uniqueIdentifier The unique identifier of the exercise
|
||||
* @return The exercise, if it exists on the server. Otherwise null.
|
||||
*/
|
||||
public static <T extends AbstractExercise> AbstractExercise acquireExercise(String uniqueIdentifier, Class<T> referenceClass) {
|
||||
String response = sendHTTP(
|
||||
HOST_ADDRESS + "/acquire", "GET", "application/json", "{\"kind\":\"" + uniqueIdentifier + "\"}"
|
||||
);
|
||||
// Validate the response
|
||||
if (response != null) {
|
||||
try {
|
||||
JsonObject content = JsonParser.parseString(response).getAsJsonObject();
|
||||
Constructor<T> constructor = referenceClass.getConstructor(referenceClass);
|
||||
T instance = null;
|
||||
try {
|
||||
instance = constructor.newInstance(
|
||||
EMuscleGroup.parse(content.get(PROPERTY_MUSCLE_GROUP).getAsInt()),
|
||||
gesturePathFromString(content.get(PROPERTY_VECTORS).getAsString())
|
||||
);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return instance;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for converting a string to a GesturePath object.
|
||||
* The input string bytes will be directly converted into 3d vectors.
|
||||
* Every coordinate is composed of 32 bits, so four characters per coordinate.
|
||||
*
|
||||
* @param input The string to convert
|
||||
* @return The GesturePath object
|
||||
*/
|
||||
private static GesturePath gesturePathFromString(String input) {
|
||||
byte[] bytes = input.getBytes();
|
||||
|
||||
// Check if the input string contains a valid amount of bytes (12 bytes per vector)
|
||||
if (input.length() % 12 != 0) {
|
||||
throw new IllegalArgumentException("Invalid input string length");
|
||||
}
|
||||
GesturePath.Builder builder = new GesturePath.Builder();
|
||||
|
||||
float[] xyz = new float[3];
|
||||
for (int i = 0; i < bytes.length; i += 12) {
|
||||
for (int j = 0; j < 3; j++) {
|
||||
xyz[j] = Float.intBitsToFloat(
|
||||
(bytes[i + j * 4] & 0xFF) << 24 |
|
||||
(bytes[i + j * 4 + 1] & 0xFF) << 16 |
|
||||
(bytes[i + j * 4 + 2] & 0xFF) << 8 |
|
||||
(bytes[i + j * 4 + 3] & 0xFF)
|
||||
);
|
||||
}
|
||||
builder.addVector(new Vector3f(
|
||||
xyz[0], xyz[1], xyz[2]
|
||||
));
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
package com.example.fitbot.sports;
|
||||
|
||||
public enum ESportType {
|
||||
|
||||
FITNESS("Fitness"),
|
||||
POWER("Krachttrening");
|
||||
|
||||
private final String name;
|
||||
|
||||
ESportType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
@@ -1,6 +1,7 @@
|
||||
package com.example.fitbot.ui.activities;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.design.widget.NavigationView;
|
||||
import android.support.v4.view.GravityCompat;
|
||||
@@ -8,6 +9,8 @@ import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v7.app.ActionBarDrawerToggle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.Log;
|
||||
import android.widget.Button;
|
||||
|
||||
import com.example.fitbot.R;
|
||||
|
||||
@@ -17,17 +20,26 @@ public class MainActivity extends AppCompatActivity {
|
||||
DrawerLayout drawerLayout;
|
||||
NavigationView navigationView;
|
||||
Toolbar toolbar;
|
||||
Button startButton;
|
||||
|
||||
@SuppressLint("WrongViewCast")
|
||||
@Override
|
||||
protected void onCreate (Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
setContentView(R.layout.activity_main );
|
||||
|
||||
/*---Hooks---*/
|
||||
drawerLayout = findViewById(R.id.drawer_layout);
|
||||
navigationView = findViewById(R.id.nav_view);
|
||||
toolbar = findViewById(R.id.toolbar);
|
||||
startButton = findViewById(R.id.startButton);
|
||||
|
||||
startButton.setOnClickListener(v -> {
|
||||
// Switch to fitness activity
|
||||
Log.i("MainActivity", "Switching to FitnessActivity");
|
||||
Intent intent = new Intent(MainActivity.this, FitnessActivity.class);
|
||||
startActivity(intent);
|
||||
});
|
||||
|
||||
/*---Tool Bar---*/
|
||||
// setSupportActionBar(toolbar);
|
||||
|
@@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import com.example.fitbot.util.path.GesturePath;
|
||||
@@ -24,6 +25,8 @@ public class PersonalMotionPreviewElement extends View {
|
||||
private Path referencePath, performingPath;
|
||||
private Paint referencePaint, performingPaint;
|
||||
|
||||
private Paint backgroundColor = new Paint();
|
||||
|
||||
/**
|
||||
* Constants for the preview path projection.
|
||||
*/
|
||||
@@ -42,6 +45,9 @@ public class PersonalMotionPreviewElement extends View {
|
||||
*/
|
||||
public PersonalMotionPreviewElement(Context context, GesturePath path) {
|
||||
super(context);
|
||||
Log.i("PersonalMotionPreviewElement", "Creating new PersonalMotionPreviewElement.");
|
||||
this.backgroundColor = new Paint();
|
||||
this.backgroundColor.setColor(0xFF000000); // Black
|
||||
this.path = path;
|
||||
this.motionProcessor = new MotionProcessor();
|
||||
this.motionProcessor.startListening();
|
||||
@@ -158,6 +164,7 @@ public class PersonalMotionPreviewElement extends View {
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas) {
|
||||
canvas.drawRect(0, 0, getWidth(), getHeight(), backgroundColor);
|
||||
// Draw the sport preview canvas
|
||||
canvas.drawPath(referencePath, referencePaint);
|
||||
canvas.drawPath(performingPath, performingPaint);
|
||||
|
@@ -10,7 +10,6 @@ public class GesturePath {
|
||||
|
||||
// The vectors that make up the path.
|
||||
private final PathSegment[] segments;
|
||||
private double curvature;
|
||||
|
||||
public GesturePath(Vector3f[] vectors) {
|
||||
this(vectors, 0.0D);
|
||||
@@ -27,7 +26,6 @@ public class GesturePath {
|
||||
if ( vectors.length < 2)
|
||||
throw new IllegalArgumentException("A path must have at least two points.");
|
||||
|
||||
this.curvature = curvature;
|
||||
this.segments = new PathSegment[vectors.length - 1];
|
||||
for ( int i = 0; i < vectors.length - 1; i++)
|
||||
segments[i] = new PathSegment(vectors[i], vectors[i + 1]);
|
||||
@@ -39,7 +37,6 @@ public class GesturePath {
|
||||
*/
|
||||
public GesturePath(PathSegment... segments) {
|
||||
this.segments = segments;
|
||||
this.curvature = 0.0d;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -25,10 +25,9 @@ public class PathSegment {
|
||||
* depending on the curvature of the curve. If the curvature is unset, or set to 0
|
||||
* then this method will use linear interpolation. Otherwise, it will use a curve.
|
||||
*
|
||||
* @param dst The destination vector to interpolate to.
|
||||
* @param t The interpolation value between 0 and 1.
|
||||
*/
|
||||
public Vector3f interpolate(Vector3f dst, double t) {
|
||||
public Vector3f interpolate(double t) {
|
||||
return new Vector3f(this.start)
|
||||
.lerp(this.end, (float) Math.min(1.0F, Math.max(0.0F, t)));
|
||||
}
|
||||
|
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#F0E4E4" />
|
||||
<corners android:radius="15dp" />
|
||||
|
||||
</shape>
|
10
code/src/Fitbot/app/src/main/res/drawable/rectangle.xml
Normal file
10
code/src/Fitbot/app/src/main/res/drawable/rectangle.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/listview_background_shape">
|
||||
<stroke android:width="2dp" android:color="#ff207d94" />
|
||||
<padding android:left="2dp"
|
||||
android:top="2dp"
|
||||
android:right="2dp"
|
||||
android:bottom="2dp" />
|
||||
<corners android:radius="45dp" />
|
||||
<solid android:color="#F0F0F0" />
|
||||
</shape>
|
@@ -0,0 +1,79 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:background="@color/red"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".EndScreenActivity">
|
||||
|
||||
<View
|
||||
android:id="@+id/myRectangleView"
|
||||
android:layout_width="720dp"
|
||||
android:layout_height="270dp"
|
||||
android:layout_marginStart="320dp"
|
||||
android:layout_marginTop="25dp"
|
||||
android:layout_marginEnd="320dp"
|
||||
android:layout_marginBottom="25dp"
|
||||
android:background="@drawable/rectangle"
|
||||
app:layout_constraintBottom_toTopOf="@+id/homeButton"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/homeButton"
|
||||
style="@style/ButtonStyle"
|
||||
android:layout_width="278dp"
|
||||
android:layout_height="117dp"
|
||||
android:layout_marginStart="501dp"
|
||||
android:layout_marginTop="25dp"
|
||||
android:layout_marginEnd="501dp"
|
||||
android:layout_marginBottom="50dp"
|
||||
android:text="Home"
|
||||
app:layout_constraintBottom_toTopOf="@+id/continueButton"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/myRectangleView" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/continueButton"
|
||||
style="@style/ButtonStyle"
|
||||
android:layout_width="280dp"
|
||||
android:layout_height="120dp"
|
||||
android:layout_marginStart="500dp"
|
||||
android:layout_marginTop="25dp"
|
||||
android:layout_marginEnd="500dp"
|
||||
android:layout_marginBottom="140dp"
|
||||
android:text="Continue"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/homeButton" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gefeliciteerdText"
|
||||
style="@style/TextStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="539dp"
|
||||
android:layout_marginEnd="533dp"
|
||||
android:text="Gefeliciteerd"
|
||||
app:layout_constraintBottom_toTopOf="@+id/workoutText"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.0"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/myRectangleView" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/workoutText"
|
||||
style="@style/TextStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="u heeft de work out voltooid"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/myRectangleView"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/myRectangleView" />
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
@@ -1,10 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/drawer_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#232323"
|
||||
android:fitsSystemWindows="true"
|
||||
tools:context=".ui.activities.FitnessActivity"
|
||||
tools:openDrawer="start">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.example.fitbot.ui.components.PersonalMotionPreviewElement
|
||||
android:id="@+id/personalMotionPreviewElement"
|
||||
android:visibility="visible"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
</android.support.constraint.ConstraintLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.v4.widget.DrawerLayout>
|
@@ -9,4 +9,6 @@
|
||||
<string name="start">Start</string>
|
||||
<string name="help">Help</string>
|
||||
<string name="todo">TODO</string>
|
||||
<color name="red">#f22b1d</color>
|
||||
|
||||
</resources>
|
@@ -5,5 +5,24 @@
|
||||
<item name="android:statusBarColor">#00000000</item>
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowNoTitle">true</item>
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
<style name="ButtonStyle">
|
||||
<item name="android:textSize">24sp</item>
|
||||
<item name="android:textColor">#000000</item>
|
||||
<item name="android:background">@drawable/button_background</item>
|
||||
<item name= "android:textStyle">bold</item>
|
||||
<item name="android:padding">16dp</item>
|
||||
<item name="android:layout_margin">8dp</item>
|
||||
</style>
|
||||
|
||||
<style name="TextStyle">
|
||||
<item name="android:textSize">36sp</item>
|
||||
<item name="android:textColor">#000000</item>
|
||||
<item name= "android:textStyle">bold</item>
|
||||
</style>
|
||||
|
||||
|
||||
</resources>
|
@@ -6,5 +6,9 @@
|
||||
<item name="colorPrimaryDark">@color/purple_700</item>
|
||||
<item name="colorAccent">@color/teal_200</item>
|
||||
<!-- Customize your theme here. -->
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- Style for general buttons -->
|
||||
</resources>
|
||||
</style>
|
||||
</resources>
|
@@ -0,0 +1,37 @@
|
||||
package com.example.fitbot;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.example.fitbot.util.path.GesturePath;
|
||||
import com.example.fitbot.util.path.PathSegment;
|
||||
|
||||
import org.joml.Vector3f;
|
||||
import org.junit.Test;
|
||||
|
||||
public class PathSegmentTest {
|
||||
|
||||
@Test
|
||||
public void testPathSegment() {
|
||||
// Test the PathSegment class
|
||||
Vector3f[] vectors = new Vector3f[2];
|
||||
vectors[0] = new Vector3f(0, 0, 0);
|
||||
vectors[1] = new Vector3f(1, 1, 1);
|
||||
GesturePath path = new GesturePath(vectors);
|
||||
PathSegment[] segments = path.getSegments();
|
||||
assertEquals(1, segments.length);
|
||||
assertEquals(new Vector3f(0, 0, 0), segments[0].getStart());
|
||||
assertEquals(new Vector3f(1, 1, 1), segments[0].getEnd());
|
||||
assertEquals(new Vector3f(0.5f, 0.5f, 0.5f), segments[0].interpolate(0.5));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test_pathSegmentInterpolation() {
|
||||
Vector3f start = new Vector3f(0, 0, 0);
|
||||
Vector3f end = new Vector3f(1, 1, 1);
|
||||
PathSegment segment = new PathSegment(start, end);
|
||||
assertEquals(new Vector3f(0.5f, 0.5f, 0.5f), segment.interpolate(0.5));
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
# Creating Styles in android
|
||||
|
||||
Styles and themes on Android make it possible for you to separate the details of our app design from the UI structure and behavior, identical to stylesheets in web design. We will use this in our project to maintain a consistent style, so that we won't have to hardcode it to each element. A style is a set of attributes that determine the appearance of a single View. A style can define features like font color, font size, background color, and a lot more.
|
||||
|
||||
To make a style you want to navigate to res/values/styles.xml in this file you can make styles. Fot this example we will make a buttonstyle that we can implement across multiple buttons. To make a style you need to add this code to your style.xml file
|
||||
|
||||
```xml
|
||||
|
||||
<resources>
|
||||
<style name="ButtonStyle">
|
||||
|
||||
</style>
|
||||
</resources>
|
||||
|
||||
```
|
||||
After that, you may add your styling items in the code.
|
||||
|
||||
|
||||
```xml
|
||||
<style name="ButtonStyle">
|
||||
<item name="android:textSize">24sp</item>
|
||||
<item name="android:textColor">#000000</item>
|
||||
<item name="android:background">#F0F0F0</item>
|
||||
<item name= "android:textStyle">bold</item>
|
||||
<item name="android:padding">16dp</item>
|
||||
<item name="android:layout_margin">8dp</item>
|
||||
</style>
|
||||
```
|
||||
If you have done this, return to your activity.xml file and add the style element to your object. You will need to connect your style to the element.
|
||||
```xml
|
||||
<Button
|
||||
android:id="@+id/homeButton"
|
||||
style="@style/ButtonStyle"/>
|
||||
```
|
||||
You can now add this to multiple buttons to keep the same style and avoid copying and pasting the same feature
|
@@ -15,8 +15,9 @@ public class MyClass {
|
||||
Then in a class you can have Methods or Atributes where the actual code is.
|
||||
|
||||
```mermaid
|
||||
flowchart
|
||||
a[Access Modifiers] --> b[class] --> c[Class name]
|
||||
flowchart LR
|
||||
0[~] --> a([Access Modifiers]) --> b([class]) --> c([Class name])
|
||||
0 --> b
|
||||
```
|
||||
|
||||
## Constructor
|
||||
@@ -29,8 +30,11 @@ A method is a block of code which only runs when it is called. You can pass data
|
||||
|
||||
Methods are build like this
|
||||
```mermaid
|
||||
flowchart
|
||||
A[Access Modifiers] --> B[Method Modifier] --> C[Return Type] --> D[Method Name] --> E[Parameters] --> F[Method Body]
|
||||
flowchart LR
|
||||
0([~]) --> A([Access Modifiers]) --> B([Method Modifier]) --> C([Return Type]) --> D([Method Name]) --> E([Parameters]) --> F([Method Body])
|
||||
A --> C
|
||||
0 --> C
|
||||
D --> F
|
||||
```
|
||||
|
||||
|
||||
|
@@ -3,11 +3,11 @@
|
||||
Which sensor are we gonna use for this project and why?
|
||||
|
||||
|
||||
### What do we wanna measure?
|
||||
### What do we want to measure?
|
||||
|
||||
We wanna measure the movement of the people doing our exercises. We want to know how many times they have done the exercise and how many times they have done it correctly.
|
||||
|
||||
### What sensor are we gonna use?
|
||||
### What sensor are we going to use?
|
||||
To measure these movements we are gonna use gyroscopes. With gyroscopes we can measure the rotation of the body. With some math we can also measure the speed of the rotation. So we know how fast the person is doing the exercise.
|
||||
|
||||
### Which gyroscopes are there?
|
||||
|
Reference in New Issue
Block a user