huge commit

- worked on about everything
- grid walker using plugable modules
- wifi models
- new distributions
- worked on geometric data-structures
- added typesafe timestamps
- worked on grid-building
- added sensor-classes
- added sensor analysis (step-detection, turn-detection)
- offline data reader
- many test-cases
This commit is contained in:
2016-08-29 08:18:44 +02:00
parent 99ee95ce7b
commit a2c9e575a2
94 changed files with 8298 additions and 257 deletions

View File

@@ -54,7 +54,10 @@ public:
/** no-copy */
Grid(const Grid& o) = delete;
/** reset the grid (empty) */
/**
* reset (clear) the grid
* remove all nodes, hashes, ..
*/
void reset() {
nodes.clear();
hashes.clear();
@@ -211,10 +214,23 @@ public:
*
*/
UID getUID(const GridPoint& p) const {
const uint64_t x = std::round(p.x_cm / (float)gridSize_cm);
const uint64_t y = std::round(p.y_cm / (float)gridSize_cm);
const uint64_t z = std::round(p.z_cm / (float)gridSize_cm * 5); // z is usually much lower and not always aligned -> allow more room for hashes
// sanity check (region between -1^19 and +1^19
const int32_t max = 1 << 19;
Assert::isBetween((int32_t)p.x_cm, -max, +max, "x out of bounds");
Assert::isBetween((int32_t)p.y_cm, -max, +max, "y out of bounds");
Assert::isBetween((int32_t)p.z_cm, -max, +max, "z out of bounds");
// shift by half of the allowed width of 20 bit to allow negative regions
const uint64_t center = 1 << 19;
// build
const uint64_t x = std::round((p.x_cm+center) / (float)gridSize_cm);
const uint64_t y = std::round((p.y_cm+center) / (float)gridSize_cm);
const uint64_t z = std::round((p.z_cm+center) / (float)gridSize_cm * 5); // z is usually much lower and not always aligned -> allow more room for hashes
return (z << 40) | (y << 20) | (x << 0);
}
/** array access */
@@ -363,63 +379,47 @@ public:
Log::add(name, "memory: " + std::to_string(bytes/1024.0f/1024.0f) + " MB in " + std::to_string(numNodes) + " nodes");
}
// /**
// * remove all nodes, marked for deletion.
// * BEWARE: this will invalidate all indices used externally!
// */
// void cleanupOld() {
// Log::add(name, "running grid cleanup");
public:
// // check every single node
// for (size_t i = 0; i < nodes.size(); ++i) {
/** serialize into the given stream */
void write(std::ostream& out) {
// // is this node marked as "deleted"? (idx == -1)
// if (nodes[i]._idx == -1) {
// serialize static
T::staticSerialize(out);
// // remove this node
// deleteNode(i);
// --i;
// number of nodes
const int numNodes = nodes.size();
out.write((const char*) &numNodes, sizeof(numNodes));
// }
// }
// serialize
for (const T& node : nodes) {
out.write((const char*) &node, sizeof(T));
}
// // rebuild hashes
// Log::add(name, "rebuilding UID hashes", false);
// Log::tick();
// hashes.clear();
// for (size_t idx = 0; idx < nodes.size(); ++idx) {
// hashes[getUID(nodes[idx])] = idx;
// }
// Log::tock();
}
// }
/** deserialize from the given stream */
void read(std::istream& inp) {
private:
// deserialize static
T::staticDeserialize(inp);
// /** hard-delete the given node */
// void deleteNode(const int idx) {
// number of nodes
int numNodes;
inp.read((char*) &numNodes, sizeof(numNodes));
// _assertBetween(idx, 0, nodes.size()-1, "index out of bounds");
// allocate node-space
nodes.resize(numNodes);
// // COMPLEX AND SLOW AS HELL.. BUT UGLY TO REWIRTE TO BE CORRECT
// deserialize
inp.read((char*) nodes.data(), numNodes*sizeof(T));
// // remove him from the node list (reclaim its memory and its index)
// nodes.erase(nodes.begin()+idx);
// update
rebuildHashes();
// // decrement the index for all of the following nodes and adjust neighbor references
// for (size_t i = 0; i < nodes.size(); ++i) {
}
// // decrement the higher indices (reclaim the free one)
// if (nodes[i]._idx >= idx) { --nodes[i]._idx;}
// // adjust the neighbor references (decrement by one)
// for (int n = 0; n < nodes[i]._numNeighbors; ++n) {
// if (nodes[i]._neighbors[n] >= idx) {--nodes[i]._neighbors[n];}
// }
// }
// }
public: