worked on grid-walker and synthetic steps/turns

This commit is contained in:
k-a-z-u
2017-11-29 16:35:29 +01:00
parent 55c061b344
commit 63bc2f3046
5 changed files with 370 additions and 232 deletions

View File

@@ -37,14 +37,22 @@ private:
Distribution::Normal<float> dY = Distribution::Normal<float>(0, 0.3);
Distribution::Normal<float> dZ = Distribution::Normal<float>(0, 0.4);
int stepPatternPos = -1;
std::vector<Listener*> listeners;
//float stepSize_m;
//float stepSizeSigma_m;
float noiseLevel;
Distribution::Normal<float> dNextStep;
public:
/** ctor with the walker to follow */
SyntheticSteps(SyntheticWalker* walker) {
SyntheticSteps(SyntheticWalker* walker, const float stepSize_m = 0.7, const float stepSizeSigma_m = 0.1, const float noiseLevel = 0.33) :
//stepSize_m(stepSize_m), drift(drift), stepSizeSigma_m(stepSizeSigma_m),
noiseLevel(noiseLevel), dNextStep(stepSize_m, stepSizeSigma_m) {
walker->addListener(this);
dX.setSeed(1);
@@ -82,15 +90,15 @@ protected:
void onWalk(const Timestamp walkedTime, float walkedDistance, const Point3 curPos) override {
(void) curPos;
const float nextStepAt = (lastStepAtDistance + stepSize_m);
const float nextStepAt = lastStepAtDistance + dNextStep.draw();
// 1st, start with random noise on the accelerometer
const float x = dX.draw();
const float y = dY.draw();
const float z = dZ.draw();
const AccelerometerData base(0, 4, 9.7);
const AccelerometerData noise(x, y, z);
AccelerometerData acc = base + noise;
const AccelerometerData aBase(0, 4, 9.7);
const AccelerometerData aNoise(x, y, z);
AccelerometerData acc = aBase + aNoise * noiseLevel;
// is it time to inject a "step" into the accelerometer data?
if (walkedDistance > nextStepAt) {
@@ -105,7 +113,7 @@ protected:
refStepPattern = Timestamp::fromMS(0);
} else {
const AccelerometerData step = stepPattern.get(curPatPos);
acc = base + noise*2.5f + step;
acc = aBase + (aNoise * noiseLevel) + step;
}
}