évitement d obstacles

Dependencies:   Motor 16_Channel_Analog VL53L0X

Revision:
1:53b992a47b28
Parent:
0:324dc73a5829
Child:
2:f3ca81bbfabf
--- a/main.cpp	Fri Jul 17 09:29:10 2020 +0000
+++ b/main.cpp	Fri Jul 17 10:08:05 2020 +0000
@@ -5,26 +5,34 @@
 
 #include "mbed.h"
 #include "perceptron.h"
+#include "Motor.h"
 #include <vector>
 #include <iostream>
 #include <stdio.h>
 
 int main()
 {
+    Motor m1(D8, D9, D10); // pwm, fwd, rev
+    Motor m2(D3, D4, D5); // pwm, fwd, rev
+    
     printf("debut\r\n");
     vector<float> Wg = {1,1,-1,-1};
     perceptron perceptronG(Wg);
     
     vector<float> Wd = {1,-1,-1,1};
     perceptron perceptronD(Wd);
-    
-    vector<int> X = {1,1,1};
-    
-    printf("X=%d,%d,%d\r\n",X[0],X[1],X[2]);
-    
-    int Vg=perceptronG.predict(X);
-    int Vd=perceptronD.predict(X);
-    
-    printf("Vg=%d\r\n",Vg);
-    printf("Vd=%d\r\n",Vd);
+    while(true){
+        
+        vector<int> X = {1,1,1};
+        
+        printf("X=%d,%d,%d\r\n",X[0],X[1],X[2]);
+        
+        int Vg=perceptronG.predict(X);
+        int Vd=perceptronD.predict(X);
+        
+        printf("Vg=%d\r\n",Vg);
+        printf("Vd=%d\r\n",Vd);
+        m1.speed(Vg);
+        m2.speed(Vd);
+    }
 }