Eimantas Bernotavicius / Mbed 2 deprecated Buggy_Project

Dependencies:   QEI mbed

Revision:
2:7f4be54c7257
Parent:
1:12f18cede014
Child:
3:c9df852ad9ac
--- a/encoderBase.cpp	Thu Feb 15 20:17:42 2018 +0000
+++ b/encoderBase.cpp	Fri Feb 16 19:30:19 2018 +0000
@@ -1,4 +1,4 @@
-/*#include "mbed.h"
+#include "mbed.h"
 #include "QEI.h"
 #include "pins.cpp"
 #define ENCODER_PULSE 256 //per manual
@@ -14,13 +14,16 @@
 class Wheel{
     int currentPulses, previousPulses;
     public:
-        float wheelVelocity(float, int){
+        float velocity(){
+            return encoderVelocity*GEAR_RATIO;
         }
     private:
         float sampleTime= SAMPLE_TIME;
         int gearRatio = GEAR_RATIO;
-        float encoderVelocity(){
-        return (currentEncoderTicks-previousEncoderTicks)/sampleTime;
+        float encoderVelocity(encoderPulse){
+            wait(sampleTIme);
+            previousEncoderPulses=currentEncoderPulses;
+            currentEncoderPulses=encoderPulse;
         }
 
 } wheelRight, wheelLeft;
@@ -30,17 +33,18 @@
 //call this for speed, linear and angular
 class Buggy{
     public:
-        float speedLinear(float wheelVelocityRight, float wheelVelocityLeft){
-            return (wheelVelocityRight+wheelVelocityLeft)/2;
+        float speedLinear(){
+            return (wheelRight.velocity()+wheelLeft.velocity())/2;
             }
-        float speedAngular(float wheelVelocityRight, float wheelVelocityLeft){
-            return (wheelVelocityRight-wheelVelocityLeft)/WHEEL_DISTANCE;
+        float speedAngular(){
+            return (wheelRight.velocity()-wheelLeft.velocity())/WHEEL_DISTANCE;
             }
-    }
-int encoderTicks(){
-        previousEncoderTicks=currentEncoderTicks;
-        currentEncoderTicks=
-        }
+    }buggy;
+    
+int speedMeasure(int encoderSide){
+        wheelRight.currentPulses(&encoderRight.getPulses());
+        wheelLeft.currentPulses(&encoderLeft.getPulses());
+    }//set this as an interupt routine on the timer based on SAMPLE_TIME
 
 
-*/
+