added new assertins

added some temporary eval parts
new helper methods
worked on the walkers
This commit is contained in:
2016-02-03 19:56:52 +01:00
parent 2e2c1a3004
commit 56203e59ed
5 changed files with 30 additions and 5 deletions

View File

@@ -40,6 +40,9 @@ public:
GridFactory<T> fac(inv); GridFactory<T> fac(inv);
fac.addInverted(g, z_cm); fac.addInverted(g, z_cm);
// sanity check
Assert::isFalse(inv.getNumNodes() == 0, "inverted grid is empty!");
// construct KNN search // construct KNN search
KNN<Grid<T>, 3> knn(inv); KNN<Grid<T>, 3> knn(inv);
@@ -194,7 +197,7 @@ public:
float getWallImportance(float dist_m) { float getWallImportance(float dist_m) {
// avoid sticking too close to walls (unlikely) // avoid sticking too close to walls (unlikely)
static Distribution::Normal<float> avoidWalls(0.0, 0.4); static Distribution::Normal<float> avoidWalls(0.0, 0.5);
// favour walking near walls (likely) // favour walking near walls (likely)
static Distribution::Normal<float> stickToWalls(0.9, 0.5); static Distribution::Normal<float> stickToWalls(0.9, 0.5);

View File

@@ -155,11 +155,14 @@ private:
// update the heading-change and walked-distance // update the heading-change and walked-distance
next.headingChange_rad += next.heading.getRAD() - cur.heading.getRAD(); next.headingChange_rad += next.heading.getRAD() - cur.heading.getRAD();
next.distanceWalked_m += walked_m; next.distanceWalked_m += walked_m;
++((T*)next.node)->cnt; // TODO: eval only
if (next.node->z_cm != cur.node->z_cm) { if (next.node->z_cm != cur.node->z_cm) {
int i = 0; int i = 0;
} }
// done? // done?
if (distRest_m <= 0) {return next;} if (distRest_m <= 0) {return next;}

View File

@@ -114,7 +114,7 @@ private:
if (drawer.getCumProbability() < 0.1 && (--retries) >= 0) { if (drawer.getCumProbability() < 0.1 && (--retries) >= 0) {
walked_m = 0; walked_m = 0;
cur = start; cur = start;
WHAT THE HELL //WHAT THE HELL
if (retries == 0) { reqHeading = dChange.draw(); } if (retries == 0) { reqHeading = dChange.draw(); }
continue; continue;
} }

View File

@@ -22,9 +22,10 @@ template <typename T> class Dijkstra {
public: public:
/** get the dijkstra-pendant for the given user-node */ /** get the dijkstra-pendant for the given user-node. null if none matches */
DijkstraNode<T>* getNode(const T& userNode) { DijkstraNode<T>* getNode(const T& userNode) const {
return nodes[&userNode]; auto it = nodes.find(&userNode);
return (unlikely(it == nodes.end())) ? (nullptr) : (it->second);
} }
/** build shortest path from start to end using the provided wrapper-class */ /** build shortest path from start to end using the provided wrapper-class */

View File

@@ -2,6 +2,9 @@
#define DIJKSTRAPATH_H #define DIJKSTRAPATH_H
#include "DijkstraStructs.h" #include "DijkstraStructs.h"
#include <vector>
#include "../../Assertions.h"
/** /**
* describes a dijkstra-generated path between end and start. * describes a dijkstra-generated path between end and start.
@@ -20,15 +23,30 @@ public:
/** ctor from end- to start-node */ /** ctor from end- to start-node */
DijkstraPath(DijkstraNode<T>* end, DijkstraNode<T>* start) { DijkstraPath(DijkstraNode<T>* end, DijkstraNode<T>* start) {
// sanity checks
Assert::isNotNull(end, "end-node must not be null");
Assert::isNotNull(start, "start-node must not be null");
// follow the path from the end to the start // follow the path from the end to the start
DijkstraNode<T>* curNode = end; DijkstraNode<T>* curNode = end;
while (curNode != start) { while (curNode != start) {
// sanity check in case no path between start and end exists
Assert::isNotNull(curNode, "there is not path between start and end. did you accidentially swap start and end?");
// append
path.push_back(curNode); path.push_back(curNode);
curNode = curNode->previous; curNode = curNode->previous;
} }
} }
/** allow iteration */
decltype(path.begin()) begin() {return path.begin();}
decltype(path.end()) end() {return path.end();}
/** NANOFLANN: number of elements in the path */ /** NANOFLANN: number of elements in the path */
inline int kdtree_get_point_count() const { inline int kdtree_get_point_count() const {
return path.size(); return path.size();