DP / Mbed 2 deprecated RCControlOOPWithThrottle

Dependencies:   mbed

Fork of RCControlOOP by DP

Revision:
2:e9042e88abf1
Parent:
1:e694ee3b4a7f
Child:
3:b3ec75e9163f
--- a/Mousr.cpp	Sun Sep 21 14:43:47 2014 +0000
+++ b/Mousr.cpp	Wed Oct 08 16:59:47 2014 +0000
@@ -1,46 +1,61 @@
 #include "Mousr.h"
 
-Mousr::Mousr() : m1a(p24), m1b(p23), m2a(p22), m2b(p21)
+//Mousr::Mousr() : m1a(p24), m1b(p23), m2a(p22), m2b(p21)
+Mousr::Mousr() : mstby(p6), m_a1(p24), m_a2(p25), mpwma(p26), m_b1(p23), m_b2(p22), mpwmb(p21)
 {           
-    straightSpeed     = 0.7;
-    rotateSlowSpeed   = 0.1;
-    rotateSpeed       = 0.3;
-    rotateFastSpeed   = 0.9;
-    flipStraightSpeed = 0.9;
-    flipStraightWait  = 0.6;
-    flipRotateSpeed   = 0.9;
-    flipRotateWait    = 0.2;
+    straightSpeed     = 0.3;
+    straightSlowSpeed = 0.1;
+    rotateSlowSpeed   = 0.05;
+    rotateSpeed       = 0.1;
+    rotateFastSpeed   = 0.2;
+    
+    // Parameters for Flip
+    flipStraightSpeed = 0.5;
+    flipStraightWait  = 0.5;
+    flipStopWait      = 0.1;
+    flipRotateSpeed   = 0.5;
+    flipRotateWait    = 0.1;
+    mpwma = 1;
+    mpwmb = 1;
+    mstby = 1;
 }
 
 void Mousr::stop()
 {
-    m1a = 0; m2a = 0; m1b = 0; m2b = 0; return;
+   // m1a = 0; m2a = 0; m1b = 0; m2b = 0; return;
+    m_a1 = 0; m_a2 = 0; m_b1 = 0; m_b2 = 0; return;
 }
 
 void Mousr::straight(float speed)
 {
-    m1a = speed; m1b = 0; m2a = speed; m2b = 0; return;
+   // m1a = speed; m1b = 0; m2a = speed; m2b = 0; return;
+   m_a1 = speed; m_a2 = 0; m_b1 = speed; m_b2 = 0; return;
 }
 
 void Mousr::backwards(float speed)
 {
-    m1a = 0; m2a = 0; m1b = speed; m2b = speed; return;
+    //m1a = 0; m2a = 0; m1b = speed; m2b = speed; return;
+    m_a1 = 0; m_a2 = speed; m_b1 = 0; m_b2 = speed; return;
 }
 
 void Mousr::left(float speed)
 {
-    m1a = 0; m1b = speed; m2a = speed; m2b = 0; return;
+   // m1a = 0; m1b = speed; m2a = speed; m2b = 0; return;
+   m_a1 = speed; m_a2 = 0; m_b1 = 0; m_b2 = speed; return;
 }
 
 void Mousr::right(float speed)
 {
-    m1a = speed; m1b = 0; m2a = 0; m2b = speed; return;
+   // m1a = speed; m1b = 0; m2a = 0; m2b = speed; return;
+   m_a1 = 0; m_a2 = speed; m_b1 = speed; m_b2 = 0; return;
 }
 
 void Mousr::flipLeft()
 {
     straight(flipStraightSpeed);
     wait(flipStraightWait);
+    stop();
+    wait(flipStopWait);
     left(flipRotateSpeed);
     wait(flipRotateWait);
     stop();
@@ -50,6 +65,8 @@
 {
     straight(flipStraightSpeed);
     wait(flipStraightWait);
+    stop();
+    wait(flipStopWait);
     right(flipRotateSpeed);
     wait(flipRotateWait);
     stop();
@@ -61,6 +78,11 @@
     return straightSpeed;
 }
 
+float Mousr::getStraightSlowSpeed()
+{
+    return straightSlowSpeed;
+}
+
 float Mousr::getRotateSlowSpeed()
 {
     return rotateSlowSpeed;