summaryrefslogtreecommitdiffhomepage
path: root/logic/tracklogger.cpp
blob: a287b6330261de8b02611566a92ce151ccb267f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "tracklogger.hpp"
#include "pipeline.hpp"

#include <QMessageBox>

void TrackLogger::write_pose(const double* p)
{
    write(p, 6);
}

void TrackLogger::reset_dt()
{
    t.start();
}

void TrackLogger::write_dt()
{
    const double dt = t.elapsed_seconds();
    write(&dt, 1);
}

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)
{
    handle_first_col_sep();
    for (int i = 0; i < n-1; ++i)
    {
        out << p[i];
        out.put(',');
    }
    out << p[n-1];
}

void TrackLoggerCSV::next_line()
{
    out << std::endl;
    first_col = true;
}