Revision 1864
Added comments (doxygen style) to linefollow and linedrive.
lineDrive.c | ||
---|---|---|
1 |
/** |
|
2 |
* @file lineDrive.c |
|
3 |
* |
|
4 |
* Provides functions to implement line driving behavior. This program extends |
|
5 |
* the behavior of the line-following program by following lines automatically |
|
6 |
* and implementing behaviors to deal with commands passed to lineDrive. |
|
7 |
* |
|
8 |
* @author Dan Jacobs |
|
9 |
* @date 11-1-2010 |
|
10 |
*/ |
|
11 |
|
|
1 | 12 |
#include "lineDrive.h" |
2 | 13 |
|
3 |
int state[5]; |
|
14 |
int state[5]; //! Stores a queue of sub-commands to be executed
|
|
4 | 15 |
int stateCounter; |
5 | 16 |
int stateLength; |
17 |
|
|
18 |
//! Whether lineDrive is currently paused. Set to 0 on initialization. |
|
6 | 19 |
int stopped=1; |
7 | 20 |
|
8 | 21 |
|
9 |
|
|
22 |
/** |
|
23 |
* Starts the line following procedure. Must be called before other |
|
24 |
* line-following functions will work. This function essentially resets the |
|
25 |
* state of line-following. |
|
26 |
*/ |
|
10 | 27 |
void lineDrive_init() |
11 | 28 |
{ |
12 | 29 |
lineFollow_init(); |
... | ... | |
17 | 34 |
} |
18 | 35 |
|
19 | 36 |
|
20 |
|
|
37 |
/** |
|
38 |
* Follows a line and executes whatever command is next on the queue. |
|
39 |
* @param speed The speed with which to drive along the line. |
|
40 |
*/ |
|
21 | 41 |
int doDrive(int speed) |
22 | 42 |
{ |
23 | 43 |
if(stopped) |
... | ... | |
97 | 117 |
} |
98 | 118 |
|
99 | 119 |
|
120 |
/** Starts the line-drive process if paused. */ |
|
100 | 121 |
void start(void){stopped=0;} |
122 |
|
|
123 |
/** Pauses the line-drive process. Default is started. */ |
|
101 | 124 |
void stop(void){stopped=1;} |
102 | 125 |
|
103 | 126 |
|
127 |
/** |
|
128 |
* Defines a merge command in the direction specified. A merge is a switch |
|
129 |
* of lanes. |
|
130 |
* @param dir Left or right, defined by ILEFT or IRIGHT |
|
131 |
*/ |
|
104 | 132 |
int merge(int dir) |
105 | 133 |
{ |
106 | 134 |
if(stateLength!=0)return ERROR; |
... | ... | |
109 | 137 |
return NORMAL; |
110 | 138 |
} |
111 | 139 |
|
140 |
/** |
|
141 |
* Executes an intersection turn where the intersection type is specified by the |
|
142 |
* parameters. |
|
143 |
* @param type A valid defined intersection type |
|
144 |
* @param dir The direction to turn at the intersection |
|
145 |
*/ |
|
112 | 146 |
int turn(int type, int dir) |
113 | 147 |
{ |
114 | 148 |
if(stateLength!=0)return ERROR; |
Also available in: Unified diff