My modifications/additions to the code
Dependencies: ADXL345 ADXL345_I2C IMUfilter ITG3200 Servo fishgait mbed-rtos mbed pixy_cam
Fork of robotic_fish_ver_4_8 by
Diff: MainController.h
- Revision:
- 25:4f2f441eceec
- Parent:
- 24:9d75ed1462d6
diff -r 9d75ed1462d6 -r 4f2f441eceec MainController.h --- a/MainController.h Fri Jun 06 19:48:01 2014 +0000 +++ b/MainController.h Fri Jul 11 14:30:36 2014 +0000 @@ -1,6 +1,6 @@ #ifndef MBED_MAINCONTROLLER_H #define MBED_MAINCONTROLLER_H - + #include "mbed.h" #include "rtos.h" #include "PwmIn.h" @@ -9,31 +9,33 @@ //#include "IMU.h" #include "Servo.h" #include "pixy.h" +#include "servoloop.h" #define MATH_PI 3.14159265359 #define START_THREAD 1 - + /** MainController class to get control inputs and place them onto the system - * - * + * + * */ -class MainController { +class MainController +{ public: /** Create a MainController * - * @param - */ + * @param + */ MainController() ; ~MainController(); - + /** Start the main controller * - * @returns + * @returns */ void start(); - + float getDutyCycle(); float getFrequency(); float getVolume(); @@ -45,12 +47,12 @@ /** Stop the main controller * - * @returns + * @returns */ void stop(); - - -protected: + + +protected: void control(); void trackTarget(); float calculateFrequency(); @@ -60,7 +62,7 @@ float calculateAdj(); float signum(float input); float saturate(float input); - + private: PwmIn ch1; PwmIn ch2; @@ -72,19 +74,23 @@ //Guardian ap; Servo leftservo; Servo rightservo; - + ServoLoop panLoop; + ServoLoop tiltLoop; + pixySPI pcam; - + Timer timer1; Ticker ticker1; //RtosTimer controlTimer; Ticker tracker; - Mutex dutyMutex; - Thread dutyThread; - static void dutyThreadStarter(void const* p); + Mutex trackMutex; + //Thread dutyThread; + //static void dutyThreadStarter(void const* p); + Thread controlThread; + static void controlThreadStarter(void const* p); void updateDutyCycle(); - //Thread trackerThread; - //static void trackerThreadStarter(void const *p); + Thread trackerThread; + static void trackerThreadStarter(void const *p); float amp; float ampCmd; float frq; @@ -104,7 +110,8 @@ float pitAvg; float alPi; }; - + + #endif