-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRealOccraB.c
196 lines (163 loc) · 3.92 KB
/
RealOccraB.c
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#pragma config(Sensor, dgtl7, bump, sensorTouch)
#pragma config(Motor, port2, rightside, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port3, leftside, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port4, hpsucker, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port5, hphammer, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port6, trashcancollect1, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port7, trashcancollect2, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port8, ballcollect2, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port9, ballcollect1, tmotorVex393_MC29, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
void drive(int throttle, int wheel)
{
if (abs(throttle) < 10) throttle = 0;
if (abs(wheel) < 10) wheel = 0;
if (abs(throttle) > 127) throttle = 127;
if (abs(wheel) > 127) wheel = 127;
motor[leftside] = throttle - wheel;
motor[rightside] = throttle + wheel;
}
int have_can =0;
//5d suck 5u spit
void control(int trashin, int trashout, int ballstage1in, int ballstage1out, int ballstage2in, int ballstage2out, int hpin,
int hpout, int hpsuck)
{
/*if(SensorValue[bump] == 1) //when trashcan is in
{
if(trashin) // trash in
{
motor[trashcancollect1] = -127; motor[trashcancollect2] = -127;
}
else if(trashout)
{
motor[trashcancollect1] = 127; motor[trashcancollect2] = 127;
}
else
{
motor[trashcancollect1] = 0; motor[trashcancollect2] = 0;
}
}
if(SensorValue[bump] == 0) //when trash can is out
{
if(trashin) // trash in
{
motor[trashcancollect1] = -127; motor[trashcancollect2] = -127;
}
else if(trashout)
{
motor[trashcancollect1] = 127; motor[trashcancollect2] = 127;
}
else
{
motor[trashcancollect1] = -127; motor[trashcancollect2] = -127;
}
}
*/
if(have_can == 0)
{
if(SensorValue(bump) == 0) //can not in
{
if (trashin)
{
motor[trashcancollect1] = -127; motor[trashcancollect2] = -127;
}
else if (trashout)
{
motor[trashcancollect1] = 127; motor[trashcancollect2] = 127;
}
else
{
motor[trashcancollect1] = 0; motor[trashcancollect2] = 0;}
}
else
{
have_can = 1;
}
}
else
{ // Have can == True
if(SensorValue(bump) == 0)
{
if (trashin)
{
motor[trashcancollect1] = -127; motor[trashcancollect2] = -127;
}
else if (trashout)
{
motor[trashcancollect1] = 127; motor[trashcancollect2] = 127; have_can =0;
}
else
{
motor[trashcancollect1] = -127; motor[trashcancollect2] = -127;
}
}
else
{//sensorvalue (Bump) == 0
if(trashin)
{
motor[trashcancollect1] = 0; motor[trashcancollect2] = 0;
}
else if(trashout)
{
motor[trashcancollect1] = 127; motor[trashcancollect2] = 127; have_can =0;
}
else
{
motor[trashcancollect1] = 0; motor[trashcancollect2] = 0;
}
}
}
if(ballstage2out)
{
motor[ballcollect2] = 127;
}
else if(ballstage2in)
{
motor[ballcollect2] = -127;
}
else
{
motor[ballcollect2] = 0;
}
if(hpin)
{
motor[hphammer] = 127;
}
else if(hpout)
{
motor[hphammer] = -127;
}
else
{
motor[hphammer] = 0;
}
if(hpsuck)
{
motor[hpsucker] = -127;
}
else if(ballstage1in)
{
motor[hpsucker] = 127;
motor[ballcollect1] = -127;
}
else if(ballstage1out)
{
motor[hpsucker] = 127;
motor[ballcollect1] = 127;
}
else
{
motor[hpsucker] = 0;
motor[ballcollect1] = 0;
}
if(motor[hpsucker] >127) motor[hpsucker] = 127;
}
task main()
{
while(true)
{
drive(vexRT[Ch3], vexRT[Ch1]);
control(vexRT[Btn7DXmtr2], vexRT[Btn7UXmtr2], vexRT[Btn6DXmtr2], vexRT[Btn6UXmtr2], vexRT[Btn5DXmtr2], vexRT[Btn5UXmtr2],vexRT[Btn8DXmtr2],
vexRT[Btn8UXmtr2], vexRT[Btn8LXmtr2]);
} //trash in //trashout ballstage1in ballstageiout ballstage2in ballstage2out
}