Merge branch 'main' of ssh://gitlab.fdmci.hva.nl/propedeuse-hbo-ict/onderwijs/2023-2024/out-a-se-ti/blok-4/muupooviixee66
This commit is contained in:
2
code/src/Fitbot/.idea/misc.xml
generated
2
code/src/Fitbot/.idea/misc.xml
generated
@@ -4,6 +4,8 @@
|
|||||||
<option name="filePathToZoomLevelMap">
|
<option name="filePathToZoomLevelMap">
|
||||||
<map>
|
<map>
|
||||||
<entry key="../../../../../../../../layout/custom_preview.xml" value="0.35989583333333336" />
|
<entry key="../../../../../../../../layout/custom_preview.xml" value="0.35989583333333336" />
|
||||||
|
<entry key="../../../../../../.gradle/caches/transforms-3/9c4b978f8e84c8bb9ebef5f19e8c189e/transformed/qisdk-design-1.7.5/res/layout/activity_robot.xml" value="0.1" />
|
||||||
|
<entry key="../../../../../../.gradle/caches/transforms-3/9c4b978f8e84c8bb9ebef5f19e8c189e/transformed/qisdk-design-1.7.5/res/layout/view_always_top_speech_bar.xml" value="0.167877197265625" />
|
||||||
<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/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/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_bicepvideo.xml" value="0.2015625" />
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
android:theme="@style/Theme.Fitbot" >
|
android:theme="@style/AppTheme" >
|
||||||
<activity
|
<activity
|
||||||
android:name=".ui.activities.EndScreenActivity"
|
android:name=".ui.activities.EndScreenActivity"
|
||||||
android:exported="false" />
|
android:exported="false" />
|
||||||
|
@@ -14,7 +14,7 @@ import java.lang.reflect.Constructor;
|
|||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
|
|
||||||
public class FitnessManager {
|
public class ExerciseManager {
|
||||||
|
|
||||||
private static final String HOST_ADDRESS = "http://145.92.8.132";
|
private static final String HOST_ADDRESS = "http://145.92.8.132";
|
||||||
|
|
||||||
@@ -22,7 +22,20 @@ public class FitnessManager {
|
|||||||
private static final String PROPERTY_VECTORS = "vector_data";
|
private static final String PROPERTY_VECTORS = "vector_data";
|
||||||
private static final String PROPERTY_NAME = "name";
|
private static final String PROPERTY_NAME = "name";
|
||||||
private static final String PROPERTY_MUSCLE_GROUP = "muscle_group";
|
private static final String PROPERTY_MUSCLE_GROUP = "muscle_group";
|
||||||
|
private static final String PROPERTY_SEGMENT_SPEED = "segment_speed";
|
||||||
|
|
||||||
|
private static final float DEFAULT_SEGMENT_SPEED = 1.0f;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function for sending an HTTP request to the server.
|
||||||
|
*
|
||||||
|
* @param url The URL to send the request to.
|
||||||
|
* @param method The method to use for the request, e.g. GET or POST.
|
||||||
|
* @param contentType The content type of the request.
|
||||||
|
* @param body The body of the request.
|
||||||
|
*
|
||||||
|
* @return The response from the server.
|
||||||
|
*/
|
||||||
private static String sendHTTP(String url, String method, String contentType, String body) {
|
private static String sendHTTP(String url, String method, String contentType, String body) {
|
||||||
try {
|
try {
|
||||||
URLConnection connection = new URL(url).openConnection();
|
URLConnection connection = new URL(url).openConnection();
|
||||||
@@ -50,7 +63,7 @@ public class FitnessManager {
|
|||||||
* @param uniqueIdentifier The unique identifier of the exercise
|
* @param uniqueIdentifier The unique identifier of the exercise
|
||||||
* @return The exercise, if it exists on the server. Otherwise null.
|
* @return The exercise, if it exists on the server. Otherwise null.
|
||||||
*/
|
*/
|
||||||
public static <T extends Exercise> Exercise acquireExercise(String uniqueIdentifier, Class<T> referenceClass) {
|
public static Exercise retrieveExercise(String uniqueIdentifier) {
|
||||||
String response = sendHTTP(
|
String response = sendHTTP(
|
||||||
HOST_ADDRESS + "/acquire", "GET", "application/json", "{\"kind\":\"" + uniqueIdentifier + "\"}"
|
HOST_ADDRESS + "/acquire", "GET", "application/json", "{\"kind\":\"" + uniqueIdentifier + "\"}"
|
||||||
);
|
);
|
||||||
@@ -58,17 +71,13 @@ public class FitnessManager {
|
|||||||
if (response != null) {
|
if (response != null) {
|
||||||
try {
|
try {
|
||||||
JsonObject content = JsonParser.parseString(response).getAsJsonObject();
|
JsonObject content = JsonParser.parseString(response).getAsJsonObject();
|
||||||
Constructor<T> constructor = referenceClass.getConstructor(referenceClass);
|
return new Exercise(
|
||||||
T instance = null;
|
EMuscleGroup.parse(content.get(PROPERTY_MUSCLE_GROUP).getAsInt()),
|
||||||
try {
|
content.get(PROPERTY_NAME).getAsString(),
|
||||||
instance = constructor.newInstance(
|
content.get(PROPERTY_DESC).getAsString(),
|
||||||
EMuscleGroup.parse(content.get(PROPERTY_MUSCLE_GROUP).getAsInt()),
|
gesturePathFromString(content.get(PROPERTY_VECTORS).getAsString()),
|
||||||
gesturePathFromString(content.get(PROPERTY_VECTORS).getAsString())
|
DEFAULT_SEGMENT_SPEED
|
||||||
);
|
);
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return instance;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -79,7 +88,9 @@ public class FitnessManager {
|
|||||||
/**
|
/**
|
||||||
* Function for converting a string to a GesturePath object.
|
* Function for converting a string to a GesturePath object.
|
||||||
* The input string bytes will be directly converted into 3d vectors.
|
* The input string bytes will be directly converted into 3d vectors.
|
||||||
* Every coordinate is composed of 32 bits, so four characters per coordinate.
|
* Every scalar is composed of 32 bits (4 characters), meaning 96 bits per vector.
|
||||||
|
*
|
||||||
|
* Note: ASCII to Vector conversion is done in Big Endian format (most significant byte first).
|
||||||
*
|
*
|
||||||
* @param input The string to convert
|
* @param input The string to convert
|
||||||
* @return The GesturePath object
|
* @return The GesturePath object
|
||||||
@@ -96,6 +107,7 @@ public class FitnessManager {
|
|||||||
float[] xyz = new float[3];
|
float[] xyz = new float[3];
|
||||||
for (int i = 0; i < bytes.length; i += 12) {
|
for (int i = 0; i < bytes.length; i += 12) {
|
||||||
for (int j = 0; j < 3; j++) {
|
for (int j = 0; j < 3; j++) {
|
||||||
|
|
||||||
xyz[j] = Float.intBitsToFloat(
|
xyz[j] = Float.intBitsToFloat(
|
||||||
(bytes[i + j * 4] & 0xFF) << 24 |
|
(bytes[i + j * 4] & 0xFF) << 24 |
|
||||||
(bytes[i + j * 4 + 1] & 0xFF) << 16 |
|
(bytes[i + j * 4 + 1] & 0xFF) << 16 |
|
@@ -11,6 +11,7 @@ import com.aldebaran.qi.sdk.QiContext;
|
|||||||
import com.aldebaran.qi.sdk.QiSDK;
|
import com.aldebaran.qi.sdk.QiSDK;
|
||||||
import com.aldebaran.qi.sdk.RobotLifecycleCallbacks;
|
import com.aldebaran.qi.sdk.RobotLifecycleCallbacks;
|
||||||
import com.aldebaran.qi.sdk.design.activity.RobotActivity;
|
import com.aldebaran.qi.sdk.design.activity.RobotActivity;
|
||||||
|
import com.aldebaran.qi.sdk.design.activity.conversationstatus.SpeechBarDisplayStrategy;
|
||||||
import com.example.fitbot.R;
|
import com.example.fitbot.R;
|
||||||
import com.example.fitbot.sports.Animations;
|
import com.example.fitbot.sports.Animations;
|
||||||
import com.example.fitbot.ui.components.PersonalMotionPreviewElement;
|
import com.example.fitbot.ui.components.PersonalMotionPreviewElement;
|
||||||
@@ -29,6 +30,8 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
|
|||||||
// Set the content view to the appropriate layout
|
// Set the content view to the appropriate layout
|
||||||
setContentView(R.layout.activity_fitness);
|
setContentView(R.layout.activity_fitness);
|
||||||
|
|
||||||
|
setSpeechBarDisplayStrategy(SpeechBarDisplayStrategy.IMMERSIVE);
|
||||||
|
|
||||||
|
|
||||||
// Find the VideoView by its ID
|
// Find the VideoView by its ID
|
||||||
VideoView videoView = findViewById(R.id.videoView);
|
VideoView videoView = findViewById(R.id.videoView);
|
||||||
|
@@ -9,6 +9,7 @@ import android.util.Log;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import com.example.fitbot.exercise.Exercise;
|
import com.example.fitbot.exercise.Exercise;
|
||||||
|
import com.example.fitbot.speech.SpeechGenerator;
|
||||||
import com.example.fitbot.util.path.GesturePath;
|
import com.example.fitbot.util.path.GesturePath;
|
||||||
import com.example.fitbot.util.path.PathSegment;
|
import com.example.fitbot.util.path.PathSegment;
|
||||||
import com.example.fitbot.util.processing.MotionData;
|
import com.example.fitbot.util.processing.MotionData;
|
||||||
@@ -35,6 +36,14 @@ public class PersonalMotionPreviewElement extends View {
|
|||||||
private Paint performingPaint;
|
private Paint performingPaint;
|
||||||
private Paint textPaint;
|
private Paint textPaint;
|
||||||
|
|
||||||
|
private static final String[] activityPhrases = {
|
||||||
|
"Goed bezig!",
|
||||||
|
"Hou vol!",
|
||||||
|
"Je bent er bijna!",
|
||||||
|
"Zet 'm op!",
|
||||||
|
"Je kan het!"
|
||||||
|
};
|
||||||
|
|
||||||
// Matrices for the projection of the path segments onto the screen.
|
// Matrices for the projection of the path segments onto the screen.
|
||||||
// Depth buffering sadly is not supported yet due to brain dysfunction
|
// Depth buffering sadly is not supported yet due to brain dysfunction
|
||||||
private Matrix4f modelViewMatrix = new Matrix4f();
|
private Matrix4f modelViewMatrix = new Matrix4f();
|
||||||
|
@@ -11,17 +11,6 @@ android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
|
|||||||
tools:context=".ui.activities.FitnessActivity"
|
tools:context=".ui.activities.FitnessActivity"
|
||||||
tools:openDrawer="start">
|
tools:openDrawer="start">
|
||||||
|
|
||||||
<!-- <com.example.fitbot.ui.components.PersonalMotionPreviewElement-->
|
|
||||||
<!-- android:id="@+id/personalMotionPreviewElement"-->
|
|
||||||
<!-- android:layout_width="600dp"-->
|
|
||||||
<!-- android:layout_height="550dp"-->
|
|
||||||
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
|
|
||||||
<!-- app:layout_constraintEnd_toEndOf="parent"-->
|
|
||||||
<!-- app:layout_constraintHorizontal_bias="0.976"-->
|
|
||||||
<!-- app:layout_constraintStart_toStartOf="parent"-->
|
|
||||||
<!-- app:layout_constraintTop_toTopOf="parent"-->
|
|
||||||
<!-- app:layout_constraintVertical_bias="0.064" />-->
|
|
||||||
|
|
||||||
<VideoView
|
<VideoView
|
||||||
android:id="@+id/videoView"
|
android:id="@+id/videoView"
|
||||||
android:layout_width="450dp"
|
android:layout_width="450dp"
|
||||||
|
@@ -2,11 +2,8 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<!-- Base application theme. -->
|
<!-- Base application theme. -->
|
||||||
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
|
||||||
<item name="android:statusBarColor">#00000000</item>
|
|
||||||
<item name="windowActionBar">false</item>
|
<item name="windowActionBar">false</item>
|
||||||
<item name="windowNoTitle">true</item>
|
<item name="windowNoTitle">true</item>
|
||||||
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="ButtonStyle">
|
<style name="ButtonStyle">
|
||||||
|
Reference in New Issue
Block a user