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

Committer:
rkk
Date:
Fri May 30 22:18:39 2014 +0000
Revision:
20:6ae16da1492a
Parent:
19:655db88b045c
Child:
22:807d5467fbf6
working setup for yaw motion

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rkk 11:8ec915eb70f6 1 #ifndef MBED_MAINCONTROLLER_H
rkk 11:8ec915eb70f6 2 #define MBED_MAINCONTROLLER_H
rkk 11:8ec915eb70f6 3
rkk 11:8ec915eb70f6 4 #include "mbed.h"
rkk 11:8ec915eb70f6 5 #include "PwmIn.h"
rkk 11:8ec915eb70f6 6 #include "motor_controller.h"
rkk 20:6ae16da1492a 7 //#include "guardian.h"
rkk 12:7eeb29892625 8 //#include "IMU.h"
rkk 17:6970aef8154b 9 #include "Servo.h"
rkk 17:6970aef8154b 10
rkk 12:7eeb29892625 11
rkk 11:8ec915eb70f6 12
rkk 11:8ec915eb70f6 13 #define MATH_PI 3.14159265359
rkk 11:8ec915eb70f6 14
rkk 11:8ec915eb70f6 15 /** MainController class to get control inputs and place them onto the system
rkk 11:8ec915eb70f6 16 *
rkk 11:8ec915eb70f6 17 *
rkk 11:8ec915eb70f6 18 */
rkk 11:8ec915eb70f6 19 class MainController {
rkk 11:8ec915eb70f6 20 public:
rkk 11:8ec915eb70f6 21 /** Create a MainController
rkk 11:8ec915eb70f6 22 *
rkk 11:8ec915eb70f6 23 * @param
rkk 11:8ec915eb70f6 24 */
rkk 11:8ec915eb70f6 25 MainController() ;
rkk 11:8ec915eb70f6 26
rkk 11:8ec915eb70f6 27 /** Start the main controller
rkk 11:8ec915eb70f6 28 *
rkk 11:8ec915eb70f6 29 * @returns
rkk 11:8ec915eb70f6 30 */
rkk 11:8ec915eb70f6 31 void start();
rkk 11:8ec915eb70f6 32
rkk 11:8ec915eb70f6 33 float getDutyCycle();
rkk 11:8ec915eb70f6 34 float getFrequency();
rkk 11:8ec915eb70f6 35 float getVolume();
rkk 11:8ec915eb70f6 36 float getAmplitude();
rkk 19:655db88b045c 37 float getYaw();
rkk 17:6970aef8154b 38 float getPitch();
rkk 19:655db88b045c 39 float getTimeAdd();
rkk 20:6ae16da1492a 40 float getAdj();
rkk 20:6ae16da1492a 41
rkk 11:8ec915eb70f6 42 /** Stop the main controller
rkk 11:8ec915eb70f6 43 *
rkk 11:8ec915eb70f6 44 * @returns
rkk 11:8ec915eb70f6 45 */
rkk 11:8ec915eb70f6 46 void stop();
rkk 11:8ec915eb70f6 47
rkk 11:8ec915eb70f6 48
rkk 11:8ec915eb70f6 49 protected:
rkk 11:8ec915eb70f6 50 void control();
rkk 11:8ec915eb70f6 51 float calculateFrequency();
rkk 19:655db88b045c 52 float calculateAmplitude();
rkk 19:655db88b045c 53 float calculateYaw();
rkk 17:6970aef8154b 54 float calculatePitch();
rkk 20:6ae16da1492a 55 float calculateAdj();
rkk 13:5ed8fd870723 56 float signum(float input);
rkk 15:dc5753a5b83e 57 float saturate(float input);
rkk 11:8ec915eb70f6 58
rkk 11:8ec915eb70f6 59 private:
rkk 17:6970aef8154b 60 PwmIn ch1;
rkk 17:6970aef8154b 61 PwmIn ch2;
rkk 11:8ec915eb70f6 62 PwmIn ch3;
rkk 12:7eeb29892625 63 PwmIn ch4;
rkk 11:8ec915eb70f6 64 PwmIn ch6;
rkk 11:8ec915eb70f6 65 PololuMController mcon;
rkk 20:6ae16da1492a 66 //Guardian ap;
rkk 20:6ae16da1492a 67 Servo leftservo;
rkk 20:6ae16da1492a 68 Servo rightservo;
rkk 12:7eeb29892625 69
rkk 11:8ec915eb70f6 70 Timer timer1;
rkk 11:8ec915eb70f6 71 Ticker ticker1;
rkk 19:655db88b045c 72 float amp;
rkk 20:6ae16da1492a 73 float ampNew;
rkk 11:8ec915eb70f6 74 float frq;
rkk 11:8ec915eb70f6 75 float dutyCycle;
rkk 11:8ec915eb70f6 76 float curTime;
rkk 11:8ec915eb70f6 77 float frqMin;
rkk 11:8ec915eb70f6 78 float frqMax;
rkk 19:655db88b045c 79 float yaw;
rkk 17:6970aef8154b 80 float pitch;
rkk 20:6ae16da1492a 81 float adj;
rkk 17:6970aef8154b 82
rkk 19:655db88b045c 83 bool fullCycle;
rkk 19:655db88b045c 84 float volume;
rkk 19:655db88b045c 85 float volChg;
rkk 19:655db88b045c 86 float volMax;
rkk 19:655db88b045c 87 float frqCmd;
rkk 19:655db88b045c 88 float timeAdd;
rkk 20:6ae16da1492a 89 float raiser;
rkk 20:6ae16da1492a 90 float pitAvg;
rkk 20:6ae16da1492a 91 float alPi;
rkk 11:8ec915eb70f6 92 };
rkk 11:8ec915eb70f6 93
rkk 11:8ec915eb70f6 94 #endif
rkk 11:8ec915eb70f6 95
rkk 11:8ec915eb70f6 96