Project

General

Profile

Statistics
| Revision:

root / trunk / code / projects / mapping / new_run_around / smart_run_around_fsm.h @ 1199

History | View | Annotate | Download (1.29 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 FORWARD 0   // drive straight forward
11
#define LEFT 1        // drive forward and to the left
12
#define RIGHT 2        // drive forward and to the right
13
#define SPIN 3        // turn without traveling (last resort if otherwise stuck)
14

    
15
/* conditions on rangefinders (in cm) informing state changes
16
 * naming format: SENSOR_URGENCY
17
 * changing these constants affects robot operation
18
 */
19
#define IR2_DANGER 5        // dangerously close to front
20
#define IR13_DANGER 10  // dangerously close to sides (looking ahead)
21
#define IR2_INTEREST 15        // notably close to front
22
#define IR45_DANGER 5        // dangerously close to sides (looking sideways)
23

    
24
uint8_t state;        // current state of FSM: FORWARD, LEFT, RIGHT, SPIN
25
int16_t d1, d2, d3, d4, d5; // values returned by rangefinders
26

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

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

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

    
38
#endif
39