added serial up, down, left and right control

Dependencies:   mbed

Fork of Robot_a_cables_v3_6 by RaC2018

Files at this revision

API Documentation at this revision

Comitter:
unslaad
Date:
Tue Jun 05 12:29:57 2018 +0000
Parent:
11:0fa23c2dab76
Commit message:
all serial controls ready; changed serial output floats to ints

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 0fa23c2dab76 -r 98a051edb19a main.cpp
--- a/main.cpp	Tue Jun 05 07:24:15 2018 +0000
+++ b/main.cpp	Tue Jun 05 12:29:57 2018 +0000
@@ -159,10 +159,10 @@
             else if(mode == NORMAL){
             pc.printf("mode = n");    
                 }
-            pc.printf(" x = %f", dx);
-            pc.printf(" y = %f", dy);
-            pc.printf(" VM_L = %f", pVx);
-            pc.printf(" VM_R = %f \r\n", pVy);
+            pc.printf(" x = %d", (int)dx);
+            pc.printf(" y = %d", (int)dy);
+            pc.printf(" VM_L = %d", (int)pVx);
+            pc.printf(" VM_R = %d \r\n", (int)pVy);
             
             
             
@@ -176,12 +176,6 @@
                 contrTraj=true;
                 lectpc=pc.getc();
                 if(lectpc=='h'){
-                    /*for(int i=0;i!=5;i++){
-                        Xtraj[i]=pc.getc();   
-                    }
-                    for(int i=0;i!=5;i++){
-                        Ytraj[i]=pc.getc();   
-                    }*/
                     robot.setVelocity(0.50,0.60,0.5, mode);   //Motors control with the joystick and with the mode we use
                 };
                 if(lectpc=='b'){
@@ -193,6 +187,16 @@
                 if(lectpc=='d'){
                     robot.setVelocity(0.40,0.50,0.5, mode);   //Motors control with the joystick and with the mode we use
                 };
+                if(lectpc=='0'){
+                    for(int i=1;i!=5;i++){
+                        Xtraj[i]=pc.getc();   
+                    }
+                    for(int i=0;i!=5;i++){
+                        Ytraj[i]=pc.getc();   
+                    }
+                    robot.setVelocity(atof(Xtraj),atof(Ytraj),0.5,mode);
+                };    
+                
             }else{
                 robot.setVelocity(0.50,0.50,0.5,mode);
                 contrTraj=false;