changes to motor library

Dependents:   pid-car-example

Fork of motor by Lawrence Harlow

Branch:
motorupdate
Revision:
14:bc77edc4adb0
Parent:
13:c43f157a6bac
Child:
15:f40e834d063b
--- a/motor.cpp	Sun Nov 20 12:48:25 2016 +0000
+++ b/motor.cpp	Sun Nov 20 13:24:43 2016 +0000
@@ -184,37 +184,26 @@
     
 // tThis is a function which works off of the duty cycle. NO SENSOR REQUIREMENT
 // CLEAN THIS UP AND UPDATE  FOR SENSORS VERSION WITH THIS CODE
+// this function works off the actual value rather than the change in angle. therefore need to have a variabe which stores where the value is.
 void dutyCycleCorner( float speed, float angle)
 {
-        
-        //float width =0.15;
-        //float radius= center(middlePoint);
-        
         bool leftOrRight;
-        //float theta = angle/0.02222f;
         if(theta<0)
         {
-         leftOrRight=true;
-         theta=theta*-1;   
+            leftOrRight=true;
+            theta=theta*-1;   
             
         }
-//       float diff = (tan(theta))/ 2; 
-       
-       
-        
-        //float radius = 0.6;
-        //float x = tan(theta* (3.14f / 180.0f));
+ 
         float deltaW = ((0.2f*tan((angle/0.02222f)* (3.14f / 180.0f)))/0.2f)*speed;
-        float w1=speed+ deltaW;
-        float w2= speed- deltaW;
         
-        TFC_SetMotorPWM(w2,w1);
-        /*if(leftOrRight){
-        TFC_SetMotorPWM(w1,w2);
+        //TFC_SetMotorPWM(w2,w1);
+        if(leftOrRight){
+        TFC_SetMotorPWM(speed+ deltaW,speed- deltaW);
         }
         else{
-            TFC_SetMotorPWM(w2,w1);
-        }*/
+            TFC_SetMotorPWM(speed- deltaW,speed+ deltaW);
+        }
         
         
         
@@ -222,25 +211,27 @@
 }
         
         
-void corner(float &w1,float &w2,float deltaTheta,int maxspeed)
-    {// when cornering left the left motor slows down more than the right hand side
+void sensorCorner(float &w1,float &w2,float deltaTheta,int maxspeed)
+{   // when cornering left the left motor slows down more than the right hand side
     // may just replace with ACC and DECC
-    float r;
-    float d;
-    float l;
-    
+   
+    bool leftOrRight;
     
-    // it may be worth doing this off the change in theta. so that it is insesnsitive to the calibration.
-    float diff= ((d*tan(deltaTheta)/(2*l)));
+    if(theta<0)
+        {
+            leftOrRight=true;
+            theta=theta*-1;   
+            
+        }
+ 
+    float deltaW = ((0.2f*tan((angle/0.02222f)* (3.14f / 180.0f)))/0.2f)*speed;
     
-     w1 = (maxspeed/r)*(1+diff);
-     w2 = (maxspeed/r)*(1-diff);
-    
-    
+    &w1= maxspeed+ deltaW;
+    &w2= maxspeed -deltaW;
         
         
-     return;   
-    }
+    return;   
+}
     
 
     
@@ -273,4 +264,16 @@
     }
     
  return;   
-}
\ No newline at end of file
+}
+
+void setDutyCycle(int w, int targetW)
+{
+    
+    
+ 
+    
+}
+
+
+
+