Project

General

Profile

Statistics
| Revision:

root / trunk / code / behaviors / hunter_prey / brad / smart_run_around_fsm.h @ 1485

History | View | Annotate | Download (1.42 KB)

1
// smart_run_around_fsm.h
2
// required to run Smart Run Around functions
3
// declare functions and global variables
4

    
5
#ifndef _RUN_AROUND_FSM_H_
6
#define _RUN_AROUND_FSM_H_
7

    
8
// states (robot shall never move in reverse)
9
// these constants may be changed (but can't overlap) without effect
10
#define SRA_FORWARD 0   // drive straight forward
11
#define SRA_LEFT 1        // drive forward and to the left
12
#define SRA_RIGHT 2        // drive forward and to the right
13
#define SRA_SPIN 3        // turn without traveling (last resort if otherwise stuck)
14

    
15
/* conditions on rangefinders (in mm) informing state changes
16
 * distances are 50 greater than in real life, cannot be smaller than 100
17
 * naming format: SENSOR_URGENCY
18
 * changing these constants affects robot operation
19
 */
20
#define IR2_DANGER 150        // 10 cm: dangerously close to front
21
#define IR13_DANGER 200 // 15 cm: dangerously close to sides (looking ahead)
22
#define IR2_INTEREST 300    // 25 cm: notably close to front
23
#define IR45_DANGER 150        // dangerously close to side (looking sideways)
24

    
25
uint8_t state;        // current state of FSM: SRA_FORWARD, SRA_LEFT, SRA_RIGHT, SRA_SPIN
26
int16_t d1, d2, d3, d4, d5; // values returned by rangefinders
27

    
28
// initialize rangefinders and global variables
29
void run_around_init(void);
30

    
31
/* evaluate rangefinder input and update state
32
 * call this function as often as possible to avoid collisions
33
 */
34
void run_around_FSM(void);
35

    
36
// behave according to current state
37
void evaluate_state(void);
38

    
39
#endif
40