added activity recognition to smoothing transition
This commit is contained in:
@@ -17,37 +17,38 @@ class MySmoothingTransitionSimple : public K::BackwardFilterTransition<MyState>
|
||||
|
||||
private:
|
||||
|
||||
/** a simple normal distribution */
|
||||
K::NormalDistribution distWalk;
|
||||
/** a simple normal distribution */
|
||||
K::NormalDistribution distWalk;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* ctor
|
||||
* @param choice the choice to use for randomly drawing nodes
|
||||
* @param fp the underlying floorplan
|
||||
*/
|
||||
/**
|
||||
* ctor
|
||||
* @param choice the choice to use for randomly drawing nodes
|
||||
* @param fp the underlying floorplan
|
||||
*/
|
||||
MySmoothingTransitionSimple() :
|
||||
distWalk(smoothing_walk_mu, smoothing_walk_sigma) {
|
||||
distWalk(smoothing_walk_mu, smoothing_walk_sigma)
|
||||
{
|
||||
distWalk.setSeed(4321);
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
uint64_t ts = 0;
|
||||
uint64_t deltaMS = 0;
|
||||
uint64_t ts = 0;
|
||||
uint64_t deltaMS = 0;
|
||||
|
||||
/** set the current time in millisconds */
|
||||
void setCurrentTime(const uint64_t ts) {
|
||||
if (this->ts == 0) {
|
||||
this->ts = ts;
|
||||
deltaMS = 0;
|
||||
} else {
|
||||
/** set the current time in millisconds */
|
||||
void setCurrentTime(const uint64_t ts) {
|
||||
if (this->ts == 0) {
|
||||
this->ts = ts;
|
||||
deltaMS = 0;
|
||||
} else {
|
||||
deltaMS = this->ts - ts;
|
||||
this->ts = ts;
|
||||
}
|
||||
}
|
||||
this->ts = ts;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* smoothing transition starting at T with t, t-1,...0
|
||||
@@ -64,52 +65,44 @@ public:
|
||||
// p(q_490(1)|q_489(1)); p(q_490(2)|q_489(1)) ... p(q_490(M)|q_489(1))
|
||||
std::vector<std::vector<double>> predictionProbabilities;
|
||||
|
||||
auto p1 = particles_old.begin(); //smoothed / backward filter p_t+1
|
||||
auto p2 = particles_new.begin(); //forward filter p_t
|
||||
|
||||
#pragma omp parallel for private(p2) shared(predictionProbabilities)
|
||||
for (p1 = particles_old.begin(); p1 < particles_old.end(); ++p1) {
|
||||
omp_set_dynamic(0); // Explicitly disable dynamic teams
|
||||
omp_set_num_threads(6);
|
||||
#pragma omp parallel for shared(predictionProbabilities)
|
||||
for (int i = 0; i < particles_old.size(); ++i) {
|
||||
std::vector<double> innerVector;
|
||||
for(p2 = particles_new.begin(); p2 < particles_new.end(); ++p2){
|
||||
auto p1 = &particles_old[i];
|
||||
|
||||
//!!!distance kann hier zu groß werden!!!
|
||||
for(int j = 0; j < particles_new.size(); ++j){
|
||||
|
||||
auto p2 = &particles_new[j];
|
||||
|
||||
//distance can be pretty big here
|
||||
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);
|
||||
}
|
||||
|
||||
const double headingProb = K::NormalDistribution::getProbability(p1->state.cumulativeHeading, smoothing_heading_sigma, angle);
|
||||
|
||||
//assert(headingProb != 0.0);
|
||||
//assert(distProb != 0.0);
|
||||
|
||||
//get proba for heading change
|
||||
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);
|
||||
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);
|
||||
|
||||
|
||||
//combine the probabilities
|
||||
double prob = distProb * headingProb * floorProb;
|
||||
innerVector.push_back(prob);
|
||||
|
||||
//error checks
|
||||
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(floorProb == 0) {throw "detected zero prob in floorprob";}
|
||||
if(prob != prob) {throw "detected NaN";}
|
||||
|
||||
//assert(prob != 0.0);
|
||||
|
||||
//if(prob == 0) {throw "detected zero prob in smoothing transition";}
|
||||
|
||||
}
|
||||
#pragma omp critical
|
||||
@@ -122,4 +115,4 @@ public:
|
||||
|
||||
};
|
||||
|
||||
#endif // MYTRANSITION_H
|
||||
#endif // MYTRANSITIONSIMPLE_H
|
||||
|
||||
Reference in New Issue
Block a user