Ben Katz
/
Hobbyking_Cheetah_V1
FOC Implementation for putting multirotor motors in robots
FastMath/FastMath.cpp@14:80ce59119d93, 2016-10-31 (annotated)
- Committer:
- benkatz
- Date:
- Mon Oct 31 16:48:16 2016 +0000
- Revision:
- 14:80ce59119d93
- Parent:
- 0:4e1c4df6aabd
Misc. changes. Finally fixed transforms (turns out B and C current measurements were accidentally swapped)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
benkatz | 0:4e1c4df6aabd | 1 | #include "FastMath.h" |
benkatz | 0:4e1c4df6aabd | 2 | #include "LUT.h" |
benkatz | 0:4e1c4df6aabd | 3 | |
benkatz | 0:4e1c4df6aabd | 4 | const float Multiplier = 81.4873308631f; |
benkatz | 0:4e1c4df6aabd | 5 | |
benkatz | 0:4e1c4df6aabd | 6 | float FastMath::FastSin(float theta){ |
benkatz | 0:4e1c4df6aabd | 7 | if (theta < 0.0f) theta += 6.28318530718f; |
benkatz | 0:4e1c4df6aabd | 8 | if (theta >= 6.28318530718f) theta -= 6.28318530718f; |
benkatz | 0:4e1c4df6aabd | 9 | return SinTable[(int) (Multiplier*theta)] ; |
benkatz | 0:4e1c4df6aabd | 10 | } |
benkatz | 0:4e1c4df6aabd | 11 | |
benkatz | 0:4e1c4df6aabd | 12 | float FastMath::FastCos(float theta){ |
benkatz | 0:4e1c4df6aabd | 13 | return FastSin(1.57079632679f - theta); |
benkatz | 0:4e1c4df6aabd | 14 | } |