diff options
author | DaMichel <mw.pub@welter-4d.de> | 2016-07-29 11:36:21 +0200 |
---|---|---|
committer | DaMichel <mw.pub@welter-4d.de> | 2016-07-29 11:40:21 +0200 |
commit | 884b3f013045d60d586c55338a76feb4dfa30c9b (patch) | |
tree | 4ddfd6a4aa827d75be86afb1792b2375e491bc4b /opentrack-logic | |
parent | 7b3be452b6be528de753a1a633a3aacdb11be86c (diff) |
track logging: why not write proper csv with COMMA separated lists! Also write proper header.
Diffstat (limited to 'opentrack-logic')
-rw-r--r-- | opentrack-logic/tracker.cpp | 27 | ||||
-rw-r--r-- | opentrack-logic/tracklogger.cpp | 15 | ||||
-rw-r--r-- | opentrack-logic/tracklogger.hpp | 1 |
3 files changed, 30 insertions, 13 deletions
diff --git a/opentrack-logic/tracker.cpp b/opentrack-logic/tracker.cpp index 8101932c..f29e3100 100644 --- a/opentrack-logic/tracker.cpp +++ b/opentrack-logic/tracker.cpp @@ -135,7 +135,7 @@ void Tracker::logic() raw(i) = newpose[i]; } - logger.write_pose(raw); // raw tracker input + logger.write_pose(raw); // raw if (is_nan(raw)) raw = last_raw; @@ -210,13 +210,13 @@ void Tracker::logic() } } - logger.write_pose(value); // after various transformations to account for camera position + logger.write_pose(value); // "corrected" - after various transformations to account for camera position // whenever something can corrupt its internal state due to nan/inf, elide the call if (is_nan(value)) { nan = true; - logger.write_pose(value); // for consistency with filtered value + logger.write_pose(value); // "filtered" } else { @@ -224,11 +224,9 @@ void Tracker::logic() Pose tmp = value; if (libs.pFilter) - { libs.pFilter->filter(tmp, value); - } } - logger.write_pose(value); // filtered value if filter present + logger.write_pose(value); // "filtered" // CAVEAT rotation only, due to tcomp for (int i = 3; i < 6; i++) @@ -265,7 +263,7 @@ void Tracker::logic() for (int i = 0; i < 3; i++) value(i) = map(value(i), m(i)); - logger.write_pose(value); // after mapping + logger.write_pose(value); // "mapped" if (nan) { @@ -296,7 +294,20 @@ void Tracker::run() (void) timeBeginPeriod(1); #endif - logger.write("//dt;raw;before filter;after filter;after mapping; every pose has channels TX, TY, TZ, Yaw, Pitch, Roll"); + { + const char* posechannels[6] = { "TX", "TY", "TZ", "Yaw", "Pitch", "Roll" }; + const char* datachannels[5] = { "dt", "raw", "corrected", "filtered", "mapped" }; + logger.write(datachannels[0]); + char buffer[128]; + for (int j = 1; j < 5; ++j) + { + for (int i = 0; i < 6; ++i) + { + snprintf(buffer, 128, "%s%s", datachannels[j], posechannels[i]); + logger.write(buffer); + } + } + } logger.next_line(); while (!should_quit) diff --git a/opentrack-logic/tracklogger.cpp b/opentrack-logic/tracklogger.cpp index 5e4cf4f9..f007c2bc 100644 --- a/opentrack-logic/tracklogger.cpp +++ b/opentrack-logic/tracklogger.cpp @@ -1,22 +1,27 @@ #include "tracklogger.hpp" #include "tracker.h" - + +void TrackLoggerCSV::handle_first_col_sep() +{ + if (!first_col) + out.put(','); + first_col = false; +} void TrackLoggerCSV::write(const char *s) { + handle_first_col_sep(); out << s; } void TrackLoggerCSV::write(const double *p, int n) { - if (!first_col) - out.put(';'); - first_col = false; + handle_first_col_sep(); for (int i = 0; i < n-1; ++i) { out << p[i]; - out.put(';'); + out.put(','); } out << p[n-1]; } diff --git a/opentrack-logic/tracklogger.hpp b/opentrack-logic/tracklogger.hpp index feed7fa2..99bc71b0 100644 --- a/opentrack-logic/tracklogger.hpp +++ b/opentrack-logic/tracklogger.hpp @@ -39,6 +39,7 @@ class OPENTRACK_LOGIC_EXPORT TrackLoggerCSV : public TrackLogger { std::ofstream out; bool first_col; + inline void handle_first_col_sep(); public: TrackLoggerCSV(const QString &filename) : TrackLogger(), first_col(true) |