These are the core files for the Robot at Team conception.

Dependencies:   mbed UniServ

Revision:
8:351b0b7b05b2
Parent:
0:eba74e7a229b
Child:
11:05d5539141c8
Child:
15:4efc66de795a
--- a/Brobot.cpp	Fri May 26 08:07:24 2017 +0000
+++ b/Brobot.cpp	Mon May 29 13:03:28 2017 +0000
@@ -5,20 +5,16 @@
 
 #include <cmath>
 #include "Brobot.h"
-
+#include "SpeedControl.h"
 
-Brobot::Brobot(PwmOut* left, PwmOut* right, int number)
-{
-    pwmL = left;  // set local references to objects
-    pwmR = right;
+SpeedControl speedctrl(PwmOut* pwmLeft, PwmOut* pwmRight, EncoderCounter* counterLeft, EncoderCounter* counterRight);
 
+Brobot::Brobot(SpeedControl* speedctrl, int number) 
+{
     this->number = number;
+    //this->speedctrl = speedctrl;
 }
 
-// empty constructor
-Brobot::Brobot()
-{}
-
 void Brobot::rotate( float phi)
 {
     if(phi>0.5f || phi<-0.5f) {
@@ -29,11 +25,19 @@
     *pwmR = 0.5f + phi;
 }
 
+/*
+void Brobot::setWheelSpeeds( float wheelL, float wheelR)
+{
+    SpeedCtrl.setDesiredSpeed( wheelL, wheelR);
+}
+*/
+
 void Brobot::forward()
 {
-    *pwmL=0.65f;  // asterisk is dereferencing the pointer so
-    *pwmR=0.36f;  // you can access the variable at the pointers address
+    //*pwmL=0.65f;  // asterisk is dereferencing the pointer so
+    //*pwmR=0.36f;  // you can access the variable at the pointers address
     // also another way to dereference the pointer is: pwmR->write(0.xx)
+    speedctrl->setDesiredSpeed(0.65f, 0.35f);
 }
 
 void Brobot::slow(float scale)
@@ -48,26 +52,22 @@
 
 void Brobot::turnleft()
 {
-    *pwmL=0.48f;
-    *pwmR=0.31f;
+    speedctrl->setDesiredSpeed(0.48f, 0.31f);
     wait(0.1);
 }
 
 void Brobot::turnright()
 {
-    *pwmL=0.69f;
-    *pwmR=0.52f;
+    speedctrl->setDesiredSpeed(0.69f, 0.52f);
     wait(0.1);
 }
 
 void Brobot::back()
 {
-    *pwmR=0.65f;
-    *pwmL=0.35f;
+    speedctrl->setDesiredSpeed(0.65f, 0.35f);
 }
 
 void Brobot::stop()
 {
-    *pwmR=0.5f;
-    *pwmL=0.5f;
+    speedctrl->setDesiredSpeed(0.5f, 0.5f);
 }
\ No newline at end of file