2015_robocon_bteam / Mbed 2 deprecated 2015robot_main

Dependencies:   PID QEI mbed

Fork of 2015robot_main by Naoto Deguchi

Committer:
DeguNaoto
Date:
Sat Sep 26 08:43:21 2015 +0000
Revision:
50:8ea4714316ce
Parent:
49:9276fda93084
Child:
55:db1797ac6cb1
?????????????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DeguNaoto 49:9276fda93084 1 #ifndef SWING_H
DeguNaoto 49:9276fda93084 2 #define SWING_H
DeguNaoto 49:9276fda93084 3
DeguNaoto 49:9276fda93084 4 /***Swing.***/
DeguNaoto 49:9276fda93084 5 PID contSwing(5.917 ,0.2145 ,0.0 ,RATE);
DeguNaoto 49:9276fda93084 6 inline void initializeSwing() {
DeguNaoto 49:9276fda93084 7 interrupter.rise(&countSwing);
DeguNaoto 49:9276fda93084 8 Motor_swing.period_us(SWING_PERIOD);
DeguNaoto 49:9276fda93084 9 //controller set
DeguNaoto 49:9276fda93084 10 contSwing.setInputLimits(0.0, 1.0);
DeguNaoto 49:9276fda93084 11 contSwing.setOutputLimits(0.0, 1.0);
DeguNaoto 49:9276fda93084 12 contSwing.setBias(0.0);
DeguNaoto 49:9276fda93084 13 contSwing.setMode(AUTO_MODE);
DeguNaoto 49:9276fda93084 14 }
DeguNaoto 49:9276fda93084 15
DeguNaoto 49:9276fda93084 16 void countSwing() {
DeguNaoto 49:9276fda93084 17 Indicator1 = !Indicator1;
DeguNaoto 49:9276fda93084 18 if(enableShoot){
DeguNaoto 49:9276fda93084 19 enableShoot=0;
DeguNaoto 49:9276fda93084 20 if(targSwingRadVelocity != 0.0) wait((2 * PI) / swingRadVelocity);
DeguNaoto 49:9276fda93084 21 sendData(1,6);
DeguNaoto 49:9276fda93084 22 }
DeguNaoto 49:9276fda93084 23 }
DeguNaoto 49:9276fda93084 24
DeguNaoto 49:9276fda93084 25 inline void mesureSwing() {
DeguNaoto 49:9276fda93084 26 PulsesSwing = ( double )SwingSens.getPulses();
DeguNaoto 49:9276fda93084 27 swingRadVelocity = (((PulsesSwing - PrefPulsesSwing) / 4.0) / pprS ) * 2 * PI;
DeguNaoto 49:9276fda93084 28 PrefPulsesSwing = PulsesSwing;
DeguNaoto 49:9276fda93084 29 }
DeguNaoto 50:8ea4714316ce 30 double cont=0.0;
DeguNaoto 49:9276fda93084 31 inline void swingFollowing(){
DeguNaoto 49:9276fda93084 32 contSwing.setSetPoint(( float )targSwingRadVelocity);
DeguNaoto 49:9276fda93084 33 contSwing.setProcessValue(( float )swingRadVelocity);
DeguNaoto 50:8ea4714316ce 34 cont = contSwing.compute();
DeguNaoto 50:8ea4714316ce 35 Motor_swing = cont;
DeguNaoto 49:9276fda93084 36 }
DeguNaoto 49:9276fda93084 37
DeguNaoto 49:9276fda93084 38 #endif /*Swing.h*/