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

Committer:
shimniok
Date:
Fri Jun 07 14:45:46 2013 +0000
Revision:
3:42f3821c4e54
Parent:
2:fbc6e3cf3ed8
Child:
18:c2f3df4ef5fe
Working version 6/6/2013. Heading estimation may not be quite perfect yet but seems the major estimation bugs are fixed now.

Who changed what in which revision?

UserRevisionLine numberNew 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 3:42f3821c4e54 6 #define clamp360(x) clamp((x), 0, 360.0, false)
shimniok 3:42f3821c4e54 7 #define clamp180(x) clamp((x), -180.0, 180.0, true)
shimniok 0:a6a169de725f 8
shimniok 0:a6a169de725f 9 #ifndef M_PI
shimniok 0:a6a169de725f 10 #define M_PI 3.14159265358979323846
shimniok 0:a6a169de725f 11 #endif
shimniok 0:a6a169de725f 12
shimniok 3:42f3821c4e54 13 /**
shimniok 3:42f3821c4e54 14 * Clamp value between min and max. Specify which of the two are inclusive
shimniok 3:42f3821c4e54 15 * @param v is the value to clamp
shimniok 3:42f3821c4e54 16 * @param min is the minimum value, inclusive if flip==false, exclusive otherwise
shimniok 3:42f3821c4e54 17 * @param max is the maximum value, inclusive if flip==true, exclusive otherwise
shimniok 3:42f3821c4e54 18 * @param flip determines whether min or max is inclusive
shimniok 3:42f3821c4e54 19 * @return the clamped value
shimniok 3:42f3821c4e54 20 */
shimniok 3:42f3821c4e54 21 float clamp(float v, float min, float max, bool flip);
shimniok 2:fbc6e3cf3ed8 22
shimniok 0:a6a169de725f 23 /** Convert char to integer */
shimniok 0:a6a169de725f 24 int ctoi(char c);
shimniok 2:fbc6e3cf3ed8 25
shimniok 0:a6a169de725f 26 /** Convert string to floating point */
shimniok 0:a6a169de725f 27 double cvstof(char *s);
shimniok 2:fbc6e3cf3ed8 28
shimniok 0:a6a169de725f 29 /** Tokenize a string
shimniok 0:a6a169de725f 30 * @param s is the string to tokenize
shimniok 0:a6a169de725f 31 * @param max is the maximum number of characters
shimniok 0:a6a169de725f 32 * @param delim is the character delimiter on which to tokenize
shimniok 0:a6a169de725f 33 * @returns t is the pointer to the next token
shimniok 0:a6a169de725f 34 */
shimniok 0:a6a169de725f 35 char *split(char *s, char *t, int max, char delim);
shimniok 0:a6a169de725f 36
shimniok 0:a6a169de725f 37 #endif