-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHelloWorld.js
78 lines (63 loc) · 2.08 KB
/
HelloWorld.js
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
misty.Debug("The HelloWorld skill is starting!")
function getRandomInt(min, max) {
return Math.floor(Math.random()*(max - min + 1)) + min;
}
misty.RegisterTimerEvent("look_around", getRandomInt(5, 10) * 1000, false);
misty.RegisterTimerEvent("rainbowLED", 1, false);
_registerFaceRec();
misty.PlayAudio("s_PhraseHello.wav", 100);
function waveRightArm(){
misty.MoveArmDegrees("right", -80, 50);
misty.Pause(5000);
misty.MoveArmDegrees("right", 80, 50);
}
waveRightArm();
/*misty.Pause(100);
misty.DriveTime(0, 100, 5000); // Turns Misty to her left
misty.Pause(10000); // Wait for turn to complete
misty.DriveTime(0, -100, 5000); // Turns Misty to her right
misty.Pause(5000); // Wait for turns to complete
misty.Stop(); // Stops driving motors
misty.pause(1000);*/
function _look_around(repeat = true) {
misty.MoveHeadDegrees(
getRandomInt(-40,20),
getRandomInt(-30,30),
getRandomInt(-40,40),
100);
if (repeat) misty.RegisterTimerEvent(
"look_around",
getRandomInt(5, 10) * 1000,
false);
}
function _rainbowLED(){
i=0
while(true){
i++;
misty.ChangeLED(i%255, (i+85)%255, (i+170)%255);
misty.Pause(1);
}
misty.RegisterTimerEvent("rainbowLED", 1, false);
}
function _registerFaceRec(){
misty.StopFaceRecognition();
misty.StartFaceRecognition();
misty.AddPropertyTest("FaceRec", "PersonName", "exists", "", "string");
misty.RegisterEvent("FaceRec", "FaceRecognition", 1000, false);
}
function _FaceRec(data) {
var faceDetected = data.PropertyTestResults[0].PropertyValue;
misty.Debug("Misty sees " + faceDetected);
if (faceDetected != "unknown person") {
misty.Debug("I see " + faceDetected);
misty.DisplayImage("e_Joy.jpg");
//misty.PlayAudio("s_Joy3.wav");
misty.Speak("Hi " + faceDetected, true);
waveRightArm();
}
else if (faceDetected == "unknown person") {
misty.DisplayImage("e_Contempt.jpg");
misty.PlayAudio("s_DisorientedConfused4.wav");
};
misty.RegisterTimerEvent("registerFaceRec", 7000, false);
}