-
Notifications
You must be signed in to change notification settings - Fork 0
/
executor.cpp
54 lines (51 loc) · 1.04 KB
/
executor.cpp
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
#include "movement.h"
#include "arm.h"
#include "executor.h"
int taskPointer = 0;
bool doTask(int task) {
switch (task) {
case GO_FORWARD:
return goForward(false);
case GO_BACKWARD:
return goBackward();
case CALC_NEXT_LINE:
return calcNextLine();
case GO_FORWARD_AND_COUNT:
return goForwardAndCount();
case TURN_LEFT:
return turn90(LEFT);
case TURN_RIGHT:
return turn90(RIGHT);
case TURN_90:
// turn this based on the side
return true;
case TURN_180:
return turn180();
case TO_VERTICAL:
return craneToVer();
case TO_HORIZONTAL:
return craneToHor();
case SLIDE_OUT:
return slideOut();
case SLIDE_IN:
return slideIn();
case OPEN_GRIPPER:
return openGripper();
case CLOSE_GRIPPER:
return closeGripper();
case SWITCH_SIDE:
return switchSide();
default:
return true;
}
}
bool executeTasks(int* tasks, int noOfTasks) {
if (taskPointer == noOfTasks) {
taskPointer = 0;
return true;
}
if (doTask(tasks[taskPointer])) {
taskPointer++;
}
return false;
}