ManualControl

Dependencies:   TPixy-Interface

Fork of MbedOS_Robot_Team by ECE4333 - 2018 - Ahmed & Brandon

Files at this revision

API Documentation at this revision

Comitter:
asobhy
Date:
Tue Mar 13 22:14:24 2018 +0000
Parent:
17:1184df616383
Child:
19:4fbffc755ed7
Commit message:
MANUAL CONTROL - main refresh rate increased to get better response - need more testing

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
ui.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sun Mar 11 01:26:23 2018 +0000
+++ b/main.cpp	Tue Mar 13 22:14:24 2018 +0000
@@ -45,6 +45,6 @@
         }
         
         consoleUI(); 
-        Thread::wait(500); // Go to sleep for 500 ms  
+        Thread::wait(100); // Go to sleep for 500 ms  
     }
 }
--- a/ui.cpp	Sun Mar 11 01:26:23 2018 +0000
+++ b/ui.cpp	Tue Mar 13 22:14:24 2018 +0000
@@ -35,9 +35,9 @@
 
 
 /******************************************************************************
-                           User interface 3
+                           User interface 3 Camera
 ******************************************************************************/
-void consoleUI(void){
+void consoleUIcamera(void){
 
     cameraData_mutex.lock();
     bluetooth.printf("\r\nsetpointR: %d   setpointL: %d    ObjectWidth: %d     ObjectXcoordinate: %d   SteeringError: %d   DistanceError: %d", setpointR, setpointL, ObjectWidth, xR, SteeringError, DistanceError);    
@@ -267,9 +267,8 @@
                            User interface 3 - manual control
 ******************************************************************************/
 
-void consoleUIManualControl(void)
+void consoleUI(void)
 {
-     
     if (bluetooth.readable()) {
         x = bluetooth.getc();
         
@@ -287,7 +286,7 @@
         // by incrementing u
         else if(x == 'w') {
             mutexSetpoint.lock();
-            Setpoint = Setpoint + 100;
+            Setpoint = 100;
             mutexSetpoint.unlock();
         
         }
@@ -296,22 +295,22 @@
         // by decrementing u
         else if(x == 's') {
             mutexSetpoint.lock();
-            Setpoint = Setpoint - 100;
+            Setpoint = -100;
             mutexSetpoint.unlock();
         
         }
 
 /******************************ROBOT STEERING**********************************/        
+        else if (x=='a')
+        {
+            mutexSetpoint.lock();
+            SteeringError = 300;
+            mutexSetpoint.unlock();
+        }
         else if (x=='d')
         {
             mutexSetpoint.lock();
-            SteeringError = SteeringError + 10;
-            mutexSetpoint.unlock();
-        }
-        else if (x=='a')
-        {
-            mutexSetpoint.lock();
-            SteeringError = SteeringError - 10;
+            SteeringError = -300;
             mutexSetpoint.unlock();
         }        
         // error wrong input
@@ -319,9 +318,11 @@
             bluetooth.printf("\r\nwrong input please enter \'w\' to increase the speed, \'s\' to reduce it or move in the opposite direction and \'r\' to reset the watchdog");
         }
     }
-    
-    // If no key is pressed stop the robot. 
-    Setpoint = 0;
-    SteeringError = 0;   
+    else{
+        // If no key is pressed stop the robot. 
+        Setpoint = 0;
+        SteeringError = 0;
+           
+    }
     
 }