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:
17
code/src/Fitbot/.idea/misc.xml
generated
17
code/src/Fitbot/.idea/misc.xml
generated
@@ -3,19 +3,18 @@
|
||||
<component name="DesignSurface">
|
||||
<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/layout/activity_bicepvideo.xml" value="0.2015625" />
|
||||
<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/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/layout/activity_bicepvideo.xml" value="0.136" />
|
||||
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/layout/activity_completion_screen.xml" value="0.18541666666666667" />
|
||||
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/layout/activity_main.xml" value="0.12" />
|
||||
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/layout/activity_bicepvideo.xml" value="0.22826086956521738" />
|
||||
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/layout/activity_main.xml" value="0.1" />
|
||||
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/layout/activity_main_screen.xml" value="0.1" />
|
||||
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/layout/activity_power_screen.xml" value="0.1" />
|
||||
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/layout/activity_sport_item.xml" value="0.18541666666666667" />
|
||||
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/layout/activity_sport_menu.xml" value="0.18541666666666667" />
|
||||
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/layout/header.xml" value="0.18125" />
|
||||
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/layout/toolbar.xml" value="0.1" />
|
||||
<entry key="..\:/Users/sebas/Documents/HvA/Reposetories/muupooviixee66/code/src/Fitbot/app/src/main/res/menu/main_menu.xml" value="0.1" />
|
||||
<entry key="app/src/main/res/layout/activity_main.xml" value="0.1" />
|
||||
<entry key="app/src/main/res/layout/activity_sport_item.xml" value="0.2341485507246377" />
|
||||
<entry key="app/src/main/res/layout/activity_sport_menu.xml" value="0.22056159420289856" />
|
||||
<entry key="app/src/main/res/layout/header.xml" value="0.1" />
|
||||
<entry key="app/src/main/res/layout/sport_menu_item.xml" value="0.22056159420289856" />
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
|
@@ -16,7 +16,8 @@
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".ui.SportMenuActivity"
|
||||
android:exported="false" />
|
||||
android:exported="true">
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".BicepVideo"
|
||||
android:exported="false" />
|
||||
@@ -25,7 +26,7 @@
|
||||
android:exported="false" />
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="false" />
|
||||
android:exported="true" />
|
||||
<activity
|
||||
android:name=".MainScreen"
|
||||
android:exported="true" >
|
||||
|
@@ -1,24 +1,20 @@
|
||||
package com.example.fitbot;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.widget.Button;
|
||||
|
||||
import com.aldebaran.qi.sdk.QiContext;
|
||||
import com.aldebaran.qi.sdk.QiSDK;
|
||||
import com.aldebaran.qi.sdk.RobotLifecycleCallbacks;
|
||||
import com.aldebaran.qi.sdk.builder.AnimateBuilder;
|
||||
import com.aldebaran.qi.sdk.builder.AnimationBuilder;
|
||||
import com.aldebaran.qi.sdk.builder.SayBuilder;
|
||||
import com.aldebaran.qi.sdk.design.activity.RobotActivity;
|
||||
import com.aldebaran.qi.sdk.design.activity.conversationstatus.SpeechBarDisplayStrategy;
|
||||
import com.aldebaran.qi.sdk.object.actuation.Animate;
|
||||
import com.aldebaran.qi.sdk.object.actuation.Animation;
|
||||
import com.aldebaran.qi.sdk.object.conversation.Phrase;
|
||||
import com.aldebaran.qi.sdk.object.conversation.Say;
|
||||
import com.aldebaran.qi.sdk.object.locale.Language;
|
||||
import com.aldebaran.qi.sdk.object.locale.Locale;
|
||||
import com.aldebaran.qi.sdk.object.locale.Region;
|
||||
import com.example.fitbot.ui.SportMenuActivity;
|
||||
|
||||
public class MainActivity extends RobotActivity implements RobotLifecycleCallbacks {
|
||||
|
||||
@@ -26,7 +22,12 @@ public class MainActivity extends RobotActivity implements RobotLifecycleCallbac
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// Register the RobotLifecycleCallbacks to this Activity.
|
||||
Button button = findViewById(R.id.menu_switch_btn);
|
||||
button.setOnClickListener(v -> {
|
||||
startActivity(new Intent(MainActivity.this, SportMenuActivity.class));
|
||||
});
|
||||
QiSDK.register(this, this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -36,6 +36,7 @@ public class MainScreen extends AppCompatActivity {
|
||||
|
||||
/*---Navigation Drawer Menu---*/
|
||||
navigationView.bringToFront();
|
||||
|
||||
ActionBarDrawerToggle toggle=new
|
||||
ActionBarDrawerToggle(this,drawerLayout,toolbar,R.string.navigation_drawer_open,R.string.navigation_drawer_close);
|
||||
drawerLayout.addDrawerListener(toggle);
|
||||
|
@@ -0,0 +1,55 @@
|
||||
package com.example.fitbot.processing;
|
||||
|
||||
public class MotionData {
|
||||
|
||||
// Data of the motion sensor
|
||||
public float accelerationX;
|
||||
public float accelerationY;
|
||||
public float accelerationZ;
|
||||
public float rotationX;
|
||||
public float rotationY;
|
||||
public float rotationZ;
|
||||
|
||||
// Delimiter for the data received from the motion sensor
|
||||
private static final String DATA_DELIMITER = ";";
|
||||
|
||||
/**
|
||||
* Constructor for the MotionData class.
|
||||
*
|
||||
* @param accelerationX The acceleration in the X axis in m/s^2.
|
||||
* @param accelerationY The acceleration in the Y axis in m/s^2.
|
||||
* @param accelerationZ The acceleration in the Z axis in m/s^2.
|
||||
* @param rotationX The rotation in the X axis in degrees.
|
||||
* @param rotationY The rotation in the Y axis in degrees.
|
||||
* @param rotationZ The rotation in the Z axis in degrees.
|
||||
*/
|
||||
public MotionData(float accelerationX, float accelerationY, float accelerationZ, float rotationX, float rotationY, float rotationZ) {
|
||||
this.accelerationX = accelerationX;
|
||||
this.accelerationY = accelerationY;
|
||||
this.accelerationZ = accelerationZ;
|
||||
this.rotationX = rotationX;
|
||||
this.rotationY = rotationY;
|
||||
this.rotationZ = rotationZ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function for decoding a string into a MotionData object.
|
||||
* This string must contain the data of the motion sensor
|
||||
* separated by the delimiter. (;)
|
||||
*
|
||||
* @param data The string containing the data of the motion sensor.
|
||||
* @return An instance of MotionData.
|
||||
*/
|
||||
public static MotionData decode(String data) {
|
||||
String[] parts = data.split(DATA_DELIMITER);
|
||||
return new MotionData(
|
||||
Float.parseFloat(parts[0]),
|
||||
Float.parseFloat(parts[1]),
|
||||
Float.parseFloat(parts[2]),
|
||||
Float.parseFloat(parts[3]),
|
||||
Float.parseFloat(parts[4]),
|
||||
Float.parseFloat(parts[5])
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
package com.example.fitbot.processing;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* Class representing the input stream of the motion sensor.
|
||||
* This class will be responsible for reading the data from
|
||||
* the motion sensor and processing it, by creating a
|
||||
* server and starting a WebSocket connection with the ESP32.
|
||||
*/
|
||||
public class MotionInputStream extends InputStream {
|
||||
|
||||
/**
|
||||
* Function for starting the listening process
|
||||
* of the motion sensor. This function will
|
||||
* @return An instance of MotionInputStream.
|
||||
*/
|
||||
public static MotionInputStream startListening()
|
||||
{
|
||||
// Create server
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int read() {
|
||||
return 0;
|
||||
}
|
||||
}
|
@@ -0,0 +1,4 @@
|
||||
package com.example.fitbot.processing;
|
||||
|
||||
public class MotionProcessor {
|
||||
}
|
@@ -6,6 +6,9 @@ import com.aldebaran.qi.sdk.object.locale.Language;
|
||||
import com.aldebaran.qi.sdk.object.locale.Locale;
|
||||
import com.aldebaran.qi.sdk.object.locale.Region;
|
||||
|
||||
/**
|
||||
* SpeechGenerator class for generating speech for the robot
|
||||
*/
|
||||
public class SpeechGenerator {
|
||||
|
||||
private static final Locale DUTCH_LOCALE = new Locale(Language.DUTCH, Region.NETHERLANDS);
|
||||
@@ -21,13 +24,18 @@ public class SpeechGenerator {
|
||||
say(phrase, ctx, DUTCH_LOCALE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void say(String text, QiContext ctx, Locale locale)
|
||||
/**
|
||||
* Function for making the robot say something with a specific locale
|
||||
* @param phrase The phrase to make the robot say
|
||||
* @param ctx The QiContext to use
|
||||
* @param locale The locale to use
|
||||
*/
|
||||
public static void say(String phrase, QiContext ctx, Locale locale)
|
||||
{
|
||||
SayBuilder.with(ctx)
|
||||
SayBuilder
|
||||
.with(ctx)
|
||||
.withLocale(locale)
|
||||
.withText(text)
|
||||
.withText(phrase)
|
||||
.build()
|
||||
.run();
|
||||
}
|
||||
|
@@ -1,21 +0,0 @@
|
||||
package com.example.fitbot.ui;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import com.example.fitbot.R;
|
||||
|
||||
public class SportItemActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_sport_item);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
}
|
@@ -1,22 +0,0 @@
|
||||
package com.example.fitbot.ui;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
|
||||
import com.example.fitbot.R;
|
||||
|
||||
|
||||
public class SportMenuActivity extends AppCompatActivity {
|
||||
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_sport_menu);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
@@ -1,45 +0,0 @@
|
||||
package com.example.fitbot.ui;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Rect;
|
||||
import android.view.View;
|
||||
|
||||
import com.example.fitbot.sports.ESportType;
|
||||
|
||||
public class SportMenuItem extends View {
|
||||
|
||||
private Paint backgroundPaint, textPaint;
|
||||
private String title, description;
|
||||
private Bitmap imageResource;
|
||||
private Rect imageRect, elementRect;
|
||||
private ESportType type;
|
||||
|
||||
public SportMenuItem(Context context, ESportType type, String title, String description, Bitmap backgroundImage) {
|
||||
super(context);
|
||||
this.title = title;
|
||||
this.description = description;
|
||||
this.imageResource = backgroundImage;
|
||||
this.imageRect = new Rect(0, 0, this.imageResource.getWidth(), this.imageResource.getHeight());
|
||||
this.elementRect = new Rect(0, 0, this.getWidth(), this.getHeight());
|
||||
this.type = type;
|
||||
this.backgroundPaint = new Paint();
|
||||
this.textPaint = new Paint();
|
||||
this.textPaint.setTextAlign(Paint.Align.CENTER);
|
||||
this.backgroundPaint.setColor(0xFFF0F0F0);
|
||||
this.textPaint.setColor(0xFF000000);
|
||||
|
||||
this.setOnClickListener(v -> context.startActivity(new Intent(context, SportItemActivity.class)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
canvas.drawBitmap(this.imageResource, this.imageRect, this.elementRect, null);
|
||||
canvas.drawRoundRect(0, 0, getWidth(), getHeight(), 10, 10, backgroundPaint);
|
||||
canvas.drawText(title, getWidth() / 2.0f, this.textPaint.getFontMetrics().top, textPaint);
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
@@ -19,14 +19,17 @@
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="start"
|
||||
app:headerLayout="@layout/header"
|
||||
|
||||
app:menu="@menu/main_menu" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/menu_switch_btn"
|
||||
android:layout_width="200dp"
|
||||
android:layout_height="50dp"
|
||||
android:clickable="true"
|
||||
android:text="Go to Sport Menu"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent" />
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
android:focusable="true" />
|
||||
|
||||
</android.support.v4.widget.DrawerLayout>
|
@@ -15,7 +15,7 @@
|
||||
android:layout_height="150dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginTop="20dp"
|
||||
android:src="@drawable/robotlogo"
|
||||
android:src="@drawable/robot_logo"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
Reference in New Issue
Block a user