Miya Miyagawa
/
OREWOTAOSITAI
aaaaa
Diff: System/Process/Process.cpp
- Revision:
- 12:8321e464475f
- Parent:
- 11:88f17bc0724f
--- a/System/Process/Process.cpp Mon Feb 25 05:48:20 2019 +0000 +++ b/System/Process/Process.cpp Mon Feb 25 06:44:02 2019 +0000 @@ -52,60 +52,63 @@ float s=Airtime.read();//エアータイム int a_array[15][15] = { -{-80, -70, -60, -50, -40, -20, -10, 0, 10, 20, 40, 50, 60, 70, 80}, -{-79, -69, -55, -47, -35, -20, -10, 0, 10, 20, 35, 47, 55, 69, 79}, -{-77, -68, -50, -45, -30, -20, -10, 0, 10, 20, 30, 45, 50, 68, 77}, -{-75, -67, -49, -40, -25, -20, -10, 0, 10, 20, 25, 40, 49, 67, 75}, -{-73, -66, -48, -37, -20, -20, -10, 0, 10, 20, 20, 37, 48, 66, 73}, -{-71, -62, -46, -32, -20, -10, 0 , 0, 0 , 10, 20, 32, 46, 62, 71}, -{-70, -60, -45, -30, -20, -10, 0 , 0, 0 , 10, 20, 30, 45, 60, 70}, -{-71, -62, -46, -32, 10 , -10, 0 , 0, 0 , 10, 20, 32, 46, 62, 71}, -{-72, -64, -47, -35, 20 , -10, -10, 0, 10, 10, 20, 35, 47, 64, 72}, -{-73, -66, -48, -37, -20, -20, -10, 0, 10, 20, 20, 37, 48, 66, 73}, -{-75, -67, -49, -40, 40 , -20, -10, 0, 10, 20, 25, 40, 49, 67, 75}, -{-77, -68, -50, -45, 60 , -20, -10, 0, 10, 20, 30, 45, 50, 68, 77}, -{-79, -69, -55, -47, 70 , -20, -10, 0, 10, 20, 35, 47, 55, 69, 79}, -{-80, -70, -60, -50, -40, -20, -10, 0, 10, 20, 40, 50, 60, 70, 80}, -{-80, -70, -60, -50, -40, -20,s-10, 0, 10, 20, 40, 50, 60, 70, 80}}; + {-80, -70, -60, -50, -40, -20, -10, 0, 10, 20, 40, 50, 60, 70, 80}, + {-79, -69, -55, -47, -35, -20, -10, 0, 10, 20, 35, 47, 55, 69, 79}, + {-77, -68, -50, -45, -30, -20, -10, 0, 10, 20, 30, 45, 50, 68, 77}, + {-75, -67, -49, -40, -25, -20, -10, 0, 10, 20, 25, 40, 49, 67, 75}, + {-73, -66, -48, -37, -20, -20, -10, 0, 10, 20, 20, 37, 48, 66, 73}, + {-71, -62, -46, -32, -20, -10, 0, 0, 0, 10, 20, 32, 46, 62, 71}, + {-70, -60, -45, -30, -20, -10, 0, 0, 0, 10, 20, 30, 45, 60, 70}, + {-71, -62, -46, -32, 10, -10, 0, 0, 0, 10, 20, 32, 46, 62, 71}, + {-72, -64, -47, -35, 20, -10, -10, 0, 10, 10, 20, 35, 47, 64, 72}, + {-73, -66, -48, -37, -20, -20, -10, 0, 10, 20, 20, 37, 48, 66, 73}, + {-75, -67, -49, -40, 40, -20, -10, 0, 10, 20, 25, 40, 49, 67, 75}, + {-77, -68, -50, -45, 60, -20, -10, 0, 10, 20, 30, 45, 50, 68, 77}, + {-79, -69, -55, -47, 70, -20, -10, 0, 10, 20, 35, 47, 55, 69, 79}, + {-80, -70, -60, -50, -40, -20, -10, 0, 10, 20, 40, 50, 60, 70, 80}, + {-80, -70, -60, -50, -40, -20,s-10, 0, 10, 20, 40, 50, 60, 70, 80} +}; int b_array[15][15] = { -{80, 80, 80 , 77 , 75 , 72 , 71 , 70, 60, 50, 40, 30, 20, 10, 0}, -{80, 80, 75 , 70 , 65 , 60 , 55 , 50, 45, 40, 30, 20, 10, 0 , -10}, -{80, 71, 70 , 60 , 55 , 50 , 45 , 40, 35, 30, 20, 10, 0, -10, -13}, -{60, 60, 57 , 50 , 45 , 40 , 35 , 30, 25, 20, 10, 0 , -10, -13, -17}, -{50, 50, 50 , 40 , 35 , 30 , 23 , 20, 15, 10, 0 , -10, -15, -17, -20}, -{45, 45, 43 , 35 , 30 , 25 , 10 , 10, 10, 0 , -10, -15, -20, -20, -25}, -{40, 37, 35 , 30 , 25 , 20 , 0 , 0 , 0 , -10, -15, -20, -25, -25, -30}, -{35, 30, 30 , 25 , 20 , 15 , 0 , 0 , 0 , -15, -20, -25, -30, -30, -35}, -{30, 25, 25 , 20 , 15 , 10 , 0 , 0 , 0 , -20, -25, -30, -35, -37, -40}, -{20, 17, 15 , 10 , 0 , -10, -15,-20, -23, -30 ,-35 ,-40 ,-50 ,-50 , -50}, -{17, 13, 10 , 0 , -10, -20, -25,-30, -35, -40 ,-45 ,-50 ,-57 ,-60 , -60}, -{13, 10, 0 , -10, -20, -30, -35,-40, -45, -50 ,-55 ,-60 , -70, -71, -80}, -{10, 0 , -10, -20, -30, -40, -45,-50, -55, -60 ,-65 ,-70 ,-75 ,-80 , -80}, -{0 , -10, -20, -30, -40, -50, -60,-70, -71, -72 ,-75 ,-77 ,-80 ,-80 , -80}, -{0 , -10, -20, -30, -40, -50, -60,-70, -71, -72 ,-75 ,-77 ,-80 ,-80 , -80}}; + {80, 80, 80, 77, 75, 72, 71, 70, 60, 50, 40, 30, 20, 10, 0}, + {80, 80, 75, 70, 65, 60, 55, 50, 45, 40, 30, 20, 10, 0, -10}, + {80, 71, 70, 60, 55, 50, 45, 40, 35, 30, 20, 10, 0, -10, -13}, + {60, 60, 57, 50, 45, 40, 35, 30, 25, 20, 10, 0, -10, -13, -17}, + {50, 50, 50, 40, 35, 30, 23, 20, 15, 10, 0, -10, -15, -17, -20}, + {45, 45, 43, 35, 30, 25, 10, 10, 10, 0, -10, -15, -20, -20, -25}, + {40, 37, 35, 30, 25, 20, 0, 0, 0, -10, -15, -20, -25, -25, -30}, + {35, 30, 30, 25, 20, 15, 0, 0, 0, -15, -20, -25, -30, -30, -35}, + {30, 25, 25, 20, 15, 10, 0, 0, 0, -20, -25, -30, -35, -37, -40}, + {20, 17, 15, 10, 0, -10, -15,-20, -23, -30,-35,-40,-50,-50, -50}, + {17, 13, 10, 0, -10, -20, -25,-30, -35, -40,-45,-50,-57,-60, -60}, + {13, 10, 0, -10, -20, -30, -35,-40, -45, -50,-55,-60, -70, -71, -80}, + {10, 0, -10, -20, -30, -40, -45,-50, -55, -60,-65,-70,-75,-80, -80}, + {0, -10, -20, -30, -40, -50, -60,-70, -71, -72,-75,-77,-80,-80, -80}, + {0, -10, -20, -30, -40, -50, -60,-70, -71, -72,-75,-77,-80,-80, -80} +}; - int c_array[15][15] = { -{0, 10, 20 , 30 , 40 , 50 , 60 ,70 , 71, 72 , 75 , 77 , 80 , 80 , 80}, -{-10, 0 , 10 , 20 , 30 , 40 , 45 ,50 , 55 , 60 ,65 ,70 ,75 ,80 ,80}, -{-13, -10, 0 , 10 , 20 , 30 , 35 ,40 , 45 , 50 ,55 ,60 ,70 ,71 ,80}, -{-17, -13, -10, 0 , 10 , 20 , 25 ,30 , 35 , 40 ,45 ,50 ,57 ,60 ,60}, -{-20, -17, -15, -10, 0 , 10 , 15 ,20 , 23 , 30 ,35 ,40 ,50 ,50 ,50}, -{-25, -20, -20, -15, -10, 0 , 10 ,10 , 10 , 25 ,30 ,35 ,43 ,45 ,45}, -{-30, -25, -25, -20, -15, -10, 0 ,0 , 0 , 20 ,25 ,30 ,35 ,37 ,40}, -{-35, -30, -30, -25, -20, -15, 0 ,0 , 0 , 15 ,20 ,25 ,30 ,30 ,35}, -{-40, -37, -35, -30, -25, -20, 0 ,0 , 0 , 10 ,15 ,20 ,25 ,25 ,30}, -{-50, -50, -50, -40, -35, -30, -23,-20, -15, -10 ,0 ,10 ,15 ,17 ,20}, -{-60, -60, -57, -50, -45, -40, -35,-30, -25, -20 ,-10 ,0 ,10 ,13 ,17}, -{-80, -71, -70, -60, -55, -50, -45,-40, -35, -30 ,-20 ,-10 ,0 ,10 ,13}, -{-80, -80, -75, -70, -65, -60, -55,-50, -45, -40 ,-30 ,-20 ,-10 ,0 ,10}, -{-80, -80, -80, -77, -75, -72, -71,-70, -60, -50 ,-40 ,-30 ,-20 ,-10 ,0}, -{-80, -80, -80, -77, -75, -72, -71,-70, -60, -50 ,-40 ,-30 ,-20 ,-10 ,0}}; +int c_array[15][15] = { + {0, 10, 20, 30, 40, 50, 60,70, 71, 72, 75, 77, 80, 80, 80}, + {-10, 0, 10, 20, 30, 40, 45,50, 55, 60,65,70,75,80,80}, + {-13, -10, 0, 10, 20, 30, 35,40, 45, 50,55,60,70,71,80}, + {-17, -13, -10, 0, 10, 20, 25,30, 35, 40,45,50,57,60,60}, + {-20, -17, -15, -10, 0, 10, 15,20, 23, 30,35,40,50,50,50}, + {-25, -20, -20, -15, -10, 0, 10,10, 10, 25,30,35,43,45,45}, + {-30, -25, -25, -20, -15, -10, 0,0, 0, 20,25,30,35,37,40}, + {-35, -30, -30, -25, -20, -15, 0,0, 0, 15,20,25,30,30,35}, + {-40, -37, -35, -30, -25, -20, 0,0, 0, 10,15,20,25,25,30}, + {-50, -50, -50, -40, -35, -30, -23,-20, -15, -10,0,10,15,17,20}, + {-60, -60, -57, -50, -45, -40, -35,-30, -25, -20,-10,0,10,13,17}, + {-80, -71, -70, -60, -55, -50, -45,-40, -35, -30,-20,-10,0,10,13}, + {-80, -80, -75, -70, -65, -60, -55,-50, -45, -40,-30,-20,-10,0,10}, + {-80, -80, -80, -77, -75, -72, -71,-70, -60, -50,-40,-30,-20,-10,0}, + {-80, -80, -80, -77, -75, -72, -71,-70, -60, -50,-40,-30,-20,-10,0} +}; - - + + #define usiro 0 #define mae 0 @@ -117,7 +120,7 @@ int conrx; int conry; -int mode=0; +int mode=1; //↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ //_____________________ @@ -131,174 +134,175 @@ using namespace SWITCH; -void SystemProcess(void) { +void SystemProcess(void) +{ while(true) { controller = XBEE::Controller::GetData(); //____________________________ -/*------------------------ HOW TO WRITE ------------------------/ + /*------------------------ HOW TO WRITE ------------------------/ - ここにメインのプログラムを書く + ここにメインのプログラムを書く - ・コントローラから受け取ったデータをもとに動作のプログラムを書く - (コントローラのデータは controller-> で取る) + ・コントローラから受け取ったデータをもとに動作のプログラムを書く + (コントローラのデータは controller-> で取る) - if(controller->Button.RIGHT) { - motor[TIRE_L].dir = FOR; - motor[TIRE_R].dir = BACK; - motor[TIRE_L].pwm = 12.3; - motor[TIRE_R].pwm = 12.3; - } + if(controller->Button.RIGHT) { + motor[TIRE_L].dir = FOR; + motor[TIRE_R].dir = BACK; + motor[TIRE_L].pwm = 12.3; + motor[TIRE_R].pwm = 12.3; + } - motor[0].dirは FOR (正転) - BACK (逆転) - BRAKE (ブレーキ) - FREE (フリー) + motor[0].dirは FOR (正転) + BACK (逆転) + BRAKE (ブレーキ) + FREE (フリー) - motor[0].pwmは 0.0(%) ~ 100.0(%) + motor[0].pwmは 0.0(%) ~ 100.0(%) - controllerは XBee.hの構造体の中身 + controllerは XBee.hの構造体の中身 - (AnalogL・Rを使いたかったら、頑張って考える or 聞いてください) + (AnalogL・Rを使いたかったら、頑張って考える or 聞いてください) - ・リミットスイッチの値をもとに動作のプログラムを書く + ・リミットスイッチの値をもとに動作のプログラムを書く - if(Switch::CheckPushed(ARM_L)) - { - if(controller->Button.L) - { - motor[ARM].dir = FOR; - motor[ARM].pwm = 80.0; - } - if(motor[ARM].dir == BACK) - { - motor[ARM].dir = BRAKE; - } - } + if(Switch::CheckPushed(ARM_L)) + { + if(controller->Button.L) + { + motor[ARM].dir = FOR; + motor[ARM].pwm = 80.0; + } + if(motor[ARM].dir == BACK) + { + motor[ARM].dir = BRAKE; + } + } - →関数 Switch::CheckPushed の引数はリミットスイッチの名前 (limitSw[0]みたいな), 返り値はbool型 (true or false) + →関数 Switch::CheckPushed の引数はリミットスイッチの名前 (limitSw[0]みたいな), 返り値はbool型 (true or false) - ・他にもやりたいことがあったら自由にどうぞ + ・他にもやりたいことがあったら自由にどうぞ - ps.わからないことがあったら聞いてください + ps.わからないことがあったら聞いてください -/------------------------ HOW TO WRITE ------------------------*/ + /------------------------ HOW TO WRITE ------------------------*/ //↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ -conlx = controller->AnalogL.X; -conly = controller->AnalogL.Y; -conrx = controller->AnalogR.X; -conry = controller->AnalogR.Y; + conlx = controller->AnalogL.X; + conly = controller->AnalogL.Y; + conrx = controller->AnalogR.X; + conry = controller->AnalogR.Y; //conba = controller->Button.A; //conbb = controller->Button.B; //conby = controller->Button.Y; //conbx = controller->Button.X; - if(a_array[conly][conlx]<0){ - motor[a].pwm = (-1*a_array[conly][conlx]*100)/80; - motor[a].dir = FOR; - }else if(a_array[conly][conlx] > 0){ - motor[a].pwm = (a_array[conly][conlx]*100)/80; - motor[a].dir = BACK; - }else if(a_array[conly][conlx] == 0){ - if(conry < 6){ - motor[a].dir = BACK; - motor[b].dir = BACK; - motor[c].dir = BACK; - motor[a].pwm = 100.0; - motor[b].pwm = 100.0; - motor[c].pwm = 100.0; - }else if(conry > 8){ + if(a_array[conly][conlx]<0) { + motor[a].pwm = (-1*a_array[conly][conlx]*100)/80; motor[a].dir = FOR; - motor[b].dir = FOR; - motor[c].dir = FOR; - motor[a].pwm = 100.0; - motor[b].pwm = 100.0; - motor[c].pwm = 100.0; - }else{ - motor[a].dir = BRAKE; - motor[b].dir = BRAKE; - motor[c].dir = BRAKE; - motor[a].pwm = 100.0; - motor[b].pwm = 100.0; - motor[c].pwm = 100.0; + } else if(a_array[conly][conlx] > 0) { + motor[a].pwm = (a_array[conly][conlx]*100)/80; + motor[a].dir = BACK; + } else if(a_array[conly][conlx] == 0) { + if(conry < 6) { + motor[a].dir = BACK; + motor[b].dir = BACK; + motor[c].dir = BACK; + motor[a].pwm = 100.0; + motor[b].pwm = 100.0; + motor[c].pwm = 100.0; + } else if(conry > 8) { + motor[a].dir = FOR; + motor[b].dir = FOR; + motor[c].dir = FOR; + motor[a].pwm = 100.0; + motor[b].pwm = 100.0; + motor[c].pwm = 100.0; + } else { + motor[a].dir = BRAKE; + motor[b].dir = BRAKE; + motor[c].dir = BRAKE; + motor[a].pwm = 100.0; + motor[b].pwm = 100.0; + motor[c].pwm = 100.0; + } } - } - - if(b_array[conly][conlx] <0 ){ - motor[b].pwm = (-1*b_array[conly][conlx]*100)/80; - motor[b].dir = FOR; - }else if(b_array[conly][conlx] > 0){ - motor[b].pwm = (b_array[conly][conlx]*100)/80; - motor[b].dir = BACK; - }else if(a_array[conly][conlx] == 0 ){ - if(conrx < 6 ) { - motor[a].dir = BACK; - motor[b].dir = BACK; - motor[c].dir = BACK; - motor[a].pwm = 100.0; - motor[b].pwm = 100.0; - motor[c].pwm = 100.0; - }else if(conrx > 8){ - motor[a].dir = FOR; + + if(b_array[conly][conlx] <0 ) { + motor[b].pwm = (-1*b_array[conly][conlx]*100)/80; motor[b].dir = FOR; - motor[c].dir = FOR; - motor[a].pwm = 100.0; - motor[b].pwm = 100.0; - motor[c].pwm = 100.0; - }else{ - motor[a].dir = BRAKE; - motor[b].dir = BRAKE; - motor[c].dir = BRAKE; - motor[a].pwm = 100.0; - motor[b].pwm = 100.0; - motor[c].pwm = 100.0; - } - } - - if(c_array[conly][conlx] <0 ){ - motor[c].pwm =(-1*c_array[conly][conlx]*100)/80; - motor[c].dir = BACK; - }else if(c_array[conly][conlx] > 0){ - motor[c].pwm =(c_array[conly][conlx]*100)/80; - motor[c].dir = FOR; - }else if(a_array[conly][conlx] == 0 ){ - if(conrx < 6 ) { - motor[a].dir = BACK; + } else if(b_array[conly][conlx] > 0) { + motor[b].pwm = (b_array[conly][conlx]*100)/80; motor[b].dir = BACK; + } else if(a_array[conly][conlx] == 0 ) { + if(conrx < 6 ) { + motor[a].dir = BACK; + motor[b].dir = BACK; + motor[c].dir = BACK; + motor[a].pwm = 100.0; + motor[b].pwm = 100.0; + motor[c].pwm = 100.0; + } else if(conrx > 8) { + motor[a].dir = FOR; + motor[b].dir = FOR; + motor[c].dir = FOR; + motor[a].pwm = 100.0; + motor[b].pwm = 100.0; + motor[c].pwm = 100.0; + } else { + motor[a].dir = BRAKE; + motor[b].dir = BRAKE; + motor[c].dir = BRAKE; + motor[a].pwm = 100.0; + motor[b].pwm = 100.0; + motor[c].pwm = 100.0; + } + } + + if(c_array[conly][conlx] <0 ) { + motor[c].pwm =(-1*c_array[conly][conlx]*100)/80; motor[c].dir = BACK; - motor[a].pwm = 100.0; - motor[b].pwm = 100.0; - motor[c].pwm = 100.0; - }else if(conrx > 8){ - motor[a].dir = FOR; - motor[b].dir = FOR; + } else if(c_array[conly][conlx] > 0) { + motor[c].pwm =(c_array[conly][conlx]*100)/80; motor[c].dir = FOR; - motor[a].pwm = 100.0; - motor[b].pwm = 100.0; - motor[c].pwm = 100.0; - }else{ - motor[a].dir = BRAKE; - motor[b].dir = BRAKE; - motor[c].dir = BRAKE; - motor[a].pwm = 100.0; - motor[b].pwm = 100.0; - motor[c].pwm = 100.0; + } else if(a_array[conly][conlx] == 0 ) { + if(conrx < 6 ) { + motor[a].dir = BACK; + motor[b].dir = BACK; + motor[c].dir = BACK; + motor[a].pwm = 100.0; + motor[b].pwm = 100.0; + motor[c].pwm = 100.0; + } else if(conrx > 8) { + motor[a].dir = FOR; + motor[b].dir = FOR; + motor[c].dir = FOR; + motor[a].pwm = 100.0; + motor[b].pwm = 100.0; + motor[c].pwm = 100.0; + } else { + motor[a].dir = BRAKE; + motor[b].dir = BRAKE; + motor[c].dir = BRAKE; + motor[a].pwm = 100.0; + motor[b].pwm = 100.0; + motor[c].pwm = 100.0; + } } - } - + ////////////課題1//////////// - if(controller->Button.X){ - if(Switch::checkPushed(ARMlim)){ + if(controller->Button.X) { + if(Switch::checkPushed(ARMlim)) { motor[d].dir = BRAKE; motor[d].pwm = 100; - }else{ + } else { motor[d].dir = FOR; motor[d].pwm = 100; - } - }else if(controller->Button.Y){ + } + } else if(controller->Button.Y) { motor[d].dir = BACK; motor[d].pwm = 100; - }else{ + } else { motor[d].dir = BRAKE; motor[d].pwm = 100; } @@ -308,47 +312,50 @@ AirOut(Air0,0); } //////////////課題2///////////////////// -// if((controller->Button.ZL)&&(mode==0)) { -// Airtime.start(); -// AirOut(Air1,0); -// } -// if((s>1)&&(s<3)) { -// AirOut(Air1,1); -// }else if(s>=3){ -// Airtime.stop(); -// Airtime.reset(); -// mode=1; -// } -// if((mode==2)||((controller->Button.ZR)&&(mode==1))) { -// motor[4].dir=FOR; -// motor[4].pwm=10; -// } -// if(!(Switch::checkPushed(lim))&&(mode==1)){ -// mode=2; -// } -// if((Switch::checkPushed(lim))&&(mode==2)){ -// motor[4].dir=BRAKE; -// motor[4].pwm=100; -// mode=0; -// } -// -// if (controller->Button.ZL) -// AiOut(Air1,0); + s=Airtime.read(); + if((controller->Button.ZL)&&(mode==1)) { + mode=2; + Airtime.start(); + } + if((mode==2)&&(s>=1)) { + mode=3; + } + if((mode==3)&&(s>=3)) { + mode=4; + } + if((mode==4)&&(!(Switch::checkPushed(lim)))) { + mode=5; + Airtime.stop(); + Airtime.reset(); + } + if((mode==5)&&(Switch::checkPushed(lim))) { + mode=1; + } - if(controller->Button.ZL){ - AirOut(Air1,1) - AirOut(Air1.0) - motor[4].dir = FOR; - motor[4].pwm = 100.0; - if(Switch::checkPushed(lim)){ - motor. - } - + if(mode==1) { + AirOut(1,1); + motor[4].dir=BRAKE; + motor[4].pwm=100; + } else if(mode==2) { + AirOut(1,0); + } else if(mode==3) { + AirOut(1,1); + } else if(mode==4) { + motor[4].dir=FOR; + motor[4].pwm=50; + } else if(mode==5) { + motor[4].dir=FOR; + motor[4].pwm=50; + } else { + mode=1; + AirOut(1,1); + } + //↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ //___________________________ - + MOTOR::Motor::Update(motor); } } \ No newline at end of file