root / branches / autonomous_recharging / code / projects / autonomous_recharging / dragonfly / homing.c @ 189
History | View | Annotate | Download (928 Bytes)
1 | 148 | cmar | #include "homing.h" |
---|---|---|---|
2 | #include "recharge_defs.h" |
||
3 | |||
4 | // values for homing sensor readings
|
||
5 | #define LEFT_LOW 6 |
||
6 | #define LEFT_HIGH 7 |
||
7 | #define CENTER_LOW 18 |
||
8 | #define CENTER_HIGH 19 |
||
9 | #define RIGHT_LOW 12 |
||
10 | #define RIGHT_HIGH 13 |
||
11 | |||
12 | /**
|
||
13 | * translates homing sensor data into the
|
||
14 | * direction the robot needs to turn
|
||
15 | * (or if it needs to use the BOM).
|
||
16 | **/
|
||
17 | int homing_direction(int beaconcount) |
||
18 | { |
||
19 | if (beaconcount < LEFT_LOW) //can't use beacon, switch to BOM |
||
20 | return HOMING_NONE;
|
||
21 | else if(beaconcount >= CENTER_LOW) |
||
22 | return HOMING_FORWARD;
|
||
23 | else
|
||
24 | { |
||
25 | if(beaconcount >= LEFT_LOW && beaconcount <= LEFT_HIGH)
|
||
26 | return HOMING_LEFT;
|
||
27 | else if (beaconcount >= RIGHT_LOW && beaconcount <= RIGHT_HIGH) |
||
28 | return HOMING_RIGHT;
|
||
29 | else
|
||
30 | { |
||
31 | RECHARGE_DEBUG_PRINT("Unexpected homing sensor value of ");
|
||
32 | RECHARGE_DEBUG_PUTI(beaconcount); |
||
33 | RECHARGE_DEBUG_PRINT(".\n");
|
||
34 | } |
||
35 | } |
||
36 | return HOMING_NONE;
|
||
37 | } |