Code for autonomous rover for Sparkfun AVC. DataBus won 3rd in 2012 and the same code was used on Troubled Child, a 1986 Jeep Grand Wagoneer to win 1st in 2014.
Dependencies: mbed Watchdog SDFileSystem DigoleSerialDisp
util.h@2:fbc6e3cf3ed8, 2013-06-06 (annotated)
- Committer:
- shimniok
- Date:
- Thu Jun 06 13:40:23 2013 +0000
- Revision:
- 2:fbc6e3cf3ed8
- Parent:
- 0:a6a169de725f
- Child:
- 3:42f3821c4e54
Sort-of working version, still some errors with estimation. Added clamp() function.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shimniok | 0:a6a169de725f | 1 | #ifndef __UTIL_H |
shimniok | 0:a6a169de725f | 2 | #define __UTIL_H |
shimniok | 0:a6a169de725f | 3 | |
shimniok | 0:a6a169de725f | 4 | /** Utility routines */ |
shimniok | 0:a6a169de725f | 5 | |
shimniok | 0:a6a169de725f | 6 | #define clamp360(x) \ |
shimniok | 0:a6a169de725f | 7 | while ((x) >= 360.0) (x) -= 360.0; \ |
shimniok | 0:a6a169de725f | 8 | while ((x) < 0) (x) += 360.0; |
shimniok | 0:a6a169de725f | 9 | #define clamp180(x) ((x) - floor((x)/360.0) * 360.0 - 180.0); |
shimniok | 0:a6a169de725f | 10 | |
shimniok | 0:a6a169de725f | 11 | #ifndef M_PI |
shimniok | 0:a6a169de725f | 12 | #define M_PI 3.14159265358979323846 |
shimniok | 0:a6a169de725f | 13 | #endif |
shimniok | 0:a6a169de725f | 14 | |
shimniok | 2:fbc6e3cf3ed8 | 15 | /** Clamp value between min (non-inclusive) and max (inclusive) */ |
shimniok | 2:fbc6e3cf3ed8 | 16 | float clamp(float v, float min, float max); |
shimniok | 2:fbc6e3cf3ed8 | 17 | |
shimniok | 0:a6a169de725f | 18 | /** Convert char to integer */ |
shimniok | 0:a6a169de725f | 19 | int ctoi(char c); |
shimniok | 2:fbc6e3cf3ed8 | 20 | |
shimniok | 0:a6a169de725f | 21 | /** Convert string to floating point */ |
shimniok | 0:a6a169de725f | 22 | double cvstof(char *s); |
shimniok | 2:fbc6e3cf3ed8 | 23 | |
shimniok | 0:a6a169de725f | 24 | /** Tokenize a string |
shimniok | 0:a6a169de725f | 25 | * @param s is the string to tokenize |
shimniok | 0:a6a169de725f | 26 | * @param max is the maximum number of characters |
shimniok | 0:a6a169de725f | 27 | * @param delim is the character delimiter on which to tokenize |
shimniok | 0:a6a169de725f | 28 | * @returns t is the pointer to the next token |
shimniok | 0:a6a169de725f | 29 | */ |
shimniok | 0:a6a169de725f | 30 | char *split(char *s, char *t, int max, char delim); |
shimniok | 0:a6a169de725f | 31 | |
shimniok | 0:a6a169de725f | 32 | #endif |