merged
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#ifdef WITH_TESTS
|
||||
#ifdef TODO_________WITH_TESTS
|
||||
|
||||
#include "../../Tests.h"
|
||||
|
||||
@@ -9,191 +9,190 @@
|
||||
/** visualize the motionAxis */
|
||||
TEST(MotionDetection, motionAxis) {
|
||||
|
||||
MotionDetection md;
|
||||
MotionDetection md;
|
||||
|
||||
//plot.gp << "set arrow 919 from " << tt.pos.x << "," << tt.pos.y << "," << tt.pos.z << " to "<< tt.pos.x << "," << tt.pos.y << "," << tt.pos.z+1 << "lw 3\n";
|
||||
//plot.gp << "set arrow 919 from " << tt.pos.x << "," << tt.pos.y << "," << tt.pos.z << " to "<< tt.pos.x << "," << tt.pos.y << "," << tt.pos.z+1 << "lw 3\n";
|
||||
|
||||
//Walking with smartphone straight and always parallel to motion axis
|
||||
//std::string filename = getDataFile("motion/straight_potrait.csv");
|
||||
//Walking with smartphone straight and always parallel to motion axis
|
||||
//std::string filename = getDataFile("motion/straight_potrait.csv");
|
||||
|
||||
//straight_landscape_left/right: walking ~40 sec straight and changing every 5 seconds the mode. started with potrait. landscape routed either to left or right.
|
||||
std::string filename = getDataFile("motion/straight_landscape_left.csv");
|
||||
//std::string filename = getDataFile("motion/straight_landscape_right.csv");
|
||||
//straight_landscape_left/right: walking ~40 sec straight and changing every 5 seconds the mode. started with potrait. landscape routed either to left or right.
|
||||
std::string filename = getDataFile("motion/straight_landscape_left.csv");
|
||||
//std::string filename = getDataFile("motion/straight_landscape_right.csv");
|
||||
|
||||
//straight_inturn_landscape: walked straight made a left turn and change the phone to landscape mode during the turn-phase
|
||||
//std::string filename = getDataFile("motion/straight_inturn_landscape.csv");
|
||||
//straight_inturn_landscape: walked straight made a left turn and change the phone to landscape mode during the turn-phase
|
||||
//std::string filename = getDataFile("motion/straight_inturn_landscape.csv");
|
||||
|
||||
//rounds_potrait: walked 3 rounds holding the phone in potrait mode. always making left turns.
|
||||
//std::string filename = getDataFile("motion/rounds_potrait.csv");
|
||||
//rounds_potrait: walked 3 rounds holding the phone in potrait mode. always making left turns.
|
||||
//std::string filename = getDataFile("motion/rounds_potrait.csv");
|
||||
|
||||
//round_landscape: walked 3 rounds holding the phone in landscape mode. always making left turns.
|
||||
//std::string filename = getDataFile("motion/rounds_landscape.csv");
|
||||
//round_landscape: walked 3 rounds holding the phone in landscape mode. always making left turns.
|
||||
//std::string filename = getDataFile("motion/rounds_landscape.csv");
|
||||
|
||||
//round potrait_to_landscape: walked 1 round with potrait, 1 with landscape and again potrait. the mode was change while walking straight not in a turn. always making left turns.
|
||||
//std::string filename = getDataFile("motion/rounds_potrait_to_landscape.csv");
|
||||
//round potrait_to_landscape: walked 1 round with potrait, 1 with landscape and again potrait. the mode was change while walking straight not in a turn. always making left turns.
|
||||
//std::string filename = getDataFile("motion/rounds_potrait_to_landscape.csv");
|
||||
|
||||
//rounds_pocket: had the phone in my jeans pocket screen pointed at my body and the phone was headfirst. pulled it shortly out after 2 rounds and rotated the phone 180° z-wise (screen not showing at me)
|
||||
//std::string filename = getDataFile("motion/rounds_pocket.csv");
|
||||
//rounds_pocket: had the phone in my jeans pocket screen pointed at my body and the phone was headfirst. pulled it shortly out after 2 rounds and rotated the phone 180° z-wise (screen not showing at me)
|
||||
//std::string filename = getDataFile("motion/rounds_pocket.csv");
|
||||
|
||||
//table_flat: phone was flat on the table and moved slowly forward/backward for 60 cm.
|
||||
//std::string filename = getDataFile("motion/table_flat.csv");
|
||||
//table_flat: phone was flat on the table and moved slowly forward/backward for 60 cm.
|
||||
//std::string filename = getDataFile("motion/table_flat.csv");
|
||||
|
||||
Offline::FileReader fr(filename);
|
||||
|
||||
K::Gnuplot gp;
|
||||
K::GnuplotPlot plot;
|
||||
K::Gnuplot gp;
|
||||
K::GnuplotPlot plot;
|
||||
|
||||
gp << "set xrange[-1:1]\n set yrange[-1:1]\n";
|
||||
gp << "set xrange[-1:1]\n set yrange[-1:1]\n";
|
||||
|
||||
|
||||
Eigen::Vector2f curVec;
|
||||
float motionAxisAngleRad;
|
||||
Timestamp ts;
|
||||
Timestamp lastTs;
|
||||
Eigen::Vector2f curVec;
|
||||
float motionAxisAngleRad;
|
||||
Timestamp ts;
|
||||
Timestamp lastTs;
|
||||
|
||||
//calc motion axis
|
||||
//calc motion axis
|
||||
for (const Offline::Entry& e : fr.getEntries()) {
|
||||
|
||||
ts = Timestamp::fromMS(e.ts);
|
||||
ts = Timestamp::fromMS(e.ts);
|
||||
|
||||
if (e.type == Offline::Sensor::LIN_ACC) {
|
||||
md.addLinearAcceleration(ts, fr.getLinearAcceleration()[e.idx].data);
|
||||
md.addLinearAcceleration(ts, fr.getLinearAcceleration()[e.idx].data);
|
||||
|
||||
} else if (e.type == Offline::Sensor::GRAVITY) {
|
||||
md.addGravity(ts, fr.getGravity()[e.idx].data);
|
||||
curVec = md.getCurrentMotionAxis();
|
||||
motionAxisAngleRad = md.getMotionChangeInRad();
|
||||
}
|
||||
md.addGravity(ts, fr.getGravity()[e.idx].data);
|
||||
curVec = md.getCurrentMotionAxis();
|
||||
motionAxisAngleRad = md.getMotionChangeInRad();
|
||||
}
|
||||
|
||||
// start with the first available timestamp
|
||||
if (lastTs.isZero()) {lastTs = ts;}
|
||||
// start with the first available timestamp
|
||||
if (lastTs.isZero()) {lastTs = ts;}
|
||||
|
||||
if(ts - lastTs > Timestamp::fromMS(500)) {
|
||||
if(ts - lastTs > Timestamp::fromMS(500)) {
|
||||
|
||||
lastTs = ts;
|
||||
lastTs = ts;
|
||||
|
||||
K::GnuplotPoint2 raw_p1(0, 0);
|
||||
K::GnuplotPoint2 raw_p2(curVec(0,0), curVec(1,0));
|
||||
K::GnuplotPlotElementLines motionLines;
|
||||
motionLines.addSegment(raw_p1, raw_p2);
|
||||
plot.add(&motionLines);
|
||||
K::GnuplotPoint2 raw_p1(0, 0);
|
||||
K::GnuplotPoint2 raw_p2(curVec(0,0), curVec(1,0));
|
||||
K::GnuplotPlotElementLines motionLines;
|
||||
motionLines.addSegment(raw_p1, raw_p2);
|
||||
plot.add(&motionLines);
|
||||
|
||||
gp << "set label 111 ' Angle: " << motionAxisAngleRad * 180 / 3.14159 << "' at screen 0.1,0.1\n";
|
||||
gp << "set label 111 ' Angle: " << motionAxisAngleRad * 180 / 3.14159 << "' at screen 0.1,0.1\n";
|
||||
|
||||
gp.draw(plot);
|
||||
gp.flush();
|
||||
//usleep(5000*33);
|
||||
}
|
||||
}
|
||||
gp.draw(plot);
|
||||
gp.flush();
|
||||
//usleep(5000*33);
|
||||
}
|
||||
}
|
||||
|
||||
//was passiert bei grenzwerten. 90° oder sowas.
|
||||
//wie stabil ist die motion axis eigentlich?
|
||||
//erkenn wir aktuell überhaupt einen turn, wenn wir das telefon drehen?
|
||||
//wie hilft mir die motion achse? über einen faktor? in welchem verhältnis stehen motion axis und heading?
|
||||
//was passiert bei grenzwerten. 90° oder sowas.
|
||||
//wie stabil ist die motion axis eigentlich?
|
||||
//erkenn wir aktuell überhaupt einen turn, wenn wir das telefon drehen?
|
||||
//wie hilft mir die motion achse? über einen faktor? in welchem verhältnis stehen motion axis und heading?
|
||||
|
||||
}
|
||||
|
||||
/** comparing motionAngle and turnAngle */
|
||||
TEST(MotionDetection, motionAngle) {
|
||||
|
||||
MotionDetection md;
|
||||
PoseDetection pd;
|
||||
TurnDetection td(&pd);
|
||||
MotionDetection md;
|
||||
TurnDetection td;
|
||||
|
||||
//plot.gp << "set arrow 919 from " << tt.pos.x << "," << tt.pos.y << "," << tt.pos.z << " to "<< tt.pos.x << "," << tt.pos.y << "," << tt.pos.z+1 << "lw 3\n";
|
||||
//plot.gp << "set arrow 919 from " << tt.pos.x << "," << tt.pos.y << "," << tt.pos.z << " to "<< tt.pos.x << "," << tt.pos.y << "," << tt.pos.z+1 << "lw 3\n";
|
||||
|
||||
//Walking with smartphone straight and always parallel to motion axis
|
||||
std::string filename = getDataFile("motion/straight_potrait.csv");
|
||||
//Walking with smartphone straight and always parallel to motion axis
|
||||
std::string filename = getDataFile("motion/straight_potrait.csv");
|
||||
|
||||
//straight_landscape_left/right: walking ~40 sec straight and changing every 5 seconds the mode. started with potrait. landscape routed either to left or right.
|
||||
//std::string filename = getDataFile("motion/straight_landscape_left.csv");
|
||||
//std::string filename = getDataFile("motion/straight_landscape_right.csv");
|
||||
//straight_landscape_left/right: walking ~40 sec straight and changing every 5 seconds the mode. started with potrait. landscape routed either to left or right.
|
||||
//std::string filename = getDataFile("motion/straight_landscape_left.csv");
|
||||
//std::string filename = getDataFile("motion/straight_landscape_right.csv");
|
||||
|
||||
//straight_inturn_landscape: walked straight made a left turn and change the phone to landscape mode during the turn-phase
|
||||
//std::string filename = getDataFile("motion/straight_inturn_landscape.csv");
|
||||
//straight_inturn_landscape: walked straight made a left turn and change the phone to landscape mode during the turn-phase
|
||||
//std::string filename = getDataFile("motion/straight_inturn_landscape.csv");
|
||||
|
||||
//rounds_potrait: walked 3 rounds holding the phone in potrait mode. always making left turns.
|
||||
//std::string filename = getDataFile("motion/rounds_potrait.csv");
|
||||
//rounds_potrait: walked 3 rounds holding the phone in potrait mode. always making left turns.
|
||||
//std::string filename = getDataFile("motion/rounds_potrait.csv");
|
||||
|
||||
//round_landscape: walked 3 rounds holding the phone in landscape mode. always making left turns.
|
||||
//std::string filename = getDataFile("motion/rounds_landscape.csv");
|
||||
//round_landscape: walked 3 rounds holding the phone in landscape mode. always making left turns.
|
||||
//std::string filename = getDataFile("motion/rounds_landscape.csv");
|
||||
|
||||
//round potrait_to_landscape: walked 1 round with potrait, 1 with landscape and again potrait. the mode was change while walking straight not in a turn. always making left turns.
|
||||
//std::string filename = getDataFile("motion/rounds_potrait_to_landscape.csv");
|
||||
//round potrait_to_landscape: walked 1 round with potrait, 1 with landscape and again potrait. the mode was change while walking straight not in a turn. always making left turns.
|
||||
//std::string filename = getDataFile("motion/rounds_potrait_to_landscape.csv");
|
||||
|
||||
//rounds_pocket: had the phone in my jeans pocket screen pointed at my body and the phone was headfirst. pulled it shortly out after 2 rounds and rotated the phone 180° z-wise (screen not showing at me)
|
||||
//std::string filename = getDataFile("motion/rounds_pocket.csv");
|
||||
//rounds_pocket: had the phone in my jeans pocket screen pointed at my body and the phone was headfirst. pulled it shortly out after 2 rounds and rotated the phone 180° z-wise (screen not showing at me)
|
||||
//std::string filename = getDataFile("motion/rounds_pocket.csv");
|
||||
|
||||
//table_flat: phone was flat on the table and moved slowly forward/backward for 60 cm.
|
||||
//std::string filename = getDataFile("motion/table_flat.csv");
|
||||
//table_flat: phone was flat on the table and moved slowly forward/backward for 60 cm.
|
||||
//std::string filename = getDataFile("motion/table_flat.csv");
|
||||
|
||||
Offline::FileReader fr(filename);
|
||||
Timestamp ts;
|
||||
Timestamp ts;
|
||||
|
||||
//save for later plotting
|
||||
std::vector<float> delta_motionAngles;
|
||||
std::vector<float> delta_turnAngles;
|
||||
//save for later plotting
|
||||
std::vector<float> delta_motionAngles;
|
||||
std::vector<float> delta_turnAngles;
|
||||
|
||||
//calc motion axis
|
||||
//calc motion axis
|
||||
for (const Offline::Entry& e : fr.getEntries()) {
|
||||
|
||||
ts = Timestamp::fromMS(e.ts);
|
||||
ts = Timestamp::fromMS(e.ts);
|
||||
|
||||
if (e.type == Offline::Sensor::LIN_ACC) {
|
||||
md.addLinearAcceleration(ts, fr.getLinearAcceleration()[e.idx].data);
|
||||
md.addLinearAcceleration(ts, fr.getLinearAcceleration()[e.idx].data);
|
||||
|
||||
} else if (e.type == Offline::Sensor::GRAVITY) {
|
||||
md.addGravity(ts, fr.getGravity()[e.idx].data);
|
||||
delta_motionAngles.push_back(md.getMotionChangeInRad());
|
||||
md.addGravity(ts, fr.getGravity()[e.idx].data);
|
||||
delta_motionAngles.push_back(md.getMotionChangeInRad());
|
||||
|
||||
} else if (e.type == Offline::Sensor::ACC) {
|
||||
const Offline::TS<AccelerometerData>& _acc = fr.getAccelerometer()[e.idx];
|
||||
pd.addAccelerometer(ts, _acc.data);
|
||||
td.addAccelerometer(ts, _acc.data);
|
||||
|
||||
} else if (e.type == Offline::Sensor::GYRO) {
|
||||
const Offline::TS<GyroscopeData>& _gyr = fr.getGyroscope()[e.idx];
|
||||
delta_turnAngles.push_back(td.addGyroscope(ts, _gyr.data));
|
||||
}
|
||||
delta_turnAngles.push_back(td.addGyroscope(ts, _gyr.data));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//draw motion
|
||||
static K::Gnuplot gpMotion;
|
||||
K::GnuplotPlot plotMotion;
|
||||
K::GnuplotPlotElementLines motionLines;
|
||||
//draw motion
|
||||
static K::Gnuplot gpMotion;
|
||||
K::GnuplotPlot plotMotion;
|
||||
K::GnuplotPlotElementLines motionLines;
|
||||
|
||||
for(int i = 0; i < delta_motionAngles.size() - 1; ++i){
|
||||
for(int i = 0; i < delta_motionAngles.size() - 1; ++i){
|
||||
|
||||
K::GnuplotPoint2 raw_p1(i, delta_motionAngles[i]);
|
||||
K::GnuplotPoint2 raw_p2(i + 1, delta_motionAngles[i+1]);
|
||||
motionLines.addSegment(raw_p1, raw_p2);
|
||||
K::GnuplotPoint2 raw_p1(i, delta_motionAngles[i]);
|
||||
K::GnuplotPoint2 raw_p2(i + 1, delta_motionAngles[i+1]);
|
||||
motionLines.addSegment(raw_p1, raw_p2);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
gpMotion << "set title 'Motion Detection'\n";
|
||||
plotMotion.add(&motionLines);
|
||||
gpMotion.draw(plotMotion);
|
||||
gpMotion.flush();
|
||||
gpMotion << "set title 'Motion Detection'\n";
|
||||
plotMotion.add(&motionLines);
|
||||
gpMotion.draw(plotMotion);
|
||||
gpMotion.flush();
|
||||
|
||||
|
||||
//draw rotation
|
||||
static K::Gnuplot gpTurn;
|
||||
K::GnuplotPlot plotTurn;
|
||||
K::GnuplotPlotElementLines turnLines;
|
||||
//draw rotation
|
||||
static K::Gnuplot gpTurn;
|
||||
K::GnuplotPlot plotTurn;
|
||||
K::GnuplotPlotElementLines turnLines;
|
||||
|
||||
for(int i = 0; i < delta_turnAngles.size() - 1; ++i){
|
||||
for(int i = 0; i < delta_turnAngles.size() - 1; ++i){
|
||||
|
||||
K::GnuplotPoint2 raw_p1(i, delta_turnAngles[i]);
|
||||
K::GnuplotPoint2 raw_p2(i + 1, delta_turnAngles[i+1]);
|
||||
turnLines.addSegment(raw_p1, raw_p2);
|
||||
}
|
||||
K::GnuplotPoint2 raw_p1(i, delta_turnAngles[i]);
|
||||
K::GnuplotPoint2 raw_p2(i + 1, delta_turnAngles[i+1]);
|
||||
turnLines.addSegment(raw_p1, raw_p2);
|
||||
}
|
||||
|
||||
gpTurn << "set title 'Turn Detection'\n";
|
||||
plotTurn.add(&turnLines);
|
||||
gpTurn.draw(plotTurn);
|
||||
gpTurn.flush();
|
||||
gpTurn << "set title 'Turn Detection'\n";
|
||||
plotTurn.add(&turnLines);
|
||||
gpTurn.draw(plotTurn);
|
||||
gpTurn.flush();
|
||||
|
||||
sleep(1);
|
||||
sleep(1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -6,34 +6,33 @@
|
||||
|
||||
TEST(TurnDetection, rotationMatrix) {
|
||||
|
||||
Vector3 dst(0, 0, 1);
|
||||
Vector3 src(1, 1, 0);
|
||||
src = src.normalized();
|
||||
Vector3 dst(0, 0, 1);
|
||||
Vector3 src(1, 1, 0); src = src.normalized();
|
||||
|
||||
// get a matrix that rotates "src" into "dst"
|
||||
Matrix3 rot = PoseDetection::getRotationMatrix(src, dst);
|
||||
Matrix3 rot = PoseDetection::getRotationMatrix(src, dst);
|
||||
|
||||
Vector3 res = rot * src;
|
||||
Vector3 res = rot * src;
|
||||
|
||||
ASSERT_NEAR(dst.x, res.x, 0.01);
|
||||
ASSERT_NEAR(dst.y, res.y, 0.01);
|
||||
ASSERT_NEAR(dst.z, res.z, 0.01);
|
||||
ASSERT_NEAR(dst.x, res.x, 0.01);
|
||||
ASSERT_NEAR(dst.y, res.y, 0.01);
|
||||
ASSERT_NEAR(dst.z, res.z, 0.01);
|
||||
|
||||
}
|
||||
|
||||
TEST(TurnDetection, gyroRotate) {
|
||||
|
||||
|
||||
Vector3 zAxis(0, 0, 1);
|
||||
Vector3 acc(0, 7.0, 7.0);
|
||||
Vector3 zAxis(0, 0, 1);
|
||||
Vector3 acc(0, 7.0, 7.0);
|
||||
|
||||
Matrix3 rot = PoseDetection::getRotationMatrix(acc, zAxis);
|
||||
Matrix3 rot = PoseDetection::getRotationMatrix(acc, zAxis);
|
||||
|
||||
Vector3 gyro(0, 60, 60);
|
||||
Vector3 gyro(0, 60, 60);
|
||||
|
||||
Vector3 gyro2(0, 0, 84);
|
||||
Vector3 gyro2(0, 0, 84);
|
||||
|
||||
Vector3 gyro3 = rot * gyro;
|
||||
Vector3 gyro3 = rot * gyro;
|
||||
|
||||
ASSERT_NEAR(0, (gyro2-gyro3).norm(), 1.0);
|
||||
|
||||
@@ -42,11 +41,10 @@ TEST(TurnDetection, gyroRotate) {
|
||||
|
||||
TEST(TurnDetection, xx) {
|
||||
|
||||
Vector3 dst(0, 0, 1);
|
||||
Vector3 src(0.0, 2.9, -10.0);
|
||||
src = src.normalized(); // sample accelerometer readings
|
||||
Vector3 dst(0, 0, 1);
|
||||
Vector3 src(0.0, 2.9, -10.0); src = src.normalized(); // sample accelerometer readings
|
||||
|
||||
Matrix3 rot = PoseDetection::getRotationMatrix(src, dst);
|
||||
Matrix3 rot = PoseDetection::getRotationMatrix(src, dst);
|
||||
|
||||
// Eigen::Vector3f x; x << 1, 0, 0;
|
||||
// Eigen::Vector3f z = src.normalized();
|
||||
@@ -57,14 +55,14 @@ TEST(TurnDetection, xx) {
|
||||
// rot.row(1) = y;
|
||||
// rot.row(2) = z;
|
||||
|
||||
Vector3 res = rot * src;
|
||||
Vector3 res = rot * src;
|
||||
// ASSERT_NEAR(dst(0), res(0), 0.01);
|
||||
// ASSERT_NEAR(dst(1), res(1), 0.01);
|
||||
// ASSERT_NEAR(dst(2), res(2), 0.01);
|
||||
|
||||
Vector3 gyro(0, 10, 30);
|
||||
Vector3 gyro(0, 10, 30);
|
||||
|
||||
Vector3 gyro2 = rot * gyro;
|
||||
Vector3 gyro2 = rot * gyro;
|
||||
int i = 0; (void) i;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#ifdef WITH_TESTS
|
||||
#ifdef TODO_______WITH_TESTS
|
||||
|
||||
#include "../../Tests.h"
|
||||
|
||||
@@ -115,7 +115,7 @@ TEST(Barometer, LIVE_tendence2) {
|
||||
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
sleep(1);
|
||||
|
||||
|
||||
// tendence must be clear and smaller than the sigma
|
||||
@@ -124,120 +124,119 @@ TEST(Barometer, LIVE_tendence2) {
|
||||
}
|
||||
|
||||
TEST(Barometer, Activity) {
|
||||
ActivityButterPressure act;
|
||||
ActivityButterPressure act;
|
||||
|
||||
//read file
|
||||
std::string line;
|
||||
//read file
|
||||
std::string line;
|
||||
std::string filename = getDataFile("barometer/baro1.dat");
|
||||
std::ifstream infile(filename);
|
||||
std::ifstream infile(filename);
|
||||
|
||||
std::vector<ActivityButterPressure::History> actHist;
|
||||
std::vector<ActivityButterPressure::History> rawHist;
|
||||
std::vector<ActivityButterPressure::History> actHist;
|
||||
std::vector<ActivityButterPressure::History> rawHist;
|
||||
|
||||
while (std::getline(infile, line))
|
||||
{
|
||||
std::istringstream iss(line);
|
||||
int ts;
|
||||
double value;
|
||||
while (std::getline(infile, line))
|
||||
{
|
||||
std::istringstream iss(line);
|
||||
int ts;
|
||||
double value;
|
||||
|
||||
while (iss >> ts >> value) {
|
||||
act.add(Timestamp::fromMS(ts), BarometerData(value));
|
||||
Activity currentAct = act.get();
|
||||
rawHist.push_back(ActivityButterPressure::History(Timestamp::fromMS(ts), BarometerData(value)));
|
||||
actHist.push_back(ActivityButterPressure::History(Timestamp::fromMS(ts), BarometerData((int)currentAct)));
|
||||
}
|
||||
}
|
||||
while (iss >> ts >> value) {
|
||||
ActivityButterPressure::Activity currentAct = act.add(Timestamp::fromMS(ts), BarometerData(value));
|
||||
rawHist.push_back(ActivityButterPressure::History(Timestamp::fromMS(ts), BarometerData(value)));
|
||||
actHist.push_back(ActivityButterPressure::History(Timestamp::fromMS(ts), BarometerData(currentAct)));
|
||||
}
|
||||
}
|
||||
|
||||
K::Gnuplot gp;
|
||||
K::Gnuplot gpRaw;
|
||||
K::GnuplotPlot plot;
|
||||
K::GnuplotPlot plotRaw;
|
||||
K::GnuplotPlotElementLines rawLines;
|
||||
K::GnuplotPlotElementLines resultLines;
|
||||
K::Gnuplot gp;
|
||||
K::Gnuplot gpRaw;
|
||||
K::GnuplotPlot plot;
|
||||
K::GnuplotPlot plotRaw;
|
||||
K::GnuplotPlotElementLines rawLines;
|
||||
K::GnuplotPlotElementLines resultLines;
|
||||
|
||||
for(int i=0; i < actHist.size()-1; ++i){
|
||||
for(int i=0; i < actHist.size()-1; ++i){
|
||||
|
||||
//raw
|
||||
K::GnuplotPoint2 raw_p1(rawHist[i].ts.sec(), rawHist[i].data.hPa);
|
||||
K::GnuplotPoint2 raw_p2(rawHist[i+1].ts.sec(), rawHist[i+1].data.hPa);
|
||||
//raw
|
||||
K::GnuplotPoint2 raw_p1(rawHist[i].ts.sec(), rawHist[i].data.hPa);
|
||||
K::GnuplotPoint2 raw_p2(rawHist[i+1].ts.sec(), rawHist[i+1].data.hPa);
|
||||
|
||||
rawLines.addSegment(raw_p1, raw_p2);
|
||||
rawLines.addSegment(raw_p1, raw_p2);
|
||||
|
||||
//results
|
||||
K::GnuplotPoint2 input_p1(actHist[i].ts.sec(), actHist[i].data.hPa);
|
||||
K::GnuplotPoint2 input_p2(actHist[i+1].ts.sec(), actHist[i+1].data.hPa);
|
||||
//results
|
||||
K::GnuplotPoint2 input_p1(actHist[i].ts.sec(), actHist[i].data.hPa);
|
||||
K::GnuplotPoint2 input_p2(actHist[i+1].ts.sec(), actHist[i+1].data.hPa);
|
||||
|
||||
resultLines.addSegment(input_p1, input_p2);
|
||||
}
|
||||
resultLines.addSegment(input_p1, input_p2);
|
||||
}
|
||||
|
||||
plotRaw.add(&rawLines);
|
||||
plot.add(&resultLines);
|
||||
plotRaw.add(&rawLines);
|
||||
plot.add(&resultLines);
|
||||
|
||||
gp.draw(plot);
|
||||
gp.flush();
|
||||
gp.draw(plot);
|
||||
gp.flush();
|
||||
|
||||
gpRaw.draw(plotRaw);
|
||||
gpRaw.flush();
|
||||
gpRaw.draw(plotRaw);
|
||||
gpRaw.flush();
|
||||
|
||||
sleep(5);
|
||||
sleep(5);
|
||||
|
||||
}
|
||||
|
||||
TEST(Barometer, ActivityPercent) {
|
||||
|
||||
ActivityButterPressurePercent act;
|
||||
ActivityButterPressurePercent act;
|
||||
|
||||
//read file
|
||||
std::string line;
|
||||
std::string filename = getDataFile("barometer/baro1.dat");
|
||||
std::ifstream infile(filename);
|
||||
//read file
|
||||
std::string line;
|
||||
std::string filename = getDataFile("barometer/baro1.dat");
|
||||
std::ifstream infile(filename);
|
||||
|
||||
std::vector<ActivityButterPressurePercent::ActivityProbabilities> actHist;
|
||||
std::vector<double> rawHist;
|
||||
std::vector<ActivityButterPressurePercent::ActivityProbabilities> actHist;
|
||||
std::vector<double> rawHist;
|
||||
|
||||
while (std::getline(infile, line))
|
||||
{
|
||||
std::istringstream iss(line);
|
||||
int ts;
|
||||
double value;
|
||||
while (std::getline(infile, line))
|
||||
{
|
||||
std::istringstream iss(line);
|
||||
int ts;
|
||||
double value;
|
||||
|
||||
while (iss >> ts >> value) {
|
||||
ActivityButterPressurePercent::ActivityProbabilities activity = act.add(Timestamp::fromMS(ts), BarometerData(value));
|
||||
rawHist.push_back(value);
|
||||
actHist.push_back(activity);
|
||||
}
|
||||
}
|
||||
while (iss >> ts >> value) {
|
||||
ActivityButterPressurePercent::ActivityProbabilities activity = act.add(Timestamp::fromMS(ts), BarometerData(value));
|
||||
rawHist.push_back(value);
|
||||
actHist.push_back(activity);
|
||||
}
|
||||
}
|
||||
|
||||
K::Gnuplot gp;
|
||||
K::Gnuplot gpRaw;
|
||||
K::GnuplotPlot plot;
|
||||
K::GnuplotPlot plotRaw;
|
||||
K::GnuplotPlotElementLines rawLines;
|
||||
K::GnuplotPlotElementLines resultLines;
|
||||
K::Gnuplot gp;
|
||||
K::Gnuplot gpRaw;
|
||||
K::GnuplotPlot plot;
|
||||
K::GnuplotPlot plotRaw;
|
||||
K::GnuplotPlotElementLines rawLines;
|
||||
K::GnuplotPlotElementLines resultLines;
|
||||
|
||||
for(int i=0; i < actHist.size()-1; ++i){
|
||||
for(int i=0; i < actHist.size()-1; ++i){
|
||||
|
||||
K::GnuplotPoint2 raw_p1(i, rawHist[i]);
|
||||
K::GnuplotPoint2 raw_p2(i+1, rawHist[i+1]);
|
||||
K::GnuplotPoint2 raw_p1(i, rawHist[i]);
|
||||
K::GnuplotPoint2 raw_p2(i+1, rawHist[i+1]);
|
||||
|
||||
rawLines.addSegment(raw_p1, raw_p2);
|
||||
rawLines.addSegment(raw_p1, raw_p2);
|
||||
|
||||
K::GnuplotPoint2 input_p1(i, actHist[i].elevatorDown);
|
||||
K::GnuplotPoint2 input_p2(i+1, actHist[i+1].elevatorDown);
|
||||
K::GnuplotPoint2 input_p1(i, actHist[i].elevatorDown);
|
||||
K::GnuplotPoint2 input_p2(i+1, actHist[i+1].elevatorDown);
|
||||
|
||||
resultLines.addSegment(input_p1, input_p2);
|
||||
}
|
||||
resultLines.addSegment(input_p1, input_p2);
|
||||
}
|
||||
|
||||
plotRaw.add(&rawLines);
|
||||
plot.add(&resultLines);
|
||||
plotRaw.add(&rawLines);
|
||||
plot.add(&resultLines);
|
||||
|
||||
gp.draw(plot);
|
||||
gp.flush();
|
||||
gp.draw(plot);
|
||||
gp.flush();
|
||||
|
||||
gpRaw.draw(plotRaw);
|
||||
gpRaw.flush();
|
||||
gpRaw.draw(plotRaw);
|
||||
gpRaw.flush();
|
||||
|
||||
sleep(5);
|
||||
sleep(5);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user