polymorphic base structures for easily implementing different gaits. Triangle wave is already in there
Dependents: robotic_fish_ver_4_9_pixy
fishgait.h@0:aec7653a5b19, 2014-06-19 (annotated)
- Committer:
- sandwich
- Date:
- Thu Jun 19 17:53:17 2014 +0000
- Revision:
- 0:aec7653a5b19
- Child:
- 1:0aa1a6ccf5fe
works
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sandwich | 0:aec7653a5b19 | 1 | #pragma once |
sandwich | 0:aec7653a5b19 | 2 | #include "mbed.h" |
sandwich | 0:aec7653a5b19 | 3 | |
sandwich | 0:aec7653a5b19 | 4 | class fishgait |
sandwich | 0:aec7653a5b19 | 5 | { |
sandwich | 0:aec7653a5b19 | 6 | protected: |
sandwich | 0:aec7653a5b19 | 7 | Timer* t; |
sandwich | 0:aec7653a5b19 | 8 | public: |
sandwich | 0:aec7653a5b19 | 9 | fishgait(); //give the constructor a timer to use |
sandwich | 0:aec7653a5b19 | 10 | ~fishgait(); |
sandwich | 0:aec7653a5b19 | 11 | void setTimer(Timer* tObject); //give the instance a timer to base its calculations off of instead of making a new one |
sandwich | 0:aec7653a5b19 | 12 | virtual float compute()=0; //asbtract function to compute output duty cycle. Must redefine in child classes |
sandwich | 0:aec7653a5b19 | 13 | }; |
sandwich | 0:aec7653a5b19 | 14 | |
sandwich | 0:aec7653a5b19 | 15 | class triangleGait: public fishgait |
sandwich | 0:aec7653a5b19 | 16 | { |
sandwich | 0:aec7653a5b19 | 17 | private: |
sandwich | 0:aec7653a5b19 | 18 | float frq; |
sandwich | 0:aec7653a5b19 | 19 | float amp; |
sandwich | 0:aec7653a5b19 | 20 | public: |
sandwich | 0:aec7653a5b19 | 21 | triangleGait(float freq, float amplitude); |
sandwich | 0:aec7653a5b19 | 22 | //~triangleGait(); |
sandwich | 0:aec7653a5b19 | 23 | float compute(); //this does a triangle wave pattern. frequency and amplitude controlled |
sandwich | 0:aec7653a5b19 | 24 | }; |