This repository has been archived by the owner on Apr 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WER_xyl.2018 05 26 18 17 43.c
1398 lines (1365 loc) · 30 KB
/
WER_xyl.2018 05 26 18 17 43.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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "ASEIO.h"
#define true 1
#define false 0
//=================Settings=================//
//Button
const int buttonPort = 10;
//dh
const bool useSafedh = true;
const int safedh = 500;
const bool ReadEEOnStart = true;
const int dhPort[7] = {2,3,4,5,6,7,8};
const int EEAddr[7] = {0,1,2,3,4,5,6};
//Motor
const int lMotorPort = 0;
const int rMotorPort = 1;
const bool invertL = true;
const bool invertR = false;
//Servo
const int servoPort = 9;
const int servoID = 1;
//Battery
const int battMin = 7800;
const int battMax = 8500;
//--------------Drive--------------//
//Departure 2
const int Speed_2 = 50;
//UpStair 3
const int lSpeed_3 = -40;
const int mSpeed_3 = 35;
const int hSpeed_3 = 70;
const int tSpeed_3 = 40;
const int upSpeed_3 = 100;
const float upDelay_3 = 0.3;
const int dhdet_3 = 200;
//Back 4
const int mSpeed_4 = 40;
const float backDelay_4 = 0.75;
//UtlStop 5
const int lSpeed_5 = -40;
const int mSpeed_5 = 30;
const int hSpeed_5 = 40;
const int tSpeed_5 = 20;
//CrossJunc 6
const int lSpeed_6 = -40;
const int mSpeed_6 = 35;
const int hSpeed_6 = 60;
const int tSpeed_6 = 40;
//Left 7
const int hSpeed_7 = 60;
const int mSpeed_7 = 35;
const int lSpeed_7 = -40;
const int tSpeed_7 = 40;
const float btDelay_7 = 0.2;
const float bttDelay_7 = 0.2;
//Right 8
const int hSpeed_8 = 60;
const int mSpeed_8 = 35;
const int lSpeed_8 = -40;
const int tSpeed_8 = 40;
const float btDelay_8 = 0.2;
const float bttDelay_8 = 0.2;
//TLeft 9
const int tSpeed_9 = 40;
const float btDelay_9 = 0.15;
const float bttDelay_9 = 0.2;
//TRight 10
const int tSpeed_10 = 40;
const float btDelay_10 = 0.15;
const float bttDelay_10 = 0.2;
//DownStair 11
const int lSpeed_11 = -20;
const int mSpeed_11 = 20;
const int hSpeed_11 = 40;
const int tSpeed_11 = 20;
//---------------------------------//
//Debug
int defdbgLevel = 2;
float dbgSeqDelay = 1;
int defSequence = 0;
float dbgDelay = 0.0;
//---------------------------------//
bool isMatch = false;
//==========================================//
//===varDecl===//
int dbgLevel = 0;
int dh[7]={0};
char *subNameP;
char *subNameC;
char *subNameN;
int curSeq;
bool isServInit = false;
//=============//
//===funcDecl===//
void runsub(int sub,bool getName);
void initServ();
void Drive_Init();//1
void Drive_Departure();//2
void Drive_UpStair();//3
void Drive_Back();//4
void Drive_UtlStop();//5
void Drive_CrossJunc();//6
void Drive_UtlLeft();//7
void Drive_UtlRight();//8
void Drive_TurnLeft();//9
void Drive_TurnRight();//10
void Drive_DownStair();//11
void Mission_N01();//101
void Mission_N02();//102
void Mission_N03();//103
void Mission_N04();//104
void Mission_N05();//105
void Mission_N06();//106
void Mission_N07();//107
void Mission_N08();//108
void Mission_N09();//109
void Mission_N10();//110
void Mission_N11();//111
void Mission_N12();//112
void Mission_N13();//113
void Mission_N14();//114
void Mission_N15();//115
void Mission_N16();//116
void Act_01();//201
void Act_02();//202
void Act_03();//203
void Act_04();//204
void Act_05();//205
void Act_06();//206
void Act_07();//207
void Act_08();//208
void Act_09();//209
void Act_10();//210
void Act_11();//211
void Act_12();//212
void Act_13();//213
void Act_14();//214
void Act_15();//215
void Act_16();//216
void Act_17();//217
void Act_18();//218
void Act_19();//219
void Act_20();//220
bool dhs(int port);
int rawDh(int port);
void drive(int lspd,int rspd);
void setServ(float angle,int speed);
void dhUpdate();
void ReadEE();
void ReadEE_Fast();
void WriteEE();
void main_match();
void main_test();
//==============//
//=================SEQUENCE=================//
int Sequence[8][100] = {
{1,2,3,4,5,6,7,8,9,10},
{201,1,2,6,202,9,3,0},
{7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7},
{8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8},
{0},
{0},
{0},
{0},
{0}};
//==========================================//
//Upstair: {201,1,2,6,202,9,3,0}
void main(){
if(isMatch) main_match();
else main_test();
return;
}
void main_match(){
BEEP(700,0.25);
printf(" Debug\n\n Init Servo\n (on port %2d ID %3d)",servoPort,servoID);
initServ();
Drive_Init();
if(ReadEEOnStart)ReadEE_Fast();
curSeq = defSequence;
int curStep = 0;
int i=0,Steps=0;
bool runFlag=false;
A:
i=0;
Steps=0;
curStep = 0;
runFlag=false;
int cnt = 0;
while(true){
while(true){
bool cbatt=false;
int batt;
batt = Get_Battery();
if(batt<battMin||batt>battMax)cbatt=true;
switch(curSeq){
case 0:
printf(" MATCH\nChoose Sequence:\n >0< 1\n 2 3\n 4 5\n 6 7\nBatt:%d%s\nPrev Sel Next",batt,cbatt?"<-ATTENTION":" ");
break;
case 1:
printf(" MATCH\nChoose Sequence:\n 0 >1<\n 2 3\n 4 5\n 6 7\nBatt:%d%s\nPrev Sel Next",batt,cbatt?"<-ATTENTION":" ");
break;
case 2:
printf(" MATCH\nChoose Sequence:\n 0 1\n >2< 3\n 4 5\n 6 7\nBatt:%d%s\nPrev Sel Next",batt,cbatt?"<-ATTENTION":" ");
break;
case 3:
printf(" MATCH\nChoose Sequence:\n 0 1\n 2 >3<\n 4 5\n 6 7\nBatt:%d%s\nPrev Sel Next",batt,cbatt?"<-ATTENTION":" ");
break;
case 4:
printf(" MATCH\nChoose Sequence:\n 0 1\n 2 3\n >4< 5\n 6 7\nBatt:%d%s\nPrev Sel Next",batt,cbatt?"<-ATTENTION":" ");
break;
case 5:
printf(" MATCH\nChoose Sequence:\n 0 1\n 2 3\n 4 >5<\n 6 7\nBatt:%d%s\nPrev Sel Next",batt,cbatt?"<-ATTENTION":" ");
break;
case 6:
printf(" MATCH\nChoose Sequence:\n 0 1\n 2 3\n 4 5\n >6< 7\nBatt:%d%s\nPrev Sel Next",batt,cbatt?"<-ATTENTION":" ");
break;
case 7:
printf(" MATCH\nChoose Sequence:\n 0 1\n 2 3\n 4 5\n 6 >7<\nBatt:%d%s\nPrev Sel Next",batt,cbatt?"<-ATTENTION":" ");
break;
}
if(Get_Button()||AI(buttonPort))break;
if(Get_BtnLeft()){
BEEP(1000,0.15);
if(--curSeq<0)curSeq=7;
break;
}
if(Get_BtnRight()){
BEEP(1000,0.15);
if(++curSeq>7)curSeq=0;
break;
}
wait(0.05);
}
if(Get_Button()||AI(buttonPort)){
BEEP(1000,0.15);
break;
}
}
dbgLevel = 0;
wait(0.5);
for(i=0;true;i++){
if(Sequence[curSeq][i])Steps++;
else break;
}
if(!Steps){
printf(" Debug\n\n Invalid Sequence %2d\n\n\n\n\n Continue",curSeq);
while(!Get_Button()||AI(buttonPort)){;}
BEEP(1000,0.15);
curStep = 0;
i=0;
Steps=0;
goto A;
}
Steps--;
switch(curSeq){
case 0:
printf(" MATCH\nChoose Sequence:\n >0< 1\n 2 3\n 4 5\n 6 7\n RUNNING SEQ\nPrev Sel Next");
break;
case 1:
printf(" MATCH\nChoose Sequence:\n 0 >1<\n 2 3\n 4 5\n 6 7\n RUNNING SEQ\nPrev Sel Next");
break;
case 2:
printf(" MATCH\nChoose Sequence:\n 0 1\n >2< 3\n 4 5\n 6 7\n RUNNING SEQ\nPrev Sel Next");
break;
case 3:
printf(" MATCH\nChoose Sequence:\n 0 1\n 2 >3<\n 4 5\n 6 7\n RUNNING SEQ\nPrev Sel Next");
break;
case 4:
printf(" MATCH\nChoose Sequence:\n 0 1\n 2 3\n >4< 5\n 6 7\n RUNNING SEQ\nPrev Sel Next");
break;
case 5:
printf(" MATCH\nChoose Sequence:\n 0 1\n 2 3\n 4 >5<\n 6 7\n RUNNING SEQ\nPrev Sel Next");
break;
case 6:
printf(" MATCH\nChoose Sequence:\n 0 1\n 2 3\n 4 5\n >6< 7\n RUNNING SEQ\nPrev Sel Next");
break;
case 7:
printf(" MATCH\nChoose Sequence:\n 0 1\n 2 3\n 4 5\n 6 >7<\n RUNNING SEQ\nPrev Sel Next");
break;
}
while(true){
runsub(curStep,0);
BEEP(1000,0.15);
if(++curStep>Steps){
BEEP(1000,0.15);
break;
}
}
if(++curSeq>7)curSeq=7;
drive(0,0);
setServ(45,512);
goto A;
}
void main_test(){
BEEP(700,0.25);
if(ReadEEOnStart)ReadEE_Fast();
curSeq = defSequence;
int curStep = 0;
int i=0,Steps=0;
bool runFlag=false;
A:
i=0;
Steps=0;
curStep = 0;
runFlag=false;
dbgLevel=defdbgLevel;
int cnt = 0;
if(dbgLevel == 2){
while(true){
while(true){
bool cbatt;
int batt;
batt = Get_Battery();
if(++cnt>15&&(batt<battMin||batt>battMax)){
cbatt = true;
if(cnt>30)cnt=0;
}else{
cbatt = false;
if(!batt<battMin&&!batt>battMax)
cnt=0;
}
switch(curSeq){
case 0:
printf(" Debug\nChoose Sequence:\n >0< 1\n 2 3\n 4 5\n 6 7\nBatt:%d%s\nPrev Sel Next",batt,cbatt?"<-ATTENTION":" ");
break;
case 1:
printf(" Debug\nChoose Sequence:\n 0 >1<\n 2 3\n 4 5\n 6 7\nBatt:%d%s\nPrev Sel Next",batt,cbatt?"<-ATTENTION":" ");
break;
case 2:
printf(" Debug\nChoose Sequence:\n 0 1\n >2< 3\n 4 5\n 6 7\nBatt:%d%s\nPrev Sel Next",batt,cbatt?"<-ATTENTION":" ");
break;
case 3:
printf(" Debug\nChoose Sequence:\n 0 1\n 2 >3<\n 4 5\n 6 7\nBatt:%d%s\nPrev Sel Next",batt,cbatt?"<-ATTENTION":" ");
break;
case 4:
printf(" Debug\nChoose Sequence:\n 0 1\n 2 3\n >4< 5\n 6 7\nBatt:%d%s\nPrev Sel Next",batt,cbatt?"<-ATTENTION":" ");
break;
case 5:
printf(" Debug\nChoose Sequence:\n 0 1\n 2 3\n 4 >5<\n 6 7\nBatt:%d%s\nPrev Sel Next",batt,cbatt?"<-ATTENTION":" ");
break;
case 6:
printf(" Debug\nChoose Sequence:\n 0 1\n 2 3\n 4 5\n >6< 7\nBatt:%d%s\nPrev Sel Next",batt,cbatt?"<-ATTENTION":" ");
break;
case 7:
printf(" Debug\nChoose Sequence:\n 0 1\n 2 3\n 4 5\n 6 >7<\nBatt:%d%s\nPrev Sel Next",batt,cbatt?"<-ATTENTION":" ");
break;
}
if(cnt>29&&cbatt)BEEP(2000,0.25);
else wait(0.05);
if(Get_Button()||AI(buttonPort))break;
if(Get_BtnLeft()){
BEEP(1000,0.15);
if(--curSeq<0)curSeq=7;
break;
}
if(Get_BtnRight()){
BEEP(1000,0.15);
if(++curSeq>7)curSeq=0;
break;
}
}
if(Get_Button()||AI(buttonPort)){
BEEP(1000,0.15);
break;
}
}
while(true){
while(true){
bool cbatt;
int batt;
batt = Get_Battery();
if(++cnt>15&&(batt<battMin||batt>battMax)){
cbatt = true;
if(cnt>30)cnt=0;
}else{
cbatt = false;
if(!batt<battMin&&!batt>battMax)
cnt=0;
}
switch(dbgLevel){
case 0:
printf(" Debug\nChoose dbgLevel:\n\n >0< 1 2\n\n\nBatt:%d%s\nPrev Sel Next",batt,cbatt?"<-ATTENTION":" ");
break;
case 1:
printf(" Debug\nChoose dbgLevel:\n\n 0 >1< 2\n\n\nBatt:%d%s\nPrev Sel Next",batt,cbatt?"<-ATTENTION":" ");
break;
case 2:
printf(" Debug\nChoose dbgLevel:\n\n 0 1 >2<\n\n\nBatt:%d%s\nPrev Sel Next",batt,cbatt?"<-ATTENTION":" ");
break;
}
if(cnt>29&&cbatt)BEEP(2000,0.25);
else wait(0.05);
if(Get_Button()||AI(buttonPort))break;
if(Get_BtnLeft()){
BEEP(1000,0.15);
if(--dbgLevel<0)dbgLevel=2;
break;
}
if(Get_BtnRight()){
BEEP(1000,0.15);
if(++dbgLevel>2)dbgLevel=0;
break;
}
}
if(Get_Button()||AI(buttonPort)){
BEEP(1000,0.15);
break;
}
}
}
if(dbgLevel){
printf(" Debug\n\n Init Servo\n (on port %2d ID %3d)",servoPort,servoID);
wait(0.5);
}
initServ();
if(dbgLevel){
printf(" Debug\n\n Loading Sequence %2d",curSeq);
wait(0.5);
}
for(i=0;true;i++){
if(Sequence[curSeq][i])Steps++;
else break;
}
if(!Steps){
printf(" Debug\n\n Invalid Sequence %2d\n\n\n\n\n Continue",curSeq);
while(!Get_Button()||AI(buttonPort)){;}
BEEP(1000,0.15);
curStep = 0;
i=0;
Steps=0;
goto A;
}
Steps--;
while(true){
if(dbgLevel==2){
runsub(curStep,1);
if(curStep==0){
printf(" Debug\n\n\n Cur==>%2d-%s\n Next: %2d-%s\n\n\nPrev Run Next",curStep,subNameC,curStep+1,subNameN);
}else if(curStep==Steps){
printf(" Debug\n\n Prev: %2d-%s\n Cur==>%2d-%s\n\n\n\nPrev Run Next",curStep-1,subNameP,curStep,subNameC);
}else{
printf(" Debug\n\n Prev: %2d-%s\n Cur==>%2d-%s\n Next: %2d-%s\n\n\nPrev Run Next",curStep-1,subNameP,curStep,subNameC,curStep+1,subNameN);
}
while(true){
if(Get_Button()||AI(buttonPort)){
break;
}
if(Get_BtnLeft()){
int buf=0;
while(Get_BtnLeft()){
buf++;
wait(0.01);
if(buf>150){
BEEP(1000,0.15);
printf(" Debug\n\n Return to SeqSel?");
wait(1);
printf(" Debug\n\n Return to SeqSel?\n\n\n\n\nNo Yes");
while(true){
if(Get_BtnLeft()||Get_BtnRight()){
break;
}
}
if(Get_BtnLeft()){
break;
}
if(Get_BtnRight()){
BEEP(1000,0.15);
goto A;
break;
}
}
}
if(Get_BtnLeft()){
BEEP(1000,0.15);
break;
}
BEEP(1000,0.15);
if(--curStep<0)curStep=Steps;
break;
}
if(Get_BtnRight()){
int buf=0;
bool bufFlag=true;
while(Get_BtnRight()){
buf++;
wait(0.01);
if(buf>150){
bufFlag=false;
BEEP(1000,0.15);
printf(" Debug\n\n Run dhUpdate?");
wait(1);
if(useSafedh)
printf(" Debug\n\n Run dhUpdate?\n\n ***NOTE***\n Safe dh Enabled\n\nNo Yes");
else
printf(" Debug\n\n Run dhUpdate?\n\n\n\n\nNo Yes");
while(true){
if(Get_BtnLeft()||Get_BtnRight()){
break;
}
}
if(Get_BtnLeft()){
while(Get_BtnLeft()){;}
}
if(Get_BtnRight()){
BEEP(1000,0.15);
dhUpdate();
break;
}
}
}
if(bufFlag){
BEEP(1000,0.15);
if(++curStep>Steps)curStep=0;
break;
}else break;
}
if(Get_Button()||AI(buttonPort)){
BEEP(1000,0.15);
printf(" Debug\n\nRunning:\n Seq %2d Step %2d",curSeq,curStep);
runFlag=true;
break;
}
}
}
if(runFlag||dbgLevel!=2){
runsub(curStep,0);
if(dbgLevel){
drive(0,0);
BEEP(700,0.25);
wait(dbgDelay);
}
if(runFlag)runFlag=false;
if(++curStep>Steps){
if(dbgLevel!=2){
printf(" Debug\n\n Seq %2d Completed\n\n\n\n\n Continue",curSeq);
drive(0,0);
BEEP(700,0.25);
while(!Get_Button()&&!AI(buttonPort)){;}
BEEP(1000,0.15);
break;
}else{
curStep--;
}
}
}
}
goto A;
}
void runsub(int sub,bool getName){
if(!getName){
switch(Sequence[curSeq][sub]){
case 1:
Drive_Init();
break;
case 2:
Drive_Departure();
break;
case 3:
Drive_UpStair();
break;
case 4:
Drive_Back();
break;
case 5:
Drive_UtlStop();
break;
case 6:
Drive_CrossJunc();
break;
case 7:
Drive_UtlLeft();
break;
case 8:
Drive_UtlRight();
break;
case 9:
Drive_TurnLeft();
break;
case 10:
Drive_TurnRight();
break;
case 11:
Drive_DownStair();
break;
case 101:
Mission_N01();
break;
case 102:
Mission_N02();
break;
case 103:
Mission_N03();
break;
case 104:
Mission_N04();
break;
case 105:
Mission_N05();
break;
case 106:
Mission_N06();
break;
case 107:
Mission_N07();
break;
case 108:
Mission_N08();
break;
case 109:
Mission_N09();
break;
case 110:
Mission_N10();
break;
case 111:
Mission_N11();
break;
case 112:
Mission_N12();
break;
case 113:
Mission_N13();
break;
case 114:
Mission_N14();
break;
case 115:
Mission_N15();
break;
case 116:
Mission_N16();
break;
case 201:
Act_01();
break;
case 202:
Act_02();
break;
case 203:
Act_03();
break;
case 204:
Act_04();
break;
case 205:
Act_05();
break;
case 206:
Act_06();
break;
case 207:
Act_07();
break;
case 208:
Act_08();
break;
case 209:
Act_09();
break;
case 210:
Act_10();
break;
case 211:
Act_11();
break;
case 212:
Act_12();
break;
case 213:
Act_13();
break;
case 214:
Act_14();
break;
case 215:
Act_15();
break;
case 216:
Act_16();
break;
case 217:
Act_17();
break;
case 218:
Act_18();
break;
case 219:
Act_19();
break;
case 220:
Act_20();
break;
}
}else{
char *subName;
int i=0;
for(i=0;i<3;i++){
switch(Sequence[curSeq][sub-1+i]){
case 1:
subName="D_Init";
break;
case 2:
subName="D_Dept";
break;
case 3:
subName="D_UStair";
break;
case 4:
subName="D_Back";
break;
case 5:
subName="D_UtStop";
break;
case 6:
subName="D_CrJunc";
break;
case 7:
subName="D_UtLeft";
break;
case 8:
subName="D_UtRght";
break;
case 9:
subName="D_TuLeft";
break;
case 10:
subName="D_TuRght";
break;
case 11:
subName="D_DStair";
break;
case 101:
subName="M_N01";
break;
case 102:
subName="M_N02";
break;
case 103:
subName="M_N03";
break;
case 104:
subName="M_N04";
break;
case 105:
subName="M_N05";
break;
case 106:
subName="M_N06";
break;
case 107:
subName="M_N07";
break;
case 108:
subName="M_N08";
break;
case 109:
subName="M_N09";
break;
case 110:
subName="M_N10";
break;
case 111:
subName="M_N11";
break;
case 112:
subName="M_N12";
break;
case 113:
subName="M_N13";
break;
case 114:
subName="M_N14";
break;
case 115:
subName="M_N15";
break;
case 116:
subName="M_N16";
break;
case 201:
subName="A_01";
break;
case 202:
subName="A_02";
break;
case 203:
subName="A_03";
break;
case 204:
subName="A_04";
break;
case 205:
subName="A_05";
break;
case 206:
subName="A_06";
break;
case 207:
subName="A_07";
break;
case 208:
subName="A_08";
break;
case 209:
subName="A_09";
break;
case 210:
subName="A_10";
break;
case 211:
subName="A_11";
break;
case 212:
subName="A_12";
break;
case 213:
subName="A_13";
break;
case 214:
subName="A_14";
break;
case 215:
subName="A_15";
break;
case 216:
subName="A_16";
break;
case 217:
subName="A_17";
break;
case 218:
subName="A_18";
break;
case 219:
subName="A_19";
break;
case 220:
subName="A_20";
break;
default:
subName="*INVALID*";
}
switch(i){
case 0:
subNameP=subName;
break;
case 1:
subNameC=subName;
break;
case 2:
subNameN=subName;
}
}
}
return;
}
void initServ(){
if(!isServInit){
ServoPort_Init(servoPort);
isServInit = true;
}
}
void Drive_Init(){//1
int i=0;
for(i=0;i<7;i++){
rawDh(i);
}
}
void Drive_Departure(){//2
drive(Speed_2,Speed_2);
while(!(dhs(0)||dhs(6))){;}
wait(0.1);
return;
}
void Drive_UpStair(){//3
setServ(-90,512);
int i=0;
for(i=0;i<7;i++){
dh[i]+=dhdet_3;
}
resettime();
while(true){
if(dhs(6)&&seconds()>4){
drive(upSpeed_3,upSpeed_3);
wait(upDelay_3);
drive(mSpeed_3,mSpeed_3);
break;
}else if(dhs(1)){
drive(lSpeed_3,hSpeed_3);
}else if(dhs(5)){
drive(hSpeed_3,lSpeed_3);
}else if(dhs(2)){
drive(mSpeed_3,hSpeed_3);
}else if(dhs(4)){
drive(hSpeed_3,mSpeed_3);
}else if(!dhs(3)){
drive(tSpeed_3,-tSpeed_3);
}else{
drive(hSpeed_3,hSpeed_3);
}
}
for(i=0;i<7;i++){
dh[i]-=dhdet_3;
}
drive(mSpeed_3,mSpeed_3);
wait(0.5);
}
void Drive_Back(){//4
drive(-mSpeed_4,-mSpeed_4);
wait(backDelay_4);
}
void Drive_UtlStop(){//5
int i=0;
while(true){
i++;
if(!GetPrevSpeed(0)&&!GetPrevSpeed(3)&&i>1000){
drive(0,0);
return;
}else if(dhs(1)){
drive(lSpeed_5,hSpeed_5);
}else if(dhs(5)){
drive(hSpeed_5,lSpeed_5);
}else if(dhs(2)){
drive(mSpeed_5,hSpeed_5);
}else if(dhs(4)){
drive(hSpeed_5,mSpeed_5);
}else{
drive(hSpeed_5,hSpeed_5);
}
}
}
void Drive_CrossJunc(){//6
while(true){
if(dhs(0)||dhs(6)){
drive(hSpeed_6,hSpeed_6);
while((dhs(0)||dhs(6))){;}
wait(0.1);
return;
}else if(dhs(1)){
drive(lSpeed_6,hSpeed_6);
}else if(dhs(5)){
drive(hSpeed_6,lSpeed_6);
}else if(dhs(2)){
drive(mSpeed_6,hSpeed_6);
}else if(dhs(4)){
drive(hSpeed_6,mSpeed_6);
}else if(!dhs(3)){
drive(tSpeed_6,-tSpeed_6);
}else{
drive(hSpeed_6,hSpeed_6);
}
}
}
void Drive_UtlLeft(){//7
while(true){
if(dhs(0)){
drive(tSpeed_7,tSpeed_7);
wait(btDelay_7);
drive(-tSpeed_7,tSpeed_7);
wait(bttDelay_7);
while(!dhs(2)){;}
return;
}else if(dhs(1)){
drive(lSpeed_7,hSpeed_7);
}else if(dhs(5)){
drive(hSpeed_7,lSpeed_7);
}else if(dhs(2)){
drive(mSpeed_7,hSpeed_7);
}else if(dhs(4)){
drive(hSpeed_7,mSpeed_7);
}else if(!dhs(3)){
drive(tSpeed_7,-tSpeed_7);
}else{
drive(hSpeed_7,hSpeed_7);
}
}
}
void Drive_UtlRight(){//8
while(true){
if(dhs(6)){
drive(tSpeed_8,tSpeed_8);
wait(btDelay_8);