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:
SebasKoedam
2024-06-03 16:25:36 +02:00
5 changed files with 32 additions and 9 deletions

View File

@@ -29,7 +29,7 @@ public class ExerciseManager {
private static final String PROPERTY_NAME = "name";
// The delimiter used to separate the paths of the sensors.
public static final String PATH_DELIMITER = ";";
public static final String PATH_DELIMITER = ":";
public static final int SENSOR_COUNT = 2;
@@ -96,6 +96,7 @@ public class ExerciseManager {
// Ensure all required properties are present
for (String property : REQUIRED_PROPERTIES) {
if (!content.has(property)) {
System.out.println("Missing property: " + property);
return null;
}
}
@@ -103,10 +104,13 @@ public class ExerciseManager {
// Path data is split into two parts, due to the left and right hand.
// If one wants to add support for more sensors, one will have to adjust the Exercise
// class to support more paths.
System.out.println(content.get(PROPERTY_PATH).getAsString());
String[] leftRightData = content.get(PROPERTY_PATH).getAsString().split(PATH_DELIMITER);
if (leftRightData.length != SENSOR_COUNT)
if (leftRightData.length != SENSOR_COUNT) {
System.out.println("Invalid path data.");
return null;
}
return new Exercise(
EMuscleGroup.parse(content.get(PROPERTY_MUSCLE_GROUP).getAsString()),

View File

@@ -13,8 +13,10 @@ public class GesturePath {
* @param vectors The vectors that make up the path.
*/
public GesturePath(Vector3f[] vectors) {
if (vectors.length < 2)
throw new IllegalArgumentException("A path must have at least two points.");
if (vectors.length < 2) {
this.segments = new PathSegment[0];
return;
}
this.segments = new PathSegment[vectors.length - 1];
for (int i = 0; i < vectors.length - 1; i++)
@@ -98,7 +100,7 @@ public class GesturePath {
// 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");
throw new IllegalArgumentException("Invalid input string length (" + input.length() + " bytes provided - must be a multiple of 12)");
}
Vector3f[] vectors = new Vector3f[input.length() / 12];

View File

@@ -40,7 +40,7 @@
<Tangent side="left" abscissaParam="-32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="119.500008" frame="299">
<Key value="-119.500008" frame="299">
<Tangent side="left" abscissaParam="-33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
@@ -177,14 +177,14 @@
</Key>
</ActuatorCurve>
<ActuatorCurve fps="25" actuator="RShoulderPitch" mute="false" unit="degree">
<Key value="119.500008" frame="101">
<Key value="-119.500008" frame="101">
<Tangent side="right" abscissaParam="32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="-119.500008" frame="199">
<Key value="119.500008" frame="199">
<Tangent side="left" abscissaParam="-32.6666667" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>
<Key value="112.970039" frame="299">
<Key value="-119.500008" frame="299">
<Tangent side="left" abscissaParam="-33.3333333" ordinateParam="0" editor:interpType="bezier_auto"/>
<Tangent side="right" abscissaParam="34" ordinateParam="0" editor:interpType="bezier_auto"/>
</Key>