This is some awesome robot code
Dependencies: mbed-rtos mbed QEI
Fork of ICRSEurobot13 by
supportfuncs.h@25:b16f1045108f, 2013-04-10 (annotated)
- Committer:
- madcowswe
- Date:
- Wed Apr 10 02:01:51 2013 +0000
- Revision:
- 25:b16f1045108f
- Parent:
- 20:70d651156779
- Child:
- 62:78d99b781f02
Motion and motor works, but needs tuning
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
madcowswe | 16:52250d8d8fce | 1 | #ifndef SUPPORTFUNCS_H |
madcowswe | 16:52250d8d8fce | 2 | #define SUPPORTFUNCS_H |
madcowswe | 16:52250d8d8fce | 3 | |
madcowswe | 16:52250d8d8fce | 4 | #include <cmath> |
madcowswe | 19:4b993a9a156e | 5 | #include "globals.h" |
madcowswe | 20:70d651156779 | 6 | #include "tvmet/Matrix.h" |
madcowswe | 16:52250d8d8fce | 7 | |
madcowswe | 16:52250d8d8fce | 8 | //Constrains agles to +/- pi |
madcowswe | 16:52250d8d8fce | 9 | inline float constrainAngle(float x){ |
madcowswe | 19:4b993a9a156e | 10 | x = fmod(x + PI, 2*PI); |
madcowswe | 16:52250d8d8fce | 11 | if (x < 0) |
madcowswe | 19:4b993a9a156e | 12 | x += 2*PI; |
madcowswe | 19:4b993a9a156e | 13 | return x - PI; |
madcowswe | 16:52250d8d8fce | 14 | } |
madcowswe | 16:52250d8d8fce | 15 | |
madcowswe | 20:70d651156779 | 16 | template <typename T> |
madcowswe | 20:70d651156779 | 17 | tvmet::Matrix <T, 2, 2> Rotmatrix(T theta) { |
madcowswe | 20:70d651156779 | 18 | tvmet::Matrix <T, 2, 2> outmatrix; |
madcowswe | 20:70d651156779 | 19 | outmatrix = cos(theta), -sin(theta), |
madcowswe | 20:70d651156779 | 20 | sin(theta), cos(theta); |
madcowswe | 20:70d651156779 | 21 | return outmatrix; |
madcowswe | 20:70d651156779 | 22 | } |
madcowswe | 20:70d651156779 | 23 | |
madcowswe | 16:52250d8d8fce | 24 | #endif //SUPPORTFUNCS_H |