Fixed more shit
This commit is contained in:
@@ -3,8 +3,6 @@ package com.example.fitbot.ui.activities;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.MediaController;
|
||||
import android.widget.VideoView;
|
||||
|
||||
import com.aldebaran.qi.sdk.QiContext;
|
||||
@@ -13,15 +11,18 @@ 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.exercise.EMuscleGroup;
|
||||
import com.example.fitbot.exercise.Exercise;
|
||||
import com.example.fitbot.ui.components.PersonalMotionPreviewElement;
|
||||
import com.example.fitbot.util.Animations;
|
||||
import com.example.fitbot.util.ButtonNavigation;
|
||||
import com.example.fitbot.util.path.GesturePath;
|
||||
|
||||
import org.joml.Vector3f;
|
||||
|
||||
public class FitnessActivity extends RobotActivity implements RobotLifecycleCallbacks {
|
||||
|
||||
// PersonalMotionPreviewElement personalMotionPreviewElement;
|
||||
PersonalMotionPreviewElement personalMotionPreviewElement;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
@@ -30,9 +31,9 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
|
||||
// Set the content view to the appropriate layout
|
||||
setContentView(R.layout.activity_fitness);
|
||||
|
||||
// Remove the ugly ass bar on top of the view
|
||||
setSpeechBarDisplayStrategy(SpeechBarDisplayStrategy.IMMERSIVE);
|
||||
|
||||
|
||||
// Find the VideoView by its ID
|
||||
VideoView videoView = findViewById(R.id.videoView);
|
||||
|
||||
@@ -44,8 +45,9 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
|
||||
Log.e("FitnessActivity", "VideoView is null. Check your layout XML.");
|
||||
}
|
||||
|
||||
com.example.fitbot.util.ButtonNavigation.setupButtonNavigation(this, R.id.homeButton, MainActivity.class);
|
||||
com.example.fitbot.util.ButtonNavigation.setupButtonNavigation(this, R.id.buttonComplete, EndScreenActivity.class);
|
||||
ButtonNavigation.setupButtonNavigation(this, R.id.homeButton, MainActivity.class);
|
||||
ButtonNavigation.setupButtonNavigation(this, R.id.buttonComplete, EndScreenActivity.class);
|
||||
// Implement your logic when the robot focus is gained
|
||||
|
||||
GesturePath.Builder gesturePathBuilder = new GesturePath.Builder();
|
||||
|
||||
@@ -61,21 +63,20 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
|
||||
gesturePathBuilder.addVector(new Vector3f(-.5f, .5f, .5f));
|
||||
gesturePathBuilder.addVector(new Vector3f(-.5f, .5f, -.5f));
|
||||
|
||||
// Uncomment and fix if needed for personalMotionPreviewElement
|
||||
// personalMotionPreviewElement = findViewById(R.id.personalMotionPreviewElement);
|
||||
// personalMotionPreviewElement.post(() -> {
|
||||
// Log.i("FitnessActivity", "PersonalMotionPreviewElement.post()");
|
||||
//
|
||||
// Exercise exercise = new Exercise(EMuscleGroup.ARMS, "Bicep Curls", "Oefening voor de biceps.", gesturePathBuilder.build(), 1);
|
||||
//
|
||||
// personalMotionPreviewElement.initialize(exercise);
|
||||
// });
|
||||
personalMotionPreviewElement = findViewById(R.id.personalMotionPreviewElement);
|
||||
personalMotionPreviewElement.post(() -> {
|
||||
Log.i("FitnessActivity", "PersonalMotionPreviewElement.post()");
|
||||
|
||||
Exercise exercise = new Exercise(EMuscleGroup.ARMS, "Bicep Curls", "Oefening voor de biceps.", gesturePathBuilder.build(), 1);
|
||||
|
||||
personalMotionPreviewElement.initialize(exercise);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRobotFocusGained(QiContext qiContext) {
|
||||
// Implement your logic when the robot focus is gained
|
||||
Animations.Animate("bicepcurl", qiContext);
|
||||
personalMotionPreviewElement.provideQiContext(qiContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -8,6 +8,7 @@ import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import com.aldebaran.qi.sdk.QiContext;
|
||||
import com.example.fitbot.exercise.Exercise;
|
||||
import com.example.fitbot.speech.SpeechGenerator;
|
||||
import com.example.fitbot.util.path.GesturePath;
|
||||
@@ -26,6 +27,8 @@ public class PersonalMotionPreviewElement extends View {
|
||||
private double pathTime = 0.0D; // The timestamp at which the path is currently at.
|
||||
private MotionProcessor motionProcessor;
|
||||
|
||||
private QiContext qiContext;
|
||||
|
||||
private Exercise exercise;
|
||||
|
||||
private Path referencePath; // The path the user is supposed to follow.
|
||||
@@ -36,12 +39,10 @@ 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!"
|
||||
private static final String[] USER_PHRASES = {
|
||||
"Veel success met de oefening!",
|
||||
"Je kan het!",
|
||||
"Veel plezier!"
|
||||
};
|
||||
|
||||
// Matrices for the projection of the path segments onto the screen.
|
||||
@@ -60,7 +61,7 @@ public class PersonalMotionPreviewElement extends View {
|
||||
private final float FOV = 80.0f; // The field of view of the preview path
|
||||
private final float Z_NEAR = 0.1f; // The near clipping plane
|
||||
private final float Z_FAR = 1000.0f; // The far clipping plane
|
||||
private Vector3f objectPosition = new Vector3f(0.0f, 0.0f, 0.0f); // The position of the camera
|
||||
private Vector3f objectPosition = new Vector3f(0.0f, 0.0f, -4.0f); // The position of the camera
|
||||
private Vector2f screenDimensions = new Vector2f(); // Width and height dimensions of the screen
|
||||
private Vector2f rotation = new Vector2f(); // Rotation vector (yaw, pitch)
|
||||
|
||||
@@ -145,13 +146,33 @@ public class PersonalMotionPreviewElement extends View {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for providing a QiContext to the PersonalMotionPreviewElement.
|
||||
* @param context The QiContext to provide.
|
||||
*/
|
||||
public void provideQiContext(QiContext context) {
|
||||
this.qiContext = context;
|
||||
saySomethingNice();
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to say something nice to the user :)
|
||||
*/
|
||||
private void saySomethingNice()
|
||||
{
|
||||
if (this.qiContext == null)
|
||||
return;
|
||||
|
||||
SpeechGenerator.say(USER_PHRASES[(int) Math.floor(Math.random() * USER_PHRASES.length)], this.qiContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method that calculates the path that will be drawn on the
|
||||
* canvas. This method will be called every time new motion data is received.
|
||||
*/
|
||||
private void calculateDrawingPath(Vector3f transformedVector, MotionData motionData, int sampleIndex, double sampleRate) {
|
||||
// Recalculate the personal path based on the new motion data
|
||||
|
||||
// TODO: Implement
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,16 +185,6 @@ public class PersonalMotionPreviewElement extends View {
|
||||
this.referencePath = getDrawablePath(path.getSegments());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for setting the rotation of the preview path.
|
||||
*
|
||||
* @param yaw The yaw rotation of the preview path.
|
||||
* @param pitch The pitch rotation of the preview path.
|
||||
*/
|
||||
public void setRotation(float yaw, float pitch) {
|
||||
this.rotation.set(Math.toRadians(yaw), Math.toRadians(pitch));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for projecting a 3D point onto the screen.
|
||||
* This method converts the 3D point to 2D space using a Model-View-Projection matrix transformation.
|
||||
@@ -249,11 +260,9 @@ public class PersonalMotionPreviewElement extends View {
|
||||
canvas.drawPath(referencePath, referencePaint);
|
||||
canvas.drawPath(performingPath, performingPaint);
|
||||
|
||||
canvas.drawText(this.exercise.getTitle(), 10, 40, textPaint);
|
||||
|
||||
timePassed = (System.nanoTime() - startingTime) / 1E9D;
|
||||
|
||||
this.rotation.add(1f, 0);
|
||||
this.rotation.x = (float) (Math.sin(timePassed) * 45);
|
||||
this.referencePath = getDrawablePath(this.path.getSegments());
|
||||
this.invalidate(); // Causes a redraw.
|
||||
}
|
||||
|
@@ -1,26 +1,17 @@
|
||||
//usage: PlayAnimation(animationfile, Qicontext);
|
||||
// https://qisdk.softbankrobotics.com/sdk/doc/pepper-sdk/ch4_api/movement/reference/animation.html
|
||||
|
||||
package com.example.fitbot.sports;
|
||||
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
package com.example.fitbot.util;
|
||||
|
||||
import com.aldebaran.qi.sdk.QiContext;
|
||||
import com.aldebaran.qi.sdk.builder.AnimateBuilder;
|
||||
import com.aldebaran.qi.sdk.builder.AnimationBuilder;
|
||||
import com.aldebaran.qi.sdk.object.actuation.Animate;
|
||||
import com.aldebaran.qi.sdk.object.actuation.Animation;
|
||||
import com.example.fitbot.ui.activities.MainActivity;
|
||||
|
||||
public class Animations extends AppCompatActivity {
|
||||
|
||||
public class Animations {
|
||||
|
||||
public static void Animate(String AnimationFile, QiContext ctx)
|
||||
{
|
||||
PlayAnimation(AnimationFile, ctx);
|
||||
}
|
||||
|
||||
public static void PlayAnimation(String AnimationFile, QiContext ctx)
|
||||
{
|
||||
int resId = ctx.getResources().getIdentifier(AnimationFile, "raw", ctx.getPackageName());
|
||||
|
@@ -8,6 +8,13 @@ import android.widget.Button;
|
||||
|
||||
public class ButtonNavigation {
|
||||
|
||||
/**
|
||||
* Sets up a button to navigate to a different activity when clicked.
|
||||
*
|
||||
* @param currentActivity The activity that contains the button
|
||||
* @param buttonId The ID of the button
|
||||
* @param targetActivity The activity to navigate to
|
||||
*/
|
||||
public static void setupButtonNavigation(Activity currentActivity, int buttonId, Class<? extends Activity> targetActivity) {
|
||||
Button button = currentActivity.findViewById(buttonId);
|
||||
button.setOnClickListener(v -> {
|
||||
|
@@ -22,8 +22,8 @@ tools:openDrawer="start">
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintVertical_bias="0.2" />
|
||||
|
||||
<VideoView
|
||||
android:id="@+id/videoView2"
|
||||
<com.example.fitbot.ui.components.PersonalMotionPreviewElement
|
||||
android:id="@+id/personalMotionPreviewElement"
|
||||
android:layout_width="450dp"
|
||||
android:layout_height="450dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
|
Reference in New Issue
Block a user