aa

Dependencies:   mbed

Revision:
49:697b4e9ce884
Parent:
48:5562a99479e5
Child:
50:87f5fa1bc460
--- a/System/Process/Process.cpp	Tue Nov 12 11:49:18 2019 +0000
+++ b/System/Process/Process.cpp	Wed Nov 13 09:20:49 2019 +0000
@@ -274,7 +274,7 @@
             } else {
                 countss = 0;
                 mode=1;
-                current = 2;
+                current = 2;//11ガツ13ニチヘンコウ
             }
         }
         if(DWSW||DOSW) {
@@ -504,7 +504,7 @@
     } else if(mode==10) { //縦ライントレース
         switch(g[1]) {
             case 98:
-                motor[TIRE_FR].pwm = normal+50;
+                motor[TIRE_FR].pwm = normal+55;
                 motor[TIRE_FR].dir = FOR;
                 motor[TIRE_FL].pwm = normal+50;
                 motor[TIRE_FL].dir = BACK;
@@ -534,7 +534,7 @@
                 }
                 break;
             case 0:
-                motor[TIRE_FR].pwm = fast+50;
+                motor[TIRE_FR].pwm = fast+55;
                 motor[TIRE_FR].dir = FOR;
                 motor[TIRE_FL].pwm = fast+50;
                 motor[TIRE_FL].dir = BACK;
@@ -545,7 +545,7 @@
                 mtc=true;
                 break;
             case 255:
-                motor[TIRE_FR].pwm = fast+50;
+                motor[TIRE_FR].pwm = fast+55;
                 motor[TIRE_FR].dir = FOR;
                 motor[TIRE_FL].pwm = slow+50;
                 motor[TIRE_FL].dir = BACK;
@@ -556,7 +556,7 @@
                 mtc=true;
                 break;
             case 253:
-                motor[TIRE_FR].pwm = slow+50;
+                motor[TIRE_FR].pwm = slow+55;
                 motor[TIRE_FR].dir = FOR;
                 motor[TIRE_FL].pwm = 0;
                 motor[TIRE_FL].dir = FREE;
@@ -567,7 +567,7 @@
                 mtc=true;
                 break;
             case 254:
-                motor[TIRE_FR].pwm = normal+50;
+                motor[TIRE_FR].pwm = normal+55;
                 motor[TIRE_FR].dir = FOR;
                 motor[TIRE_FL].pwm = 0;
                 motor[TIRE_FL].dir = FREE;
@@ -578,7 +578,7 @@
                 mtc=true;
                 break;
             case 1:
-                motor[TIRE_FR].pwm = slow+50;
+                motor[TIRE_FR].pwm = slow+55;
                 motor[TIRE_FR].dir = FOR;
                 motor[TIRE_FL].pwm = fast+50;
                 motor[TIRE_FL].dir = BACK;
@@ -662,15 +662,15 @@
         solenoid.solenoid2= SOLENOID_ON;
         switch(g[2]) {
             case 98:
-                motor[TIRE_FR].pwm = normal-20;
+                motor[TIRE_FR].pwm = normal;
                 motor[TIRE_FR].dir = FOR;
-                motor[TIRE_FL].pwm = normal-20;
+                motor[TIRE_FL].pwm = normal;
                 motor[TIRE_FL].dir = FOR;
-                motor[TIRE_BR].pwm = normal-20;
+                motor[TIRE_BR].pwm = normal;
                 motor[TIRE_BR].dir = BACK;
-                motor[TIRE_BL].pwm = normal-20;
+                motor[TIRE_BL].pwm = normal;
                 motor[TIRE_BL].dir = BACK;
-                if(countss>10000) {
+                if(countss>20000) {
                     cross++;
                     countss=0;
                 }
@@ -681,7 +681,8 @@
                         fast=20;
                         normal=15;
                         slow=15;
-                    } else if(cross==2) {
+                    }
+                    if(cross==2) {
                         mode=21;
                         countss=0;
                         cross=0;
@@ -1028,6 +1029,11 @@
                     motor[TIRE_BL].dir = FOR;
                     break;
             }
+            if(g[0]==98) {
+                fast=30;
+                normal=25;
+                slow=20;
+            }
             if(g[2]==254&&countss>=100000) {
                 mode=24;
                 solenoid.solenoid2 = SOLENOID_OFF;
@@ -1274,7 +1280,7 @@
             motor[TIRE_BR].dir = BACK;
             motor[TIRE_BL].pwm = 255;
             motor[TIRE_BL].dir = BRAKE;
-            if(g[1]==0) {
+            if(g[0]==0) {
                 mode=22;
                 fast=60;
                 normal=40;
@@ -1619,6 +1625,9 @@
             mode=40;
         }
     } else if(mode==40) {
+        if(LIF||LIB) {
+            mode=42;
+        }
         switch(g[3]) {
             case 98:
                 motor[TIRE_FR].pwm = normal+15;
@@ -1634,10 +1643,18 @@
                     countss=0;
                 }
                 mtc2=true;
-                if(cross==1) {
-                    mode=41;
-                    countss=0;
-                    cross=0;
+                if(YELLOW) {
+                    if(cross==1) {
+                        mode=41;
+                        countss=0;
+                        cross=0;
+                    }
+                } else {
+                    if(cross==3) {
+                        mode=41;
+                        countss=0;
+                        cross=0;
+                    }
                 }
                 break;
             case 0:
@@ -3448,24 +3465,28 @@
                 motor[TIRE_BL].pwm = normal+50;
                 motor[TIRE_BL].dir = BACK;
                 mtc=true;
-                if(countss>80000) {
-                    cross++;
-                    countss=0;
-                }
+                if(YELLOW) {
+                    if(countss>80000) {
+                        cross++;
+                        countss=0;
+                    }
 
-                if(cross==2) {
-                    fast = 10;
-                    normal = 10;
-                    slow = 5;
-                }
+                    if(cross==2) {
+                        fast = 10;
+                        normal = 10;
+                        slow = 5;
+                    }
 
-                if(cross==3) {
-                    fast=40;
-                    normal=30;
-                    slow=20;
+                    if(cross==3) {
+                        fast=40;
+                        normal=30;
+                        slow=20;
+                        mode=11;
+                        countss=0;
+                        cross=0;
+                    }
+                } else {
                     mode=11;
-                    countss=0;
-                    cross=0;
                 }
                 break;
             case 0:
@@ -3582,10 +3603,10 @@
     } else if(mode==11) {
         motor[TIRE_FR].pwm = normal;
         motor[TIRE_FR].dir = FOR;
-        motor[TIRE_FL].pwm = 25;
-        motor[TIRE_FL].dir = FOR;
-        motor[TIRE_BR].pwm = 25;
-        motor[TIRE_BR].dir = FOR;
+        motor[TIRE_FL].pwm = 50;
+        motor[TIRE_FL].dir = BRAKE;
+        motor[TIRE_BR].pwm = 50;
+        motor[TIRE_BR].dir = BRAKE;
         motor[TIRE_BL].pwm = normal;
         motor[TIRE_BL].dir = BACK;
         if(g[2]==0 || g[2]==255 || g[2]==254 || g[2]==253) {
@@ -3594,7 +3615,6 @@
             mode=20;
         }
     } else if(mode==20) {
-        solenoid.solenoid4= SOLENOID_ON;
         switch(g[2]) {
             case 98:
                 motor[TIRE_FR].pwm = normal+20;
@@ -3612,6 +3632,7 @@
                 mtc2=true;
 
                 if(YELLOW) {
+                    solenoid.solenoid4= SOLENOID_ON;
                     if(cross==1) {
                         fast=20;
                         normal=15;
@@ -3622,6 +3643,11 @@
                         cross=0;
                     }
                 } else {
+                    if(cross==2) {
+                        fast=20;
+                        normal=15;
+                        slow=15;
+                    }
                     if(cross==3) {
                         mode=21;
                         countss=0;
@@ -4134,181 +4160,10 @@
         }
     } else {
         if(mode==21) {
-            motor[TIRE_FR].pwm = 255;
-            motor[TIRE_FR].dir = BRAKE;
-            motor[TIRE_FL].pwm = 30;
-            motor[TIRE_FL].dir = FOR;
-            motor[TIRE_BR].pwm = 30;
-            motor[TIRE_BR].dir = BACK;
-            motor[TIRE_BL].pwm = 255;
-            motor[TIRE_BL].dir = BRAKE;
-            if(g[1]==0) {
-                mode=22;
+            if(g[0]==98&&countss>=40000) {
                 fast=60;
-                normal=40;
-                slow=25;
-            }
-        } else if(mode==22) {
-            if(g[0]==98) {
-                slow=25;
                 normal=30;
-                fast=40;
-            }
-            if(g[3]==0) {
                 slow=25;
-                normal=40;
-                fast=40;
-                mode=23;
-            }
-            switch(g[0]) {
-                case 98:
-                    solenoid.solenoid4 = SOLENOID_OFF;
-                    fast=40;
-                    normal=30;
-                    slow=25;
-                    motor[TIRE_FR].pwm = normal;
-                    motor[TIRE_FR].dir = BACK;
-                    motor[TIRE_FL].pwm = normal;
-                    motor[TIRE_FL].dir = FOR;
-                    motor[TIRE_BR].pwm = normal;
-                    motor[TIRE_BR].dir = BACK;
-                    motor[TIRE_BL].pwm = normal;
-                    motor[TIRE_BL].dir = FOR;
-                    break;
-                case 0:
-                    motor[TIRE_FR].pwm = fast;
-                    motor[TIRE_FR].dir = BACK;
-                    motor[TIRE_FL].pwm = fast;
-                    motor[TIRE_FL].dir = FOR;
-                    motor[TIRE_BR].pwm = fast;
-                    motor[TIRE_BR].dir = BACK;
-                    motor[TIRE_BL].pwm = fast;
-                    motor[TIRE_BL].dir = FOR;
-                    mtc=true;
-                    break;
-                case 255:
-                    motor[TIRE_FR].pwm = fast;
-                    motor[TIRE_FR].dir = BACK;
-                    motor[TIRE_FL].pwm = slow;
-                    motor[TIRE_FL].dir = FOR;
-                    motor[TIRE_BR].pwm = slow;
-                    motor[TIRE_BR].dir = BACK;
-                    motor[TIRE_BL].pwm = fast;
-                    motor[TIRE_BL].dir = FOR;
-                    mtc=true;
-                    break;
-                case 253:
-                    motor[TIRE_FR].pwm = slow;
-                    motor[TIRE_FR].dir = BACK;
-                    motor[TIRE_FL].pwm = 0;
-                    motor[TIRE_FL].dir = FREE;
-                    motor[TIRE_BR].pwm = 0;
-                    motor[TIRE_BR].dir = FREE;
-                    motor[TIRE_BL].pwm = slow;
-                    motor[TIRE_BL].dir = FOR;
-                    mtc=true;
-                    break;
-                case 254:
-                    motor[TIRE_FR].pwm = normal;
-                    motor[TIRE_FR].dir = BACK;
-                    motor[TIRE_FL].pwm = 0;
-                    motor[TIRE_FL].dir = FREE;
-                    motor[TIRE_BR].pwm = 0;
-                    motor[TIRE_BR].dir = FREE;
-                    motor[TIRE_BL].pwm = normal;
-                    motor[TIRE_BL].dir = FOR;
-                    mtc=true;
-                    break;
-                case 1:
-                    motor[TIRE_FR].pwm = slow;
-                    motor[TIRE_FR].dir = BACK;
-                    motor[TIRE_FL].pwm = fast;
-                    motor[TIRE_FL].dir = FOR;
-                    motor[TIRE_BR].pwm = fast;
-                    motor[TIRE_BR].dir = BACK;
-                    motor[TIRE_BL].pwm = slow;
-                    motor[TIRE_BL].dir = FOR;
-                    mtc=true;
-                    break;
-                case 3:
-                    motor[TIRE_FR].pwm = 0;
-                    motor[TIRE_FR].dir = FREE;
-                    motor[TIRE_FL].pwm = slow;
-                    motor[TIRE_FL].dir = FOR;
-                    motor[TIRE_BR].pwm = slow;
-                    motor[TIRE_BR].dir = BACK;
-                    motor[TIRE_BL].pwm = 0;
-                    motor[TIRE_BL].dir = FREE;
-                    mtc=true;
-                    break;
-                case 2:
-                    motor[TIRE_FR].pwm = 0;
-                    motor[TIRE_FR].dir = FREE;
-                    motor[TIRE_FL].pwm = normal;
-                    motor[TIRE_FL].dir = FOR;
-                    motor[TIRE_BR].pwm = normal;
-                    motor[TIRE_BR].dir = BACK;
-                    motor[TIRE_BL].pwm = 0;
-                    motor[TIRE_BL].dir = FREE;
-                    mtc=true;
-                    break;
-            }
-            if(g[0]!=98&&mtc==true) {
-                switch(g[0]) {
-                    case 0:
-                        mtc=false;
-                        break;
-                    case 255:
-                        motor[TIRE_BR].pwm += 5;
-                        mtc=false;
-                        break;
-                    case 253:
-                        motor[TIRE_BR].pwm += 10;
-                        mtc=false;
-                        break;
-                    case 254:
-                        motor[TIRE_BR].pwm += 20;
-                        motor[TIRE_BL].pwm = 0;
-                        mtc=false;
-                        break;
-                    case 1:
-                        motor[TIRE_BL].pwm += 5;
-                        mtc=false;
-                        break;
-                    case 3:
-                        motor[TIRE_BL].pwm += 10;
-                        mtc=false;
-                        break;
-                    case 2:
-                        motor[TIRE_BL].pwm += 20;
-                        motor[TIRE_BR].pwm = 0;
-                        mtc=false;
-                        break;
-                }
-            }
-        } else if(mode==23) {
-            if(UPLS==true||DOLS==true) {
-                motor[MOTOR_0].pwm = 200;
-                motor[MOTOR_0].dir = BRAKE;
-                fast=60;
-                normal=40;
-                slow=20;
-                countss=0;
-                mode=24;
-            } else {
-                motor[MOTOR_0].pwm = 100;
-                motor[MOTOR_0].dir = BACK;
-            }
-            motor[TIRE_FR].pwm = 100;
-            motor[TIRE_FR].dir = BRAKE;
-            motor[TIRE_FL].pwm = 100;
-            motor[TIRE_FL].dir = BRAKE;
-            motor[TIRE_BR].pwm = 100;
-            motor[TIRE_BR].dir = BRAKE;
-            motor[TIRE_BL].pwm = 100;
-            motor[TIRE_BL].dir = BRAKE;
-        } else if(mode==24) {
-            if(g[0]==98&&countss>=40000) {
                 mode=31;
                 countss=0;
             }