-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #54 from Gloveland/tidying_up
Tidying up
- Loading branch information
Showing
22 changed files
with
325 additions
and
521 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
import 'package:lsa_gloves/model/vector3.dart'; | ||
|
||
/// Class to encapsulate the acceleration values received from the glove. | ||
class Acceleration with Vector3 { | ||
final double x; | ||
final double y; | ||
final double z; | ||
|
||
Acceleration(this.x, this.y, this.z); | ||
|
||
Acceleration.fromJson(Map<String, dynamic> json) | ||
: x = json['x'], y = json['y'], z = json['z']; | ||
|
||
Map<String, dynamic> toJson() => { | ||
'x': x, | ||
'y': y, | ||
'z': z, | ||
}; | ||
|
||
@override | ||
double getX() => x; | ||
|
||
@override | ||
double getY() => y; | ||
|
||
@override | ||
double getZ() => z; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import 'sensor_value.dart'; | ||
import 'vector3.dart'; | ||
import 'acceleration.dart'; | ||
import 'gyro.dart'; | ||
|
||
/// Enumeration for each of the hand's fingers. | ||
enum FingerValue { | ||
Pinky, | ||
Ring, | ||
Middle, | ||
Index, | ||
Thumb | ||
} | ||
|
||
extension FingerValueTranslation on FingerValue { | ||
String spanishName() { | ||
switch (this) { | ||
case FingerValue.Pinky: | ||
return "Meñique"; | ||
case FingerValue.Ring: | ||
return "Anular"; | ||
case FingerValue.Middle: | ||
return "Medio"; | ||
case FingerValue.Index: | ||
return "Índice"; | ||
case FingerValue.Thumb: | ||
return "Pulgar"; | ||
} | ||
} | ||
} | ||
|
||
/// Class to handle the sensor measurements from a finger's mpu6050. | ||
class Finger { | ||
final Acceleration acc; | ||
final Gyro gyro; | ||
|
||
Finger(this.acc, this.gyro); | ||
|
||
Finger.fromJson(Map<String, dynamic> json) | ||
: acc = Acceleration.fromJson(json['acc'] as Map<String, dynamic>), | ||
gyro = Gyro.fromJson(json['gyro'] as Map<String, dynamic>); | ||
Map<String, dynamic> toJson() => { | ||
'acc': acc.toJson(), | ||
'gyro': gyro.toJson(), | ||
}; | ||
|
||
Finger.fromList(List<double> m): | ||
acc = Acceleration(m[0],m[1], m[2]), | ||
gyro = Gyro(m[3],m[4], m[5]); | ||
|
||
Vector3 getSensorValues(SensorValue sensorName) { | ||
switch (sensorName) { | ||
case SensorValue.Acceleration: | ||
return acc; | ||
case SensorValue.Gyroscope: | ||
return gyro; | ||
} | ||
} | ||
} |
Oops, something went wrong.