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 jetfishteam

MainController.h

Committer:
sandwich
Date:
2014-06-05
Revision:
22:807d5467fbf6
Parent:
20:6ae16da1492a
Child:
23:ef1be367726e

File content as of revision 22:807d5467fbf6:

#ifndef MBED_MAINCONTROLLER_H
#define MBED_MAINCONTROLLER_H
 
#include "mbed.h"
#include "rtos.h"
#include "PwmIn.h"
#include "motor_controller.h"
//#include "guardian.h"
//#include "IMU.h"
#include "Servo.h"
#include "pixy.h"



#define MATH_PI 3.14159265359
#define START_THREAD 1
 
/** MainController class to get control inputs and place them onto the system
 * 
 * 
 */
class MainController {
public:
    /** Create a MainController
     *
     * @param 
     */ 
    MainController() ;
    ~MainController();
    
    /** Start the main controller
     *
     * @returns 
     */
    void start();
    
    float getDutyCycle();
    float getFrequency();
    float getVolume();
    float getAmplitude();
    float getYaw();
    float getPitch();
    float getTimeAdd();
    float getAdj();
    bool getOpMode(); //returns true when in autonomous mode

    /** Stop the main controller
     *
     * @returns 
     */
    void stop();
    
 
protected:        
    void control();
    void trackTarget();
    float calculateFrequency();
    float calculateAmplitude();
    float calculateYaw();
    float calculatePitch();
    float calculateAdj();
    float signum(float input);
    float saturate(float input);
    
private:
    PwmIn ch1;
    PwmIn ch2;
    PwmIn ch3;
    PwmIn ch4;
    PwmIn ch6;
    PwmIn ch5;
    //PololuMController mcon;
    Serial syren; //syren replaced the pololu controller
    //Guardian ap;
    Servo leftservo;
    Servo rightservo;
    
    pixySPI pcam;
    
    Timer timer1;
    //Ticker ticker1;
    //Ticker tracker;
    Mutex trackMutex;
    Thread controlThread;
    static void controlThreadStarter(void const *p);
    Thread trackerThread;
    static void trackerThreadStarter(void const *p);
    float amp;
    float ampNew;
    float frq;
    float dutyCycle;
    float curTime;
    float frqMin;
    float frqMax;
    float yaw;
    float pitch;
    float adj;
    
    bool fullCycle;
    float volume;
    float volChg;
    float volMax;
    float frqCmd;
    float timeAdd;
    float raiser;
    float pitAvg;
    float alPi;
};
 
#endif