forked from matthew-t-watson/Picopter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogger.cpp
More file actions
81 lines (74 loc) · 1.93 KB
/
Logger.cpp
File metadata and controls
81 lines (74 loc) · 1.93 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* File: Logger.cpp
* Author: matt
*
* Created on 01 November 2012, 22:49
*/
#include "Logger.h"
#include "Timer.h"
#include "AHRS.h"
#include "PICInterface.h"
#include "Control.h"
LoggerClass LogMan;
std::fstream Log;
LoggerClass::LoggerClass()
{
logging = false;
sampleno = 0;
}
LoggerClass::LoggerClass(const LoggerClass& orig)
{
}
LoggerClass::~LoggerClass()
{
Log.close();
}
void LoggerClass::open(const char* filename)
{
Log.open(filename, std::fstream::out);
Log.rdbuf()->pubsetbuf(0, 0); //No buffer
logging = true;
}
void LoggerClass::update()
{
sampleno++;
if (logging)
{
Log << sampleno << ", "
<< Timer.dt * 1000 << ", "
<< AHRS.calibratedData.x << ", "
<< AHRS.calibratedData.y << ", "
<< AHRS.calibratedData.z << ", "
<< AHRS.calibratedData.p << ", "
<< AHRS.calibratedData.q << ", "
<< AHRS.calibratedData.r << ", "
<< AHRS.calibratedData.temp << ", "
<< AHRS.calibratedData.magx << ", "
<< AHRS.calibratedData.magy << ", "
<< AHRS.calibratedData.magz << ", "
<< AHRS.calibratedData.pressure << ", "
<< AHRS.calibratedData.altitude << ", "
<< AHRS.accelAngles.phi << ", "
<< AHRS.accelAngles.psi << ", "
<< AHRS.orientation.phi << ", "
<< AHRS.orientation.psi << ", "
<< AHRS.orientation.theta << ", "
<< PICInterface.rx.pitch << ", "
<< PICInterface.rx.pitchrate << ", "
<< PICInterface.rx.roll << ", "
<< PICInterface.rx.rollrate << ", "
<< PICInterface.rx.throttle << ", "
<< PICInterface.rx.yawrate << ", "
<< PICInterface.pwmwidths.frontleft << ", "
<< PICInterface.pwmwidths.frontright << ", "
<< PICInterface.pwmwidths.rearleft << ", "
<< PICInterface.pwmwidths.rearright << ", "
<< Control.ratePitchPID.output << ", "
<< Control.rateRollPID.output << ", "
<< Control.rateYawPID.output << ", "
<< Control.attitudePitchPID.output << ", "
<< Control.attitudeRollPID.output << ", "
// //Add additional logs below
<< std::endl;
}
}