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-06
Revision:
24:9d75ed1462d6
Parent:
23:ef1be367726e
Child:
25:4f2f441eceec

File content as of revision 24:9d75ed1462d6:

#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 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;
    Serial syren; //syren replaced the pololu controller
    //Guardian ap;
    Servo leftservo;
    Servo rightservo;
    
    pixySPI pcam;
    
    Timer timer1;
    Ticker ticker1;
    //RtosTimer controlTimer;
    Ticker tracker;
    Mutex dutyMutex;
    Thread dutyThread;
    static void dutyThreadStarter(void const* p);
    void updateDutyCycle();
    //Thread trackerThread;
    //static void trackerThreadStarter(void const *p);
    float amp;
    float ampCmd;
    float frq;
    float dutyCycle;
    float curTime;
    float frqMin;
    float frqMax;
    float yaw;
    float pitch;
    float adj;
    float yawAdjVal;
    bool fullCycle;
    float volume;
    float volMax;
    float frqCmd;
    float raiser;
    float pitAvg;
    float alPi;
};
 
#endif