Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (3.42 KB)

1
#ifndef TRAFFIC_NAVIGATION_H
2

    
3
/* Debug Options - These must go before includes */
4
#define MAIN_NEW /* compile the new main */
5
#define ORB_INTERSECTION
6

    
7
#include <dragonfly_lib.h>
8
#include <wl_basic.h>
9
#include "../linefollowing/lineDrive.h"
10
#include "highways.h"
11
#include "intersectData.h"
12
#include "validTurns.h"
13

    
14
/*States*/
15
#define SROAD 0
16
#define SINTERSECTION 9 /* for old version */
17
#define SINTERSECTION_ENTER 10
18
#define SINTERSECTION_ENTER_RESOLV 11
19
#define SINTERSECTION_WAIT 12
20
#define SINTERSECTION_DRIVE 13
21
#define SHIGHWAY 20
22
#define SCLEARPACKET 30
23

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

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

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

    
88
/*Macros
89
 */
90
#define ISPING(p) ((p)[0]==WPINGGLOBAL || (p)[0]==WPINGBOT || (p)[0]==WPINGQUEUE)
91

    
92
#endif