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