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:
Niels Gras
2024-05-24 12:04:45 +02:00
7 changed files with 41 additions and 29 deletions

View File

@@ -4,6 +4,8 @@
<option name="filePathToZoomLevelMap">
<map>
<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/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" />

View File

@@ -20,7 +20,7 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Fitbot" >
android:theme="@style/AppTheme" >
<activity
android:name=".ui.activities.EndScreenActivity"
android:exported="false" />

View File

@@ -14,7 +14,7 @@ import java.lang.reflect.Constructor;
import java.net.URL;
import java.net.URLConnection;
public class FitnessManager {
public class ExerciseManager {
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_NAME = "name";
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) {
try {
URLConnection connection = new URL(url).openConnection();
@@ -50,7 +63,7 @@ public class FitnessManager {
* @param uniqueIdentifier The unique identifier of the exercise
* @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(
HOST_ADDRESS + "/acquire", "GET", "application/json", "{\"kind\":\"" + uniqueIdentifier + "\"}"
);
@@ -58,20 +71,16 @@ public class FitnessManager {
if (response != null) {
try {
JsonObject content = JsonParser.parseString(response).getAsJsonObject();
Constructor<T> constructor = referenceClass.getConstructor(referenceClass);
T instance = null;
try {
instance = constructor.newInstance(
return new Exercise(
EMuscleGroup.parse(content.get(PROPERTY_MUSCLE_GROUP).getAsInt()),
gesturePathFromString(content.get(PROPERTY_VECTORS).getAsString())
content.get(PROPERTY_NAME).getAsString(),
content.get(PROPERTY_DESC).getAsString(),
gesturePathFromString(content.get(PROPERTY_VECTORS).getAsString()),
DEFAULT_SEGMENT_SPEED
);
} catch (Exception e) {
e.printStackTrace();
}
return instance;
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
@@ -79,7 +88,9 @@ public class FitnessManager {
/**
* 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.
* 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
* @return The GesturePath object
@@ -96,6 +107,7 @@ public class FitnessManager {
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 |

View File

@@ -11,6 +11,7 @@ import com.aldebaran.qi.sdk.QiContext;
import com.aldebaran.qi.sdk.QiSDK;
import com.aldebaran.qi.sdk.RobotLifecycleCallbacks;
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.sports.Animations;
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
setContentView(R.layout.activity_fitness);
setSpeechBarDisplayStrategy(SpeechBarDisplayStrategy.IMMERSIVE);
// Find the VideoView by its ID
VideoView videoView = findViewById(R.id.videoView);

View File

@@ -9,6 +9,7 @@ import android.util.Log;
import android.view.View;
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.PathSegment;
import com.example.fitbot.util.processing.MotionData;
@@ -35,6 +36,14 @@ public class PersonalMotionPreviewElement extends View {
private Paint performingPaint;
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.
// Depth buffering sadly is not supported yet due to brain dysfunction
private Matrix4f modelViewMatrix = new Matrix4f();

View File

@@ -11,17 +11,6 @@ android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
tools:context=".ui.activities.FitnessActivity"
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
android:id="@+id/videoView"
android:layout_width="450dp"

View File

@@ -2,11 +2,8 @@
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:statusBarColor">#00000000</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="ButtonStyle">