This repository has been archived by the owner on Feb 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
/
MyoController.h
132 lines (102 loc) · 4.25 KB
/
MyoController.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#pragma once
#include "MyoEnum.h"
#include "MyoController.generated.h"
USTRUCT(BlueprintType)
struct MYOPLUGIN_API FMyoControllerData
{
GENERATED_USTRUCT_BODY()
//Can be rest, fist, waveIn, waveOut, fingersSpread, reserved1, DoubleTap, unknown
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Myo Controller Data")
TEnumAsByte<EMyoPose> Pose;
//acceleration in units of g
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Myo Controller Data")
FVector Acceleration;
//orientation in rotator format
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Myo Controller Data")
FRotator Orientation;
// gyroscope vector in deg / s
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Myo Controller Data")
FVector Gyro;
//right, left, unknown
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Myo Controller Data")
TEnumAsByte<EMyoArm> Arm;
//toward wrist, toward elbow, unknown
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Myo Controller Data")
TEnumAsByte<EMyoArmDirection> ArmDirection;
//acceleration in arm space given in units of g
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Myo Controller Data")
FVector ArmAcceleration;
//orientation in arm space
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Myo Controller Data")
FRotator ArmOrientation;
//gyro in arm space
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Myo Controller Data")
FVector ArmGyro;
//the correction rotation to transform raw into arm space
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Myo Controller Data")
FRotator ArmSpaceCorrection;
//BodySpaceAcceleration(out) acceleration in calibrated body space, with gravity removed. (This value is used for velocity and position integration)
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Myo Controller Data")
FVector BodySpaceNullAcceleration;
//Id identifying myo, used for calling functions
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Myo Controller Data")
int32 MyoId;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Myo Controller Data")
int32 BatteryLevel;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Myo Controller Data")
int32 RSSI;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Myo Controller Data")
bool bIsArmSynced;
FMyoControllerData()
{
ArmAcceleration = FVector(0.f);
ArmGyro = FVector(0.f);
ArmOrientation = FRotator(0.f);
ArmSpaceCorrection = FRotator(0.f);
}
};
UCLASS(BlueprintType)
class MYOPLUGIN_API UMyoController : public UObject
{
GENERATED_UCLASS_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Myo Frame")
FMyoControllerData MyoData;
//Convenience Call, optionally check hand possession property
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Myo Frame")
bool isOnLeftArm();
//Convenience Call, optionally check hand possession property
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Myo Frame")
bool isOnRightArm();
/**
* Vibrate the specified Myo with type intensity
* @param myoId (in) starting from 1, based on pairing priority. Call LeftMyoId/RightMyoId
* @param type (in) Options: Short, Medium, Long
*/
UFUNCTION(BlueprintCallable, Category = MyoFunctions)
void VibrateDevice(EMyoVibrationType Type);
/**
* Calibrate the Orientation for Arm Space. Ask the user to point their arm to the screen, then call this function and all orientation will be
* in arm orientation space.
* @param myoId (in) device you wish to calibrate, use 0 to calibrate all.
* @param direction (in) orientation of the calibrated myo with respect to the user forward vector (R0,P0,Y0) specifies into the screen, (R0,P0,Y90) specifies pointing right, etc.
*/
UFUNCTION(BlueprintCallable, Category = MyoFunctions)
void CalibrateArmOrientation(FRotator Direction);
/**
* Unlocks the Myo if locked to detect gestures
* @param type (in) type of unlock (short period or indefinite hold)
*/
UFUNCTION(BlueprintCallable, Category = MyoFunctions)
void Unlock(EMyoUnlockType Type);
/**
* Tell the Myo to stay unlocked until told otherwise.
*/
UFUNCTION(BlueprintCallable, Category = MyoFunctions)
void Lock();
/**
* Sets the EMG streaming mode for this Myo
*/
UFUNCTION(BlueprintCallable, Category = MyoFunctions)
void SetStreamEmg(EMyoStreamEmgType StreamType);
};