mirror of
https://github.com/okalachev/flix.git
synced 2026-06-28 05:56:44 +00:00
Use double for storing time instead of float
Float precision may be not enough after some time of operating
This commit is contained in:
+4
-2
@@ -10,6 +10,7 @@
|
||||
#define LOG_PERIOD 1.0 / LOG_RATE
|
||||
#define LOG_SIZE LOG_DURATION * LOG_RATE
|
||||
|
||||
float tFloat;
|
||||
Vector attitudeEuler;
|
||||
Vector attitudeTargetEuler;
|
||||
|
||||
@@ -19,7 +20,7 @@ struct LogEntry {
|
||||
};
|
||||
|
||||
LogEntry logEntries[] = {
|
||||
{"t", &t},
|
||||
{"t", &tFloat},
|
||||
{"rates.x", &rates.x},
|
||||
{"rates.y", &rates.y},
|
||||
{"rates.z", &rates.z},
|
||||
@@ -39,6 +40,7 @@ const int logColumns = sizeof(logEntries) / sizeof(logEntries[0]);
|
||||
float logBuffer[LOG_SIZE][logColumns];
|
||||
|
||||
void prepareLogData() {
|
||||
tFloat = t;
|
||||
attitudeEuler = attitude.toEulerZYX();
|
||||
attitudeTargetEuler = attitudeTarget.toEulerZYX();
|
||||
}
|
||||
@@ -46,7 +48,7 @@ void prepareLogData() {
|
||||
void logData() {
|
||||
if (!armed) return;
|
||||
static int logPointer = 0;
|
||||
static float logTime = 0;
|
||||
static double logTime = 0;
|
||||
if (t - logTime < LOG_PERIOD) return;
|
||||
logTime = t;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user