Fixed Sonar

Dependencies:   C12832 Servo mbed-rtos-edited mbed

Fork of NervousPuppy by Sean Doyle

Revision:
2:8415bea33a95
Parent:
1:8fe6802d6971
Child:
3:74dfce05dd99
--- a/nervousPuppy.h	Mon Jan 12 19:32:28 2015 +0000
+++ b/nervousPuppy.h	Tue Jan 13 16:08:22 2015 +0000
@@ -1,25 +1,42 @@
 #include "mbed.h"
+#include "rtos.h"
+#include "Servo.h"
+#include <math.h>
+#include <string>
 
 #define Cos(a) cos(PI/180*(a))
 #define Sin(a) sin(PI/180*(a))
 #define PI 3.1415926
 
-using namespace std;
-
-static const float LONELY = 5.0f;
-static const float SCARED = 0.5f;
-
 class nervousPuppy{
     public:
         nervousPuppy();
         
         bool isLonely();
         bool isScared();
+        bool shutdown();
         
+        void detectPlayer();
         float getPlayerDistance();
         void setPlayerDistance(float dist);
-                
+        
+        float calculateVerticalAdjustment();
+        float calculateHorizontalAdjustment();
+        float calculateAngle(string axis);
+        void changePosition(string servo,float angle); 
+        
     private:
-        float playerDistance;
-
+        //Servo tilt();
+        //Servo rotate();      
+        
+        Mutex lockForDistance; //Not sure why needed
+        float playerDistance, playerError;
+        bool scared, lonely;
+        const float LONELY = 10.0f; //Placeholder number
+        const float SCARED = 3.0f; //Placeholder number
+        const float RADIUS = 2.0f; //Placeholder number
+        const float SHUTDOWN = 1.0f; //Placeholder number
+        const float PULSE_RATE = 10; //Placeholder number - Pulses per second
+        const float SERVO_TILT_LIMIT = 45; //Placeholder number - max angle servo can tilt by
+        const float SERVO_ROTATE_LIMIT = 45; //Placeholder number - max angle servo can rotate by
 };
\ No newline at end of file