Fixed Sonar
Dependencies: C12832 Servo mbed-rtos-edited mbed
Fork of NervousPuppy by
nervousPuppy.h@6:f854aa2f41e2, 2015-01-26 (annotated)
- Committer:
- SeanDoyle
- Date:
- Mon Jan 26 14:50:41 2015 +0000
- Revision:
- 6:f854aa2f41e2
- Parent:
- 5:cbb5d7460309
changedCode-removedMath;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
SeanDoyle | 0:f71b200c2f4d | 1 | #include "mbed.h" |
SeanDoyle | 2:8415bea33a95 | 2 | #include "rtos.h" |
SeanDoyle | 2:8415bea33a95 | 3 | #include "Servo.h" |
SeanDoyle | 4:2b47356f4b7d | 4 | #include "C12832.h" |
SeanDoyle | 2:8415bea33a95 | 5 | #include <math.h> |
SeanDoyle | 2:8415bea33a95 | 6 | #include <string> |
SeanDoyle | 0:f71b200c2f4d | 7 | |
SeanDoyle | 0:f71b200c2f4d | 8 | #define Cos(a) cos(PI/180*(a)) |
SeanDoyle | 0:f71b200c2f4d | 9 | #define Sin(a) sin(PI/180*(a)) |
SeanDoyle | 0:f71b200c2f4d | 10 | #define PI 3.1415926 |
SeanDoyle | 0:f71b200c2f4d | 11 | |
SeanDoyle | 0:f71b200c2f4d | 12 | class nervousPuppy{ |
SeanDoyle | 0:f71b200c2f4d | 13 | public: |
SeanDoyle | 4:2b47356f4b7d | 14 | |
SeanDoyle | 0:f71b200c2f4d | 15 | nervousPuppy(); |
SeanDoyle | 0:f71b200c2f4d | 16 | |
SeanDoyle | 0:f71b200c2f4d | 17 | bool isLonely(); |
SeanDoyle | 0:f71b200c2f4d | 18 | bool isScared(); |
SeanDoyle | 2:8415bea33a95 | 19 | bool shutdown(); |
SeanDoyle | 0:f71b200c2f4d | 20 | |
SeanDoyle | 2:8415bea33a95 | 21 | void detectPlayer(); |
SeanDoyle | 0:f71b200c2f4d | 22 | float getPlayerDistance(); |
SeanDoyle | 1:8fe6802d6971 | 23 | void setPlayerDistance(float dist); |
SeanDoyle | 2:8415bea33a95 | 24 | |
SeanDoyle | 5:cbb5d7460309 | 25 | float calculateAngle(string issue); |
SeanDoyle | 2:8415bea33a95 | 26 | void changePosition(string servo,float angle); |
SeanDoyle | 2:8415bea33a95 | 27 | |
SeanDoyle | 0:f71b200c2f4d | 28 | private: |
SeanDoyle | 2:8415bea33a95 | 29 | |
SeanDoyle | 2:8415bea33a95 | 30 | Mutex lockForDistance; //Not sure why needed |
SeanDoyle | 2:8415bea33a95 | 31 | float playerDistance, playerError; |
SeanDoyle | 2:8415bea33a95 | 32 | bool scared, lonely; |
SeanDoyle | 6:f854aa2f41e2 | 33 | const float LONELY = 22.0f; //Placeholder number |
SeanDoyle | 6:f854aa2f41e2 | 34 | const float SCARED = 24.0f; //Placeholder number |
SeanDoyle | 5:cbb5d7460309 | 35 | const float RADIUS = 1.75f; //Placeholder number |
SeanDoyle | 4:2b47356f4b7d | 36 | const float SHUTDOWN = 0.0f; //Placeholder number |
SeanDoyle | 2:8415bea33a95 | 37 | const float PULSE_RATE = 10; //Placeholder number - Pulses per second |
SeanDoyle | 2:8415bea33a95 | 38 | const float SERVO_TILT_LIMIT = 45; //Placeholder number - max angle servo can tilt by |
SeanDoyle | 2:8415bea33a95 | 39 | const float SERVO_ROTATE_LIMIT = 45; //Placeholder number - max angle servo can rotate by |
SeanDoyle | 0:f71b200c2f4d | 40 | }; |