diff --git a/code/CMakeLists.txt.user b/code/CMakeLists.txt.user index d5116e5..8c81593 100644 --- a/code/CMakeLists.txt.user +++ b/code/CMakeLists.txt.user @@ -1,6 +1,6 @@ - + EnvironmentId diff --git a/code/eval/FixedLagEvalBase.h b/code/eval/FixedLagEvalBase.h index ce9e998..f6d7bcf 100644 --- a/code/eval/FixedLagEvalBase.h +++ b/code/eval/FixedLagEvalBase.h @@ -193,6 +193,9 @@ public: //stats file std::ofstream statsout("/tmp/unsmoothed_" + runName + ".stats"); + //heading + double currentHeadingGivenByLukas = 0.0; + // process each single sensor reading while(sr->hasNext()) { @@ -251,6 +254,8 @@ public: obs.turn->delta_motion += _to.delta_motion; ctrl.headingChange_rad = Angle::degToRad(obs.turn->delta_heading); + currentHeadingGivenByLukas = obs.turn->delta_heading; + } @@ -267,6 +272,11 @@ public: const MyState est = pf->update(&ctrl, obs); const Point3 curEst = est.pCur; + //EXPERIMENTAL: Set all Particle Angles to the estimated angle of the particle set +// if(cnt % 30 == 0){ +// pf->setAngle(est.avgAngle * 3.14159265359 / 180); +// } + // error calculation. compare ground-truth to estimation const int offset = 0; const Point3 curGT = gtw.getPosAtTime(se.ts - offset); @@ -334,7 +344,19 @@ public: if (obs.barometer != nullptr) { vis.gp << "set label 112 'baro: " << obs.barometer->hpa << "' at screen 0.1,0.2\n"; } - vis.gp << "set label 111 '" < #include -#include +#include class SmoothingEval1 : public FixedLagEvalBase { @@ -45,7 +45,7 @@ public: //pf->setResampling( std::unique_ptr>(new K::ParticleFilterResamplingPercent(0.10)) ); // state estimation step - pf->setEstimation( std::unique_ptr>(new K::ParticleFilterEstimationWeightedAverage())); + pf->setEstimation( std::unique_ptr>(new K::ParticleFilterEstimationWeightedAverageWithAngle())); //pf->setEstimation( std::unique_ptr>(new K::ParticleFilterEstimationRegionalWeightedAverage())); //pf->setEstimation( std::unique_ptr>(new K::ParticleFilterEstimationOrderedWeightedAverage(0.50f))); @@ -100,14 +100,14 @@ public: //Smoothing Variables smoothing_walk_mu = 0.7; smoothing_walk_sigma = 0.5; - smoothing_heading_sigma = 15.0; + smoothing_heading_sigma = 5.0; smoothing_baro_sigma = 0.05; bool smoothing_resample = false; smoothing_time_delay = 1; //Smoothing using Simple Trans - bf->setEstimation(std::unique_ptr>(new K::ParticleFilterEstimationWeightedAverage())); + bf->setEstimation(std::unique_ptr>(new K::ParticleFilterEstimationWeightedAverageWithAngle())); if(smoothing_resample) bf->setResampling( std::unique_ptr>(new K::ParticleFilterResamplingSimple()) ); bf->setTransition(std::unique_ptr( new MySmoothingTransitionExperimental()) ); diff --git a/code/particles/MyEvaluation.h b/code/particles/MyEvaluation.h index 0e6f0d8..7126f62 100755 --- a/code/particles/MyEvaluation.h +++ b/code/particles/MyEvaluation.h @@ -79,7 +79,7 @@ public: weight *= turnEval.getProbability(p.state, observation.turn, true); //set - p.state.measurement_angle = observation.turn->delta_heading; + p.state.angularHeadingChange = observation.turn->delta_heading; } // set and accumulate diff --git a/code/particles/MyState.h b/code/particles/MyState.h index 380bfa6..2ea177d 100755 --- a/code/particles/MyState.h +++ b/code/particles/MyState.h @@ -29,8 +29,10 @@ struct MyState { // save last hPa measurement for the smoothing process double measurement_pressure; - // save last angle measurement for the smoothing process - double measurement_angle; + // save last angularHeadingChangefor the smoothing process in Degree + double angularHeadingChange; + + double avgAngle; //int distanceWalkedCM; diff --git a/code/particles/smoothing/MySmoothingTransitionExperimental.h b/code/particles/smoothing/MySmoothingTransitionExperimental.h index adfd839..cd686d4 100644 --- a/code/particles/smoothing/MySmoothingTransitionExperimental.h +++ b/code/particles/smoothing/MySmoothingTransitionExperimental.h @@ -29,7 +29,8 @@ public: * @param fp the underlying floorplan */ MySmoothingTransitionExperimental() : - distWalk(smoothing_walk_mu, smoothing_walk_sigma) { + distWalk(smoothing_walk_mu, smoothing_walk_sigma) + { distWalk.setSeed(4321); } @@ -75,23 +76,34 @@ public: //!!!distance kann hier zu groß werden!!! const double distance_m = p2->state.pCur.getDistance(p1->state.pCur) / 100.0; + + //get distance walked and getProb using the walking model //double distDijkstra_m = ((GRID_DISTANCE_CM / 100.0) * (8 - 1)); const double distProb = distWalk.getProbability(distance_m); //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); - } +// 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); +// const double headingProb = K::NormalDistribution::getProbability(p1->state.cumulativeHeading, smoothing_heading_sigma, angle); + + + // 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); + //check how near we are to the measurement double floorProb = K::NormalDistribution::getProbability(p1->state.measurement_pressure, smoothing_baro_sigma, p2->state.hPa); @@ -102,7 +114,7 @@ public: if(distance_m != distance_m) {throw "detected NaN";} if(distProb != distProb) {throw "detected NaN";} - if(angle != angle) {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";}