worked on grid-walker
started adding code for synthetic sensor simulation based on given paths
This commit is contained in:
67
synthetic/SyntheticSteps.h
Normal file
67
synthetic/SyntheticSteps.h
Normal file
@@ -0,0 +1,67 @@
|
||||
#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
|
||||
Reference in New Issue
Block a user