Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of 2015robot_main by
Swing.h@57:3fbd487e055e, 2015-09-29 (annotated)
- Committer:
- DeguNaoto
- Date:
- Tue Sep 29 08:23:03 2015 +0000
- Revision:
- 57:3fbd487e055e
- Parent:
- 55:db1797ac6cb1
- Child:
- 58:6b73e683fa70
- Child:
- 60:4a75f3f3a934
????????????????????????????; ??????????????????????
Who changed what in which revision?
User | Revision | Line number | New 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 | 57:3fbd487e055e | 6 | |
DeguNaoto | 49:9276fda93084 | 7 | inline void initializeSwing() { |
DeguNaoto | 49:9276fda93084 | 8 | interrupter.rise(&countSwing); |
DeguNaoto | 49:9276fda93084 | 9 | Motor_swing.period_us(SWING_PERIOD); |
DeguNaoto | 49:9276fda93084 | 10 | //controller set |
DeguNaoto | 49:9276fda93084 | 11 | contSwing.setInputLimits(0.0, 1.0); |
DeguNaoto | 49:9276fda93084 | 12 | contSwing.setOutputLimits(0.0, 1.0); |
DeguNaoto | 49:9276fda93084 | 13 | contSwing.setBias(0.0); |
DeguNaoto | 49:9276fda93084 | 14 | contSwing.setMode(AUTO_MODE); |
DeguNaoto | 49:9276fda93084 | 15 | } |
DeguNaoto | 57:3fbd487e055e | 16 | float waitTime = 0.0; |
DeguNaoto | 49:9276fda93084 | 17 | void countSwing() { |
DeguNaoto | 49:9276fda93084 | 18 | Indicator1 = !Indicator1; |
DeguNaoto | 49:9276fda93084 | 19 | if(enableShoot){ |
DeguNaoto | 49:9276fda93084 | 20 | enableShoot=0; |
DeguNaoto | 57:3fbd487e055e | 21 | if(swingRadVelocity > 2.0){ |
DeguNaoto | 57:3fbd487e055e | 22 | waitTime = (float)((2 * PI) / swingRadVelocity); |
DeguNaoto | 57:3fbd487e055e | 23 | wait(waitTime); |
DeguNaoto | 57:3fbd487e055e | 24 | } |
DeguNaoto | 49:9276fda93084 | 25 | sendData(1,6); |
DeguNaoto | 49:9276fda93084 | 26 | } |
DeguNaoto | 49:9276fda93084 | 27 | } |
DeguNaoto | 49:9276fda93084 | 28 | |
DeguNaoto | 55:db1797ac6cb1 | 29 | double swingSita=0.0; |
DeguNaoto | 49:9276fda93084 | 30 | inline void mesureSwing() { |
DeguNaoto | 55:db1797ac6cb1 | 31 | PulsesSwing = ( double )SwingSens.getPulses(); |
DeguNaoto | 55:db1797ac6cb1 | 32 | swingRadVelocity = (((PulsesSwing - PrefPulsesSwing) / 3450) * 2 * PI) / RATE; |
DeguNaoto | 55:db1797ac6cb1 | 33 | PrefPulsesSwing = PulsesSwing; |
DeguNaoto | 49:9276fda93084 | 34 | } |
DeguNaoto | 55:db1797ac6cb1 | 35 | |
DeguNaoto | 50:8ea4714316ce | 36 | double cont=0.0; |
DeguNaoto | 49:9276fda93084 | 37 | inline void swingFollowing(){ |
DeguNaoto | 49:9276fda93084 | 38 | contSwing.setSetPoint(( float )targSwingRadVelocity); |
DeguNaoto | 49:9276fda93084 | 39 | contSwing.setProcessValue(( float )swingRadVelocity); |
DeguNaoto | 50:8ea4714316ce | 40 | cont = contSwing.compute(); |
DeguNaoto | 50:8ea4714316ce | 41 | Motor_swing = cont; |
DeguNaoto | 49:9276fda93084 | 42 | } |
DeguNaoto | 49:9276fda93084 | 43 | |
DeguNaoto | 49:9276fda93084 | 44 | #endif /*Swing.h*/ |