Project

General

Profile

Statistics
| Branch: | Revision:

scoutos / scout / libscout / src / behaviors / navigationMap.h @ cccc25c9

History | View | Annotate | Download (1.21 KB)

1
#ifndef _NAVIGATION_MAP_
2
#define _NAVIGATION_MAP_
3

    
4
#include <cstdlib>
5
#include <queue>
6
#include "../Behavior.h"
7
//#include "lineDrive.h" // Get turn Macros
8

    
9
#define ISTRAIGHT        0
10
#define ILEFT                1
11
#define IRIGHT                2
12
#define IUTURN                3
13

    
14
#define START_STATE 1
15

    
16
#define DEADEND -1
17
#define ARRAY_SIZE 3
18
#define MAX_NODES 12
19

    
20
#define GET_EDGE_DIR(edge) ((edge)&0x3)
21
#define GET_EDGE_STATE(edge) (((edge)>>2)&0xFF)
22
#define GET_EDGE_DIST(edge) (((edge)>>10)&0x3FFFFF)
23

    
24
#define SET_EDGE_DIR(dir) ((dir)&0x3)
25
#define SET_EDGE_STATE(state) (((state)&0xFF)<<2)
26
#define SET_EDGE_DIST(dist) (((dist)&0x3FFFFF)<<10)
27

    
28
#define MAKE_EDGE(dir, state, dist) \
29
  SET_EDGE_DIR(dir)+SET_EDGE_STATE(state)+SET_EDGE_DIST(dist)
30

    
31
typedef int Edge;
32
typedef int State;
33
typedef int Turn;
34

    
35
typedef struct{
36
  int len;
37
  Turn* path;
38
} Path;
39

    
40
class navigationMap : Behavior
41
{
42
  public:
43
    navigationMap(std::string scoutname);
44
    ~navigationMap();
45

    
46
    void run();
47

    
48
    State update_state(Turn turn_made);
49

    
50
    Time get_eta();
51
    Duration get_time_remaining();
52

    
53
    State get_state();
54
    Path shortest_path(State target_state);
55

    
56
    Edge* get_outbound_edges(State state);        
57

    
58
  private:
59
    std::vector <Edge*> map;
60
    State curr_state;
61
    Time arrival_time;
62
};
63
#endif