12
fuzzy/fuzzy.h@0:dd5d4837292c, 2021-06-09 (annotated)
- Committer:
- panzhan
- Date:
- Wed Jun 09 01:41:45 2021 +0000
- Revision:
- 0:dd5d4837292c
continuous motion
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
panzhan | 0:dd5d4837292c | 1 | #ifndef _fuzzy_h_ |
panzhan | 0:dd5d4837292c | 2 | #define _fuzzy_h_ |
panzhan | 0:dd5d4837292c | 3 | |
panzhan | 0:dd5d4837292c | 4 | #include "mbed.h" |
panzhan | 0:dd5d4837292c | 5 | |
panzhan | 0:dd5d4837292c | 6 | #define max(a, b) (a>b? a:b) |
panzhan | 0:dd5d4837292c | 7 | #define min(a, b) (a<b? a:b) |
panzhan | 0:dd5d4837292c | 8 | #define range(x, a, b) (min(max(x, a), b)) |
panzhan | 0:dd5d4837292c | 9 | |
panzhan | 0:dd5d4837292c | 10 | |
panzhan | 0:dd5d4837292c | 11 | #define ANKLEE (60.0f) |
panzhan | 0:dd5d4837292c | 12 | #define ANKLEEC (15.0f) |
panzhan | 0:dd5d4837292c | 13 | |
panzhan | 0:dd5d4837292c | 14 | #define KNEEE (35.0f) |
panzhan | 0:dd5d4837292c | 15 | #define KNEEEC (15.0f) |
panzhan | 0:dd5d4837292c | 16 | |
panzhan | 0:dd5d4837292c | 17 | |
panzhan | 0:dd5d4837292c | 18 | |
panzhan | 0:dd5d4837292c | 19 | |
panzhan | 0:dd5d4837292c | 20 | extern const float FuzzyRuleKp[7][7]; |
panzhan | 0:dd5d4837292c | 21 | extern const float FuzzyRuleKd[7][7]; |
panzhan | 0:dd5d4837292c | 22 | |
panzhan | 0:dd5d4837292c | 23 | |
panzhan | 0:dd5d4837292c | 24 | typedef struct{ |
panzhan | 0:dd5d4837292c | 25 | float quantied_e; |
panzhan | 0:dd5d4837292c | 26 | float quantied_ec; |
panzhan | 0:dd5d4837292c | 27 | float quantied_resault; |
panzhan | 0:dd5d4837292c | 28 | float outKp; |
panzhan | 0:dd5d4837292c | 29 | float outKd; |
panzhan | 0:dd5d4837292c | 30 | }fuzzy_control_t; |
panzhan | 0:dd5d4837292c | 31 | void fuzzy_init(fuzzy_control_t *fuzzy ,float max_e,float max_ec,float gain); |
panzhan | 0:dd5d4837292c | 32 | void fuzzy_control(float e,float ec,fuzzy_control_t *fuzzy,const float fuzzyRuleKp[7][7],const float fuzzyRuleKd[7][7]); |
panzhan | 0:dd5d4837292c | 33 | |
panzhan | 0:dd5d4837292c | 34 | extern fuzzy_control_t ankleFuzzy, kneeFuzzy; |
panzhan | 0:dd5d4837292c | 35 | |
panzhan | 0:dd5d4837292c | 36 | |
panzhan | 0:dd5d4837292c | 37 | #endif |