geometry changes/fixes/new features

new grid walkers + fixes
new test-cases
worked on step/and turn detection
android offline-data-reader
worked on vap-grouping
This commit is contained in:
2016-09-07 10:16:51 +02:00
parent a203305628
commit d283d9b326
27 changed files with 976 additions and 333 deletions

View File

@@ -28,13 +28,15 @@ public:
/** perform the walk based on the configured setup */
WalkState getDestination(Grid<Node>& grid, const WalkState& _startState, float dist_m) {
WalkState startState = _startState;
updateBefore(startState);
// keep the starting state for reference
//const WalkState startState = _startState;
// the current state that is modified for each step
WalkState currentState = _startState;
updateBefore(currentState);
// get the node that corresponds to start;
const Node* startNode = grid.getNodePtrFor(startState.startPos);
const Node* startNode = grid.getNodePtrFor(currentState.position);
Assert::isNotNull(startNode, "failed to termine start-node for grid-walk");
// currently examined node
@@ -47,7 +49,7 @@ public:
// evaluate each neighbor
for (const Node& neighbor : grid.neighbors(*curNode)) {
const double prob = getProbability(startState, *startNode, *curNode, neighbor);
const double prob = getProbability(currentState, *startNode, *curNode, neighbor);
drawer.add(&neighbor, prob);
}
@@ -55,23 +57,21 @@ public:
const Node* nextNode = drawer.get();
// inform
step(startState, *curNode, *nextNode);
step(currentState, *curNode, *nextNode);
// update
// update distance-to-walk and current position
dist_m -= nextNode->getDistanceInMeter(*curNode);
curNode = nextNode;
currentState.position = *curNode;
}
// output state
WalkState nextState = startState;
nextState.startPos = *curNode;
// update
updateAfter(nextState, *startNode, *curNode);
// update after
updateAfter(currentState, *startNode, *curNode);
// done
return nextState;
return currentState;
}
@@ -107,16 +107,18 @@ private:
/** get the probability for the given random walk (one edge) */
inline double getProbability(const WalkState& state, const Node& start, const Node& cur, const Node& next) const {
//double prob = 1.0;
double prob = 0;
double prob = 1.0;
//double prob = 0;
for (const WalkModule<Node, WalkState>* mdl : modules) {
//prob *= mdl->getProbability(state, start, cur, next);
prob += std::log( mdl->getProbability(state, start, cur, next) );
const double subProb = mdl->getProbability(state, start, cur, next);
Assert::isTrue(subProb >= 0, "probability must not be negative!");
prob *= subProb;
//prob += std::log( mdl->getProbability(state, start, cur, next) );
}
//return prob;
return std::exp(prob);
return prob;
//return std::exp(prob);
}