svoe

Dependencies:   mbed mbed-STM32F103C8T6 MPU6050_1

Revision:
10:5bdd3dfd5f59
Parent:
9:8f98b1c277a4
Child:
12:721a9ea55e91
--- a/motion.h	Sat Sep 16 13:24:25 2017 +0000
+++ b/motion.h	Wed Sep 05 18:25:54 2018 +0000
@@ -3,9 +3,10 @@
 float speed = 1;//cm/s
 float radius = 10;
 
-float half_width = 8.5;
+float current_speed;
+//float half_width = 8.5;
 float current_x, current_y;
-float current_path, target_path;//cm
+float current_path, target_path;
 float current_angle, target_angle;//deg
 float old_path = 0;
 float old_angle = 0;
@@ -21,16 +22,18 @@
     //trap_timer.start();
     }
     
-void go(int cm, bool brake = 1){
-    if(cm != 0) {
-        stop_flag = 0; infinite_flag = 0;
-        motor_enable = 1;
-        target_path =old_path + cm; old_path = target_path;
-        if(cm > 0) path_dir = 1; else path_dir = 0;
-        angle_task = 0;
-        motor_busy = 1;
-        while(motor_busy == 1){proc_counter++;}
-        }
+void go(float distance_m, bool brake = 1){
+    //if(cm != 0) {
+        //stop_flag = 0; infinite_flag = 0;
+        //motor_enable = 1;
+        target_path = current_path + distance_m; 
+        wifi.printf("%.2f %.2f %.2f %.2f;",target_path,current_path,distance_m,current_speed);
+        while(abs(target_path - current_path) > 0.01){gyro_process();wifi.printf("%.2f %.2f %.2f %.2f;",target_path,current_path,target_path,current_speed);}
+        //if(cm > 0) path_dir = 1; else path_dir = 0;
+        //angle_task = 0;
+        //motor_busy = 1;
+        //while(motor_busy == 1){proc_counter++;}
+        //}
     }
     
 void go_no_wait(int cm, bool brake = 1){
@@ -97,4 +100,6 @@
     radius =0;
     turn(720);
     turn(-720);
-    }
\ No newline at end of file
+    }
+    
+    
\ No newline at end of file