cleaner calculation of mgm rate
This commit is contained in:
parent
78f4bbc3a7
commit
5a7f0d08a4
@ -6,11 +6,11 @@
|
|||||||
#include <fsfw/globalfunctions/math/QuaternionOperations.h>
|
#include <fsfw/globalfunctions/math/QuaternionOperations.h>
|
||||||
#include <fsfw/globalfunctions/math/VectorOperations.h>
|
#include <fsfw/globalfunctions/math/VectorOperations.h>
|
||||||
#include <fsfw/globalfunctions/timevalOperations.h>
|
#include <fsfw/globalfunctions/timevalOperations.h>
|
||||||
#include <math.h>
|
#include <mission/controller/acs/Igrf13Model.h>
|
||||||
|
#include <mission/controller/acs/util/MathOperations.h>
|
||||||
|
#include <mission/controller/controllerdefinitions/AcsCtrlDefinitions.h>
|
||||||
|
|
||||||
#include "../controllerdefinitions/AcsCtrlDefinitions.h"
|
#include <cmath>
|
||||||
#include "Igrf13Model.h"
|
|
||||||
#include "util/MathOperations.h"
|
|
||||||
|
|
||||||
using namespace Math;
|
using namespace Math;
|
||||||
|
|
||||||
@ -54,6 +54,7 @@ void SensorProcessing::processMgm(const float *mgm0Value, bool mgm0valid, const
|
|||||||
mgmDataProcessed->magIgrfModel.setValid(gpsValid);
|
mgmDataProcessed->magIgrfModel.setValid(gpsValid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
std::memcpy(savedMgmVecTot, ZERO_VEC_D, sizeof(savedMgmVecTot));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
float mgm0ValueNoBias[3] = {0, 0, 0}, mgm1ValueNoBias[3] = {0, 0, 0},
|
float mgm0ValueNoBias[3] = {0, 0, 0}, mgm1ValueNoBias[3] = {0, 0, 0},
|
||||||
@ -141,14 +142,16 @@ void SensorProcessing::processMgm(const float *mgm0Value, bool mgm0valid, const
|
|||||||
double mgmVecTotDerivative[3] = {0.0, 0.0, 0.0};
|
double mgmVecTotDerivative[3] = {0.0, 0.0, 0.0};
|
||||||
bool mgmVecTotDerivativeValid = false;
|
bool mgmVecTotDerivativeValid = false;
|
||||||
double timeDiff = timevalOperations::toDouble(timeOfMgmMeasurement - timeOfSavedMagFieldEst);
|
double timeDiff = timevalOperations::toDouble(timeOfMgmMeasurement - timeOfSavedMagFieldEst);
|
||||||
if (timeOfSavedMagFieldEst.tv_sec != 0 and timeDiff > 0) {
|
sif::debug << "timeDiff = " << timeDiff << std::endl;
|
||||||
for (uint8_t i = 0; i < 3; i++) {
|
sif::debug << "tv_sec = " << (double)timeOfSavedMagFieldEst.tv_sec << std::endl;
|
||||||
mgmVecTotDerivative[i] = (mgmVecTot[i] - savedMgmVecTot[i]) / timeDiff;
|
if (timeOfSavedMagFieldEst.tv_sec != 0 and timeDiff > 0 and
|
||||||
savedMgmVecTot[i] = mgmVecTot[i];
|
VectorOperations<double>::norm(savedMgmVecTot, 3) != 0) {
|
||||||
|
VectorOperations<double>::subtract(mgmVecTot, savedMgmVecTot, mgmVecTotDerivative, 3);
|
||||||
|
VectorOperations<double>::mulScalar(mgmVecTotDerivative, 1. / timeDiff, mgmVecTotDerivative, 3);
|
||||||
mgmVecTotDerivativeValid = true;
|
mgmVecTotDerivativeValid = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
timeOfSavedMagFieldEst = timeOfMgmMeasurement;
|
timeOfSavedMagFieldEst = timeOfMgmMeasurement;
|
||||||
|
std::memcpy(savedMgmVecTot, mgmVecTot, sizeof(savedMgmVecTot));
|
||||||
|
|
||||||
if (VectorOperations<double>::norm(mgmVecTotDerivative, 3) != 0 and
|
if (VectorOperations<double>::norm(mgmVecTotDerivative, 3) != 0 and
|
||||||
mgmDataProcessed->mgmVecTotDerivative.isValid()) {
|
mgmDataProcessed->mgmVecTotDerivative.isValid()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user