-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunction_main.ic
137 lines (103 loc) · 2.74 KB
/
function_main.ic
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
133
134
135
136
137
/**
* @file function_main.ic
* @brief Main loop
* @author Andrew Krieger
* @date 4/26/2011
*
*/
#use "defines.ic"
#use "drive.ic"
#use "servo/exp_servo_lib.ic"
#use "CdS.ic"
#use "line.ic"
//#use "corn.ic"
/**
* @brief main entry point
*/
void main() {
int i, j, old;
gps_initialize_knob();
exp_servo_min[SERVO_CORN] = exp_servo_min[SERVO_HAY] = 400;
exp_servo_max[SERVO_CORN] = exp_servo_max[SERVO_HAY] = 4000;
exp_servo_enable();
exp_servo_deg(SERVO_CORN, 0);
exp_servo_deg(SERVO_HAY, 0);
init_shaft_encoders();
/*
{
int x,d=-1;
for(;;) {
x = knob()/2;
if(x!=d)
printf("Ang: %d\n", d=x);
exp_servo_deg(SERVO_CORN, x);
}
}
*/
#if 1
for(;;) {
int up_hill=1;
printf("Are you ready tostart WINNING?\n");
wait_for_start(CDS_FRONT);
gps_enable();
while(drive_up_hill()) {
exp_servo_deg(SERVO_CORN, 60);
msleep(500L);
}
exp_servo_deg(SERVO_CORN, 0);
turn(-70.0);
gps_turn(85, 4);
drive_back_to_shiny(1, 2250L);
msleep(2000L);
gps_good_data();
if(gps_y < 185)
gps_turn(70, 4);
else
gps_turn(82, 4);
drive_back_to_shiny(0, 1500L);
follow_strip_back(0);
follow_strip_back(0);
follow_strip_back(0);
drive_straight(-3);
// exp_servo_deg(SERVO_HAY, 45);
msleep(250L);
exp_servo_deg(SERVO_HAY, 90);
msleep(250L);
exp_servo_deg(SERVO_HAY, 0);
msleep(250L);
gps_good_data();
for(i=0;!gps_button && i < RED_BUTTON_TRIES;++i) {
motor(MOTOR_LEFT, -100);
motor(MOTOR_RIGHT, -100);
msleep(300L);
motor(MOTOR_LEFT, 100);
motor(MOTOR_RIGHT, 100);
msleep(150L);
gps_good_data();
}
curve_to_wagon();
follow_strip_back(0);
follow_strip_back(0);
follow_strip_back(0);
gps_align();
motor(MOTOR_LEFT, -80);
motor(MOTOR_RIGHT, -80);
msleep(125L);
ao();
pull_wagon();
drive_down_hill();
ao();
}
#else
printf("Are you ready tostart WINNING?\n");
wait_for_start(CDS_SIDE);
gps_enable();
start_to_corn();
test_corn();
pick_corn();
printf("Ready to cleanupPress start\n");
press_start();
left_corn_cleanup();
corn_to_start();
#endif
}