This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
Indoor/grid/walk/v2/modules/WalkModuleSpread.h
FrankE d283d9b326 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
2016-09-07 10:16:51 +02:00

63 lines
1.3 KiB
C++

#ifndef WALKMODULESPREAD_H
#define WALKMODULESPREAD_H
#include "WalkModule.h"
#include "WalkStateHeading.h"
/**
* simply try to move away from the starting node as much as possible
*/
template <typename Node, typename WalkState> class WalkModuleSpread : public WalkModule<Node, WalkState> {
private:
Point3 avg;
public:
/** ctor */
WalkModuleSpread() {
;
}
virtual void updateBefore(WalkState& state) override {
(void) state;
avg = avg * 0.999 + state.position.inMeter() * 0.001;
}
virtual void updateAfter(WalkState& state, const Node& startNode, const Node& endNode) override {
(void) state;
(void) startNode;
(void) endNode;
}
virtual void step(WalkState& state, const Node& curNode, const Node& nextNode) override {
(void) state;
(void) curNode;
(void) nextNode;
}
double getProbability(const WalkState& state, const Node& startNode, const Node& curNode, const Node& potentialNode) const override {
(void) state;
(void) startNode;
(void) curNode;
const float dOld = avg.getDistance(curNode.inMeter());
const float dNew = avg.getDistance(potentialNode.inMeter());
if (dNew > dOld) {return 0.8;}
if (curNode.z_cm != potentialNode.z_cm) {return 0.8;}
if (dNew == dOld) {return 0.2;}
return 0;
}
};
#endif // WALKMODULESPREAD_H