added activity recognition to smoothing transition

This commit is contained in:
toni
2016-04-26 10:12:10 +02:00
parent ed8e37108a
commit f7e817d5e4
13 changed files with 204 additions and 183 deletions

View File

@@ -96,22 +96,8 @@ public:
auto p2 = &particles_new[j];
// find the node (square) the particle is within
// just to be safe, we round z to the nearest floor
//TODO:: Nullptr check! sometimes src/dst can be nullptr
//const Node3* dst = graph->getNearestNode(p1->state.x_cm, p1->state.y_cm, std::round(p1->state.z_nr));
//const Node3* src = graph->getNearestNode(p2->state.x_cm, p2->state.y_cm, std::round(p2->state.z_nr));
const MyGridNode* src = grid->getNodePtrFor(GridPoint(p2->state.pCur.x, p2->state.pCur.y, p2->state.pCur.z));
// Dijkstra<MyGridNode> dijkstra;
// dijkstra.build(src, dst, DijkstraMapper(*grid));
// double distDijkstra_m = dijkstra.getNode(*src)->cumWeight;
double distDijkstra_m = 0;
//std::vector<const MyGridNode*> shortestPath;
// check if this shortestPath was already calculated
std::map<my_key_type, double>::iterator it;
@@ -121,16 +107,8 @@ public:
}
else{
//Dijkstra/A* for shortest path
//shortestPath = aStar.get(src, dst, dm);
distDijkstra_m = aStar.get(src, dst, dm);
//get distance walked and getProb using the walking model
// for(int i = 0; i < shortestPath.size() - 1; ++i){
// distDijkstra_m += dm.getWeightBetween(*shortestPath[i], *shortestPath[i+1]);
// }
if(distDijkstra_m != distDijkstra_m) {throw "detected NaN";}
//save distance and nodes in lookup map
@@ -140,22 +118,12 @@ public:
const double distProb = distWalk.getProbability(distDijkstra_m * 0.01);
//getProb using the angle(heading) between src and dst
// double angle = 0.0;
// if(!(p2->state.pCur.x == p1->state.pCur.x) && !(p2->state.pCur.y == p1->state.pCur.y)){
// angle = Angle::getDEG_360(p2->state.pCur.x, p2->state.pCur.y, p1->state.pCur.x, p1->state.pCur.y);
// }
// const double headingProb = K::NormalDistribution::getProbability(p1->state.cumulativeHeading, smoothing_heading_sigma, angle);
//heading change prob
double diffRad = Angle::getDiffRAD_2PI_PI(p2->state.walkState.heading.getRAD(), p1->state.walkState.heading.getRAD());
double diffDeg = Angle::radToDeg(diffRad);
double angularChangeZeroToPi = std::fmod(std::abs(p1->state.angularHeadingChange), 360.0);
// is the heading change similiar to the measurement?
double p2AngleDeg = p2->state.walkState.heading.getRAD() * 180/3.14159265359;
double p1AngleDeg = p1->state.walkState.heading.getRAD() * 180/3.14159265359;
double diffDeg = p2AngleDeg - p1AngleDeg;
const double headingProb = K::NormalDistribution::getProbability(p1->state.angularHeadingChange, smoothing_heading_sigma, diffDeg);
//assert(headingProb != 0.0);
//assert(distProb != 0.0);
const double headingProb = K::NormalDistribution::getProbability(angularChangeZeroToPi, smoothing_heading_sigma, diffDeg);
//check how near we are to the measurement
double floorProb = K::NormalDistribution::getProbability(p1->state.measurement_pressure, smoothing_baro_sigma, p2->state.hPa);
@@ -167,10 +135,10 @@ public:
//if(distance_m != distance_m) {throw "detected NaN";}
//if(distProb != distProb) {throw "detected NaN";}
//if(angle != angle) {throw "detected NaN";}
if(headingProb != headingProb) {throw "detected NaN";}
if(floorProb != floorProb) {throw "detected NaN";}
if(floorProb == 0) {throw "detected NaN";}
if(prob != prob) {throw "detected NaN";}
//if(headingProb != headingProb) {throw "detected NaN";}
//if(floorProb != floorProb) {throw "detected NaN";}
//if(floorProb == 0) {throw "detected NaN";}
//if(prob != prob) {throw "detected NaN";}
//assert(prob != 0.0);