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/synthetic/SyntheticSteps.h
k-a-z-u 72f083d32a worked on grid-walker
started adding code for synthetic sensor simulation based on given paths
2017-10-17 17:10:23 +02:00

68 lines
1.5 KiB
C++

#ifndef SYNTHETICSTEPS_H
#define SYNTHETICSTEPS_H
#include "../sensors/imu/AccelerometerData.h"
#include "SyntheticWalker.h"
#include "../math/distribution/Normal.h"
/** fakes accelerometer-data based on synthetic walking data */
class SyntheticSteps : SyntheticWalker::Listener {
public:
class Listener {
public:
virtual void onSyntheticStepData(const Timestamp ts, const AccelerometerData acc) = 0;
};
private:
/** the walker to listen to */
SyntheticWalker* walker;
/** the pedestrian's step-size (in meter) */
float stepSize_m = 0.7;
float lastStepAtDistance = 0;
Distribution::Normal<float> dX = Distribution::Normal<float>(0, 1);
Distribution::Normal<float> dY = Distribution::Normal<float>(0, 1);
Distribution::Normal<float> dZ = Distribution::Normal<float>(0, 1);
std::vector<Listener*> listeners;
public:
/** ctor with the walker to follow */
SyntheticSteps(SyntheticWalker* walker) {
walker->addListener(this);
}
void addListener(Listener* l) {
this->listeners.push_back(l);
}
protected:
void onWalk(const Timestamp walkedTime, float walkedDistance, const Point3 curPos) override {
const float nextStepAt = (lastStepAtDistance + stepSize_m);
const float x = dX.draw();
const float y = dY.draw();
const float z = dZ.draw();
AccelerometerData acc(x, y, z);
if (walkedDistance > nextStepAt) {
lastStepAtDistance = walkedDistance;
}
for (Listener* l : listeners) {l->onSyntheticStepData(walkedTime, acc);}
}
};
#endif // SYNTHETICSTEPS_H