Revision 536
removed any conflict with other fsm variables.
added tentative orbit stop, which needs encoders to be accurate.
orbit_fsm.h | ||
---|---|---|
5 | 5 |
#define _ORBIT_FSM_H_ |
6 | 6 |
|
7 | 7 |
//The States: |
8 |
#define SEEK 12 //Move straight towards robot
|
|
9 |
#define TO_ORBIT 13 //Rotate into orbit
|
|
10 |
#define ORBIT 15 //Orbit robot
|
|
11 |
#define STOP 16 //Stop. The default state, (Something broke).
|
|
8 |
#define ORBIT_SEEK 12 //Move straight towards robot
|
|
9 |
#define ORBIT_INSERTION 13 //Rotate into orbit
|
|
10 |
#define ORBIT_ORBITING 15 //Orbit robot
|
|
11 |
#define ORBIT_STOP 16 //Stop. The default and ending state
|
|
12 | 12 |
|
13 | 13 |
|
14 |
#define STRAIGHT_SPEED 160 |
|
14 |
#define ORBIT_STRAIGHT_SPEED 160
|
|
15 | 15 |
|
16 | 16 |
|
17 | 17 |
#define ORBIT_DIRECTION 4 // if 4, then orbit to the right; if -4, then orbit to the left |
... | ... | |
19 | 19 |
#define ORBIT_DISTANCE 250 // orbit distance as measured by rangefinders |
20 | 20 |
|
21 | 21 |
|
22 |
int state; /*State machine variable.*/ |
|
22 |
int orbit_state; /*State machine variable.*/
|
|
23 | 23 |
|
24 |
int otherRobot; /* must be set prior to running FSM */ |
|
24 |
int orbit_otherRobot; /* must be set prior to running FSM */
|
|
25 | 25 |
|
26 | 26 |
|
27 |
int pControl; /*Proportional control variable, determines turn direction.*/ |
|
28 |
int d1,d2,d3,d4,d5; /*The five distances taken in by IR.*/ |
|
29 |
int bom; /* bom data */ |
|
27 |
int orbit_pControl; /*Proportional control variable, determines turn direction.*/ |
|
28 |
int orbit_d1,orbit_d2,orbit_d3,orbit_d4,orbit_d5; /*The five distances taken in by IR.*/ |
|
29 |
int orbit_bom; /* bom data */ |
|
30 |
int orbit_theta; /* number of degrees traveled in orbit */ |
|
31 |
int orbit_theta_stop; /* stop condition in number of degrees traveled */ |
|
30 | 32 |
|
33 |
/* orbit_init |
|
34 |
argument: robot_id that you want to orbit |
|
35 |
notes: must call before orbit_fsm |
|
36 |
*/ |
|
31 | 37 |
void orbit_init(int robot); |
38 |
|
|
39 |
/* orbit_init_theta |
|
40 |
argument: robot_id that you want to orbit |
|
41 |
theta that you want to stop orbiting at |
|
42 |
notes: must call before orbit_fsm |
|
43 |
*/ |
|
44 |
void orbit_init_theta(int robot,int theta); |
|
45 |
|
|
46 |
/* orbit_fsm |
|
47 |
argument: none |
|
48 |
notes: call in a while loop to perform FSM action |
|
49 |
*/ |
|
32 | 50 |
void orbit_fsm(void); |
33 |
void evaluate_state(void); |
|
34 | 51 |
|
35 | 52 |
#endif |
Also available in: Unified diff