Statistics
| Branch: | Tag: | Revision:

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

History | View | Annotate | Download (894 Bytes)

1 e1f1c4b5 galberding
#include "amiro_map.hpp"
2
3
4 b8b3a9c9 galberding
void AmiroMap::initialize(uint8_t (&config)[MAX_NODES][NODE_ATTRIBUTES]){
5 e1f1c4b5 galberding
6 b8b3a9c9 galberding
  // Clear old values in case the map is initialized again
7
  this->current = 0;
8
  this->next = 0;
9
  this->valid = false;
10 e1f1c4b5 galberding
11 b8b3a9c9 galberding
  // convert proto map to internal representation
12 e1f1c4b5 galberding
  for (int i=0; i<MAX_NODES; i++){
13 b8b3a9c9 galberding
    if(config[i][2] == 0xff && i != 0){
14
      this->valid = true;
15 e1f1c4b5 galberding
      break;
16 b8b3a9c9 galberding
    } else if (config[i][2] == 0xff && i == 0) {
17
      this->valid = false;
18
      return;
19 e1f1c4b5 galberding
    }
20
21 b8b3a9c9 galberding
    //look for start node (default is Node 0)
22
    if (config[i][2] == 1 ) {
23
      this->current= i;
24
    }
25 e1f1c4b5 galberding
26 b8b3a9c9 galberding
    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 e1f1c4b5 galberding
33 b8b3a9c9 galberding
  // TODO make validity check
34 e1f1c4b5 galberding
35
36
}
37
38 b8b3a9c9 galberding
void AmiroMap::update(bool left, bool right, LineFollowStrategy strategy) {
39 e1f1c4b5 galberding
40
}