Statistics
| Branch: | Tag: | Revision:

amiro-os / devices / DiWheelDrive / amiro_map.cpp @ b8b3a9c9

History | View | Annotate | Download (894 Bytes)

1
#include "amiro_map.hpp"
2

    
3

    
4
void AmiroMap::initialize(uint8_t (&config)[MAX_NODES][NODE_ATTRIBUTES]){
5

    
6
  // Clear old values in case the map is initialized again
7
  this->current = 0;
8
  this->next = 0;
9
  this->valid = false;
10

    
11
  // convert proto map to internal representation
12
  for (int i=0; i<MAX_NODES; i++){
13
    if(config[i][2] == 0xff && i != 0){
14
      this->valid = true;
15
      break;
16
    } else if (config[i][2] == 0xff && i == 0) {
17
      this->valid = false;
18
      return;
19
    }
20

    
21
    //look for start node (default is Node 0)
22
    if (config[i][2] == 1 ) {
23
      this->current= i;
24
    }
25

    
26
    this->nodeList[i].id = i;
27
    this->nodeList[i].left = config[i][0];
28
    this->nodeList[i].right = config[i][1];
29
    this->nodeList[i].flag = config[i][2];
30
    this->nodeCount++;
31
  }
32

    
33
  // TODO make validity check
34

    
35

    
36
}
37

    
38
void AmiroMap::update(bool left, bool right, LineFollowStrategy strategy) {
39

    
40
}