-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
56 lines (40 loc) · 1.04 KB
/
main.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
"use strict";
var queue = require('./queue');
var connection = require('./phone-connection');
var agent = require('./agent');
var STATES = {
FOLLOWING: 1,
HALTED: 2
};
var state = STATES.FOLLOWING;
agent.init();
var sumDist = 0;
setInterval(function() {
if (agent.isTooClose()) {
state = STATES.HALTED;
} else {
state = STATES.FOLLOWING;
}
switch (state) {
case STATES.FOLLOWING:
agent.shutUp();
console.log('FOLLOWING');
var step = queue.nextStepAggregate();
if (step) {
//console.log('rotating', step.direction);
//agent.rotate(step.direction);
//console.log(step.displacement);
//agent.move(step.displacement);
if (step.displacement < 0) {
console.log('NANA', step.displacement);
}
sumDist += step.displacement;
console.log('sumDist', sumDist);
}
break;
case STATES.HALTED:
console.log('STOP');
agent.speak();
break;
}
}, 200);