added new assertins
added some temporary eval parts new helper methods worked on the walkers
This commit is contained in:
@@ -40,6 +40,9 @@ public:
|
||||
GridFactory<T> fac(inv);
|
||||
fac.addInverted(g, z_cm);
|
||||
|
||||
// sanity check
|
||||
Assert::isFalse(inv.getNumNodes() == 0, "inverted grid is empty!");
|
||||
|
||||
// construct KNN search
|
||||
KNN<Grid<T>, 3> knn(inv);
|
||||
|
||||
@@ -194,7 +197,7 @@ public:
|
||||
float getWallImportance(float dist_m) {
|
||||
|
||||
// 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)
|
||||
static Distribution::Normal<float> stickToWalls(0.9, 0.5);
|
||||
|
||||
@@ -155,11 +155,14 @@ private:
|
||||
// update the heading-change and walked-distance
|
||||
next.headingChange_rad += next.heading.getRAD() - cur.heading.getRAD();
|
||||
next.distanceWalked_m += walked_m;
|
||||
++((T*)next.node)->cnt; // TODO: eval only
|
||||
|
||||
if (next.node->z_cm != cur.node->z_cm) {
|
||||
int i = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// done?
|
||||
if (distRest_m <= 0) {return next;}
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ private:
|
||||
if (drawer.getCumProbability() < 0.1 && (--retries) >= 0) {
|
||||
walked_m = 0;
|
||||
cur = start;
|
||||
WHAT THE HELL
|
||||
//WHAT THE HELL
|
||||
if (retries == 0) { reqHeading = dChange.draw(); }
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -22,9 +22,10 @@ template <typename T> class Dijkstra {
|
||||
|
||||
public:
|
||||
|
||||
/** get the dijkstra-pendant for the given user-node */
|
||||
DijkstraNode<T>* getNode(const T& userNode) {
|
||||
return nodes[&userNode];
|
||||
/** get the dijkstra-pendant for the given user-node. null if none matches */
|
||||
DijkstraNode<T>* getNode(const T& userNode) const {
|
||||
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 */
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
#define DIJKSTRAPATH_H
|
||||
|
||||
#include "DijkstraStructs.h"
|
||||
#include <vector>
|
||||
|
||||
#include "../../Assertions.h"
|
||||
|
||||
/**
|
||||
* describes a dijkstra-generated path between end and start.
|
||||
@@ -20,15 +23,30 @@ public:
|
||||
/** ctor from end- to start-node */
|
||||
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
|
||||
DijkstraNode<T>* curNode = end;
|
||||
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);
|
||||
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 */
|
||||
inline int kdtree_get_point_count() const {
|
||||
return path.size();
|
||||
|
||||
Reference in New Issue
Block a user