Project

General

Profile

Statistics
| Revision:

root / trunk / code / projects / traffic_navigation / traffic_navigation.h @ 1969

History | View | Annotate | Download (3.45 KB)

1
#ifndef TRAFFIC_NAVIGATION_H
2

    
3
#include <dragonfly_lib.h>
4
#include <wl_basic.h>
5
#include "../linefollowing/lineDrive.h"
6
#include "highways.h"
7
#include "intersectData.h"
8
#include "validTurns.h"
9

    
10
/* Debug Options */
11
#ifdef DEBUGALL
12
#define ORB_HIGHWAY
13
#define ORB_LINEFOLLOW
14
#define ORB_INTERSECTON
15
#define DEBUG_CA
16
#define DEBUG_INTERSECTION
17
#endif
18

    
19
/*States*/
20
#define SROAD 0
21
#define SINTERSECTION 9 /* for old version */
22
#define SINTERSECTION_ENTER 10
23
#define SINTERSECTION_ENTER_RESOLV 11
24
#define SINTERSECTION_WAIT 12
25
#define SINTERSECTION_DRIVE 13
26
#define SHIGHWAY 20
27
#define SCLEARPACKET 30
28

    
29
/*Sign Codes
30
 * bitwise OR labels to create a barcode or read one
31
 * There should be macros to extract these probably
32
 * The bits will be stored in some variable (char or short)
33
 * Bits if road: ? ? ? NAME NAME NAME TYPE CROAD
34
 * Bits if intersection: ? ? ? ? DIR DIR #WAYS CINTERSECTION
35
 */
36
#define CROAD 0x0 //0b
37
#define CINTERSECTION 0x1 //1b
38
#define CNORMALROAD 0x0 //00b
39
#define CHIGHWAYROAD 0x2 //10b
40
#define C4WAY 0x0 //00b
41
#define C3WAY 0x2 //10b
42
#define CNORTH 0x0 //0000b
43
#define CEAST 0x4 //0100b
44
#define CSOUTH 0x8 //1000b
45
#define CWEST 0x12 //1100b
46

    
47
/*Wireless Packet Types
48
 * The first byte of any wireless packet should be one of these types.
49
 * Each type will have its own structure
50
 * The second byte should be the id of the bot sending the packet
51
 * The third byte should be the number of the intersection or road that
52
 *   the packet pertains to
53
 */
54
#define PACKET_LENGTH 5
55
#define WROADENTRY 0 //[type, bot, road]
56
#define WROADREPLY 1 //[type, fromBot, road, toBot]
57
#define WROADEXIT 2 //[type, bot, road]
58
#define WROADSTOP 3 //[type, bot, road]
59
#define WINTERSECTIONENTRY 10   //[type, bot, intersection, fromDir, toDir]
60
#define WINTERSECTIONREPLY 11   //[type, fromBot, intersection, toBot]
61
#define WINTERSECTIONEXIT 12    //[type, bot, intersection]
62
#define WINTERSECTIONGO 13      //[type, bot, intersection]
63
#define WINTERSECTIONPOLICEENTRY 14
64
#define WINTERSECTIONRESOLVERACE 15   //[type, bot, intersection, num]
65
#define WHIGHWAYENTRY 20 //[type, bot, highway]
66
#define WHIGHWAYREPLY 21 //[type, fromBot, highway, toBot]
67
#define WHIGHWAYEXIT 22 //[type, bot, highway]
68
#define WPINGGLOBAL 30 //[type, bot]
69
#define WPINGBOT 31 //[type, fromBot, toBot]
70
#define WPINGQUEUE 32 //[type, fromBot, toBot]
71
#define WPINGREPLY 33 //[type, fromBot, toBot]
72
#define WCOLLISIONAVOID 41 //[type, bot, intersection, collision-int] //Note: collision is an int and thus takes two spaces
73

    
74
/*Wireless Parsing Status
75
 * For wireless parsing - status codes describing various errors/statuses with wireless
76
 * parsing. 
77
 * Errors begin with E - Note that all of these errors are actually returned as negative.
78
 *                     - values of >= 100 indicate a serious error
79
 * Non-Errors begin with K - returned as positive. (don't start with S because S
80
 *                           is for state)
81
 */
82
#define ENOPACKET -10 //The received packet doesn't exist.
83
#define ENOACTION -15 //The received packet has no defined action, and this is OK
84
#define ENOIMPLEMENT -20 //The received packet has no defined action and needs to be implemented.
85
#define EPACKETLEN -100 //The received packet was the wrong length
86
#define KOK 1
87
#define KPLACEDINQUEUE 20
88
#define KFAILEDTOQUEUE 21
89
#define KFIRSTINQUEUE 22
90
#define KREPLIEDTOENTER 23
91
#define KRESOLVINGENTER 24 //resolving a race between bots trying to enter intersection at the same time.
92

    
93
/*Macros
94
 */
95
#define ISPING(p) ((p)[0]==WPINGGLOBAL || (p)[0]==WPINGBOT || (p)[0]==WPINGQUEUE)
96

    
97
#endif