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
MainController.h
00001 #ifndef MBED_MAINCONTROLLER_H 00002 #define MBED_MAINCONTROLLER_H 00003 00004 #include "mbed.h" 00005 #include "rtos.h" 00006 #include "PwmIn.h" 00007 #include "motor_controller.h" 00008 //#include "guardian.h" 00009 //#include "IMU.h" 00010 #include "Servo.h" 00011 #include "pixy.h" 00012 #include "servoloop.h" 00013 00014 00015 00016 #define MATH_PI 3.14159265359 00017 #define START_THREAD 1 00018 00019 /** MainController class to get control inputs and place them onto the system 00020 * 00021 * 00022 */ 00023 class MainController 00024 { 00025 public: 00026 /** Create a MainController 00027 * 00028 * @param 00029 */ 00030 MainController() ; 00031 ~MainController(); 00032 00033 /** Start the main controller 00034 * 00035 * @returns 00036 */ 00037 void start(); 00038 00039 float getDutyCycle(); 00040 float getFrequency(); 00041 float getVolume(); 00042 float getAmplitude(); 00043 float getYaw(); 00044 float getPitch(); 00045 float getAdj(); 00046 bool getOpMode(); //returns true when in autonomous mode 00047 00048 /** Stop the main controller 00049 * 00050 * @returns 00051 */ 00052 void stop(); 00053 00054 00055 protected: 00056 void control(); 00057 void trackTarget(); 00058 float calculateFrequency(); 00059 float calculateAmplitude(); 00060 float calculateYaw(); 00061 float calculatePitch(); 00062 float calculateAdj(); 00063 float signum(float input); 00064 float saturate(float input); 00065 00066 private: 00067 PwmIn ch1; 00068 PwmIn ch2; 00069 PwmIn ch3; 00070 PwmIn ch4; 00071 PwmIn ch6; 00072 PwmIn ch5; 00073 Serial syren; //syren replaced the pololu controller 00074 //Guardian ap; 00075 Servo leftservo; 00076 Servo rightservo; 00077 ServoLoop panLoop; 00078 ServoLoop tiltLoop; 00079 00080 pixySPI pcam; 00081 00082 Timer timer1; 00083 Ticker ticker1; 00084 //RtosTimer controlTimer; 00085 Ticker tracker; 00086 Mutex trackMutex; 00087 //Thread dutyThread; 00088 //static void dutyThreadStarter(void const* p); 00089 Thread controlThread; 00090 static void controlThreadStarter(void const* p); 00091 void updateDutyCycle(); 00092 Thread trackerThread; 00093 static void trackerThreadStarter(void const *p); 00094 float amp; 00095 float ampCmd; 00096 float frq; 00097 float dutyCycle; 00098 float curTime; 00099 float frqMin; 00100 float frqMax; 00101 float yaw; 00102 float pitch; 00103 float adj; 00104 float yawAdjVal; 00105 bool fullCycle; 00106 float volume; 00107 float volMax; 00108 float frqCmd; 00109 float raiser; 00110 float pitAvg; 00111 float alPi; 00112 }; 00113 00114 00115 #endif 00116 00117
Generated on Sun Jul 17 2022 22:28:23 by 1.7.2