From 7e25f5012e81930d94a69ada71f324bc449b316c Mon Sep 17 00:00:00 2001 From: Marius Eggert Date: Thu, 26 Jan 2023 17:09:34 +0100 Subject: [PATCH 01/29] transformation before calibration --- mission/controller/acs/SensorProcessing.cpp | 67 +++++++++++---------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/mission/controller/acs/SensorProcessing.cpp b/mission/controller/acs/SensorProcessing.cpp index ac2e5752..a8fd1576 100644 --- a/mission/controller/acs/SensorProcessing.cpp +++ b/mission/controller/acs/SensorProcessing.cpp @@ -47,71 +47,72 @@ void SensorProcessing::processMgm(const float *mgm0Value, bool mgm0valid, const float mgm0ValueNoBias[3] = {0, 0, 0}, mgm1ValueNoBias[3] = {0, 0, 0}, mgm2ValueNoBias[3] = {0, 0, 0}, mgm3ValueNoBias[3] = {0, 0, 0}, mgm4ValueNoBias[3] = {0, 0, 0}; - float mgm0ValueCalib[3] = {0, 0, 0}, mgm1ValueCalib[3] = {0, 0, 0}, mgm2ValueCalib[3] = {0, 0, 0}, - mgm3ValueCalib[3] = {0, 0, 0}, mgm4ValueCalib[3] = {0, 0, 0}; float mgm0ValueBody[3] = {0, 0, 0}, mgm1ValueBody[3] = {0, 0, 0}, mgm2ValueBody[3] = {0, 0, 0}, mgm3ValueBody[3] = {0, 0, 0}, mgm4ValueBody[3] = {0, 0, 0}; + float mgm0ValueCalib[3] = {0, 0, 0}, mgm1ValueCalib[3] = {0, 0, 0}, mgm2ValueCalib[3] = {0, 0, 0}, + mgm3ValueCalib[3] = {0, 0, 0}, mgm4ValueCalib[3] = {0, 0, 0}; float sensorFusionNumerator[3] = {0, 0, 0}, sensorFusionDenominator[3] = {0, 0, 0}; if (mgm0valid) { - VectorOperations::subtract(mgm0Value, mgmParameters->mgm0hardIronOffset, mgm0ValueNoBias, - 3); + MatrixOperations::multiply(mgmParameters->mgm0orientationMatrix[0], mgm0Value, + mgm0ValueBody, 3, 3, 1); + VectorOperations::subtract(mgm0ValueBody, mgmParameters->mgm0hardIronOffset, + mgm0ValueNoBias, 3); MatrixOperations::multiply(mgmParameters->mgm0softIronInverse[0], mgm0ValueNoBias, mgm0ValueCalib, 3, 3, 1); - MatrixOperations::multiply(mgmParameters->mgm0orientationMatrix[0], mgm0ValueCalib, - mgm0ValueBody, 3, 3, 1); for (uint8_t i = 0; i < 3; i++) { - sensorFusionNumerator[i] += mgm0ValueBody[i] / mgmParameters->mgm02variance[i]; + sensorFusionNumerator[i] += mgm0ValueCalib[i] / mgmParameters->mgm02variance[i]; sensorFusionDenominator[i] += 1 / mgmParameters->mgm02variance[i]; } } if (mgm1valid) { - VectorOperations::subtract(mgm1Value, mgmParameters->mgm1hardIronOffset, mgm1ValueNoBias, - 3); + MatrixOperations::multiply(mgmParameters->mgm1orientationMatrix[0], mgm1Value, + mgm1ValueBody, 3, 3, 1); + VectorOperations::subtract(mgm1ValueBody, mgmParameters->mgm1hardIronOffset, + mgm1ValueNoBias, 3); MatrixOperations::multiply(mgmParameters->mgm1softIronInverse[0], mgm1ValueNoBias, mgm1ValueCalib, 3, 3, 1); - MatrixOperations::multiply(mgmParameters->mgm1orientationMatrix[0], mgm1ValueCalib, - mgm1ValueBody, 3, 3, 1); for (uint8_t i = 0; i < 3; i++) { - sensorFusionNumerator[i] += mgm1ValueBody[i] / mgmParameters->mgm13variance[i]; + sensorFusionNumerator[i] += mgm1ValueCalib[i] / mgmParameters->mgm13variance[i]; sensorFusionDenominator[i] += 1 / mgmParameters->mgm13variance[i]; } } if (mgm2valid) { - VectorOperations::subtract(mgm2Value, mgmParameters->mgm2hardIronOffset, mgm2ValueNoBias, - 3); + MatrixOperations::multiply(mgmParameters->mgm2orientationMatrix[0], mgm2Value, + mgm2ValueBody, 3, 3, 1); + VectorOperations::subtract(mgm2ValueBody, mgmParameters->mgm2hardIronOffset, + mgm2ValueNoBias, 3); MatrixOperations::multiply(mgmParameters->mgm2softIronInverse[0], mgm2ValueNoBias, mgm2ValueCalib, 3, 3, 1); - MatrixOperations::multiply(mgmParameters->mgm2orientationMatrix[0], mgm2ValueCalib, - mgm2ValueBody, 3, 3, 1); for (uint8_t i = 0; i < 3; i++) { - sensorFusionNumerator[i] += mgm2ValueBody[i] / mgmParameters->mgm02variance[i]; + sensorFusionNumerator[i] += mgm2ValueCalib[i] / mgmParameters->mgm02variance[i]; sensorFusionDenominator[i] += 1 / mgmParameters->mgm02variance[i]; } } if (mgm3valid) { - VectorOperations::subtract(mgm3Value, mgmParameters->mgm3hardIronOffset, mgm3ValueNoBias, - 3); + MatrixOperations::multiply(mgmParameters->mgm3orientationMatrix[0], mgm3Value, + mgm3ValueBody, 3, 3, 1); + VectorOperations::subtract(mgm3ValueBody, mgmParameters->mgm3hardIronOffset, + mgm3ValueNoBias, 3); MatrixOperations::multiply(mgmParameters->mgm3softIronInverse[0], mgm3ValueNoBias, mgm3ValueCalib, 3, 3, 1); - MatrixOperations::multiply(mgmParameters->mgm3orientationMatrix[0], mgm3ValueCalib, - mgm3ValueBody, 3, 3, 1); for (uint8_t i = 0; i < 3; i++) { - sensorFusionNumerator[i] += mgm3ValueBody[i] / mgmParameters->mgm13variance[i]; + sensorFusionNumerator[i] += mgm3ValueCalib[i] / mgmParameters->mgm13variance[i]; sensorFusionDenominator[i] += 1 / mgmParameters->mgm13variance[i]; } } if (mgm4valid) { - float mgm4ValueNT[3]; - VectorOperations::mulScalar(mgm4Value, 1e-3, mgm4ValueNT, 3); // uT to nT - VectorOperations::subtract(mgm4ValueNT, mgmParameters->mgm4hardIronOffset, + float mgm4ValueUT[3]; + VectorOperations::mulScalar(mgm4Value, 1e-3, mgm4ValueUT, 3); // nT to uT + MatrixOperations::multiply(mgmParameters->mgm4orientationMatrix[0], mgm4ValueUT, + mgm4ValueBody, 3, 3, 1); + VectorOperations::subtract(mgm4ValueBody, mgmParameters->mgm4hardIronOffset, mgm4ValueNoBias, 3); MatrixOperations::multiply(mgmParameters->mgm4softIronInverse[0], mgm4ValueNoBias, mgm4ValueCalib, 3, 3, 1); - MatrixOperations::multiply(mgmParameters->mgm4orientationMatrix[0], mgm4ValueCalib, - mgm4ValueBody, 3, 3, 1); + for (uint8_t i = 0; i < 3; i++) { - sensorFusionNumerator[i] += mgm4ValueBody[i] / mgmParameters->mgm4variance[i]; + sensorFusionNumerator[i] += mgm4ValueCalib[i] / mgmParameters->mgm4variance[i]; sensorFusionDenominator[i] += 1 / mgmParameters->mgm4variance[i]; } } @@ -148,15 +149,15 @@ void SensorProcessing::processMgm(const float *mgm0Value, bool mgm0valid, const { PoolReadGuard pg(mgmDataProcessed); if (pg.getReadResult() == returnvalue::OK) { - std::memcpy(mgmDataProcessed->mgm0vec.value, mgm0ValueBody, 3 * sizeof(float)); + std::memcpy(mgmDataProcessed->mgm0vec.value, mgm0ValueCalib, 3 * sizeof(float)); mgmDataProcessed->mgm0vec.setValid(mgm0valid); - std::memcpy(mgmDataProcessed->mgm1vec.value, mgm1ValueBody, 3 * sizeof(float)); + std::memcpy(mgmDataProcessed->mgm1vec.value, mgm1ValueCalib, 3 * sizeof(float)); mgmDataProcessed->mgm1vec.setValid(mgm1valid); - std::memcpy(mgmDataProcessed->mgm2vec.value, mgm2ValueBody, 3 * sizeof(float)); + std::memcpy(mgmDataProcessed->mgm2vec.value, mgm2ValueCalib, 3 * sizeof(float)); mgmDataProcessed->mgm2vec.setValid(mgm2valid); - std::memcpy(mgmDataProcessed->mgm3vec.value, mgm3ValueBody, 3 * sizeof(float)); + std::memcpy(mgmDataProcessed->mgm3vec.value, mgm3ValueCalib, 3 * sizeof(float)); mgmDataProcessed->mgm3vec.setValid(mgm3valid); - std::memcpy(mgmDataProcessed->mgm4vec.value, mgm4ValueBody, 3 * sizeof(float)); + std::memcpy(mgmDataProcessed->mgm4vec.value, mgm4ValueCalib, 3 * sizeof(float)); mgmDataProcessed->mgm4vec.setValid(mgm4valid); std::memcpy(mgmDataProcessed->mgmVecTot.value, mgmVecTot, 3 * sizeof(double)); mgmDataProcessed->mgmVecTot.setValid(true); From 03ec64672bfbaf6da0b7d517088f1518038a19a4 Mon Sep 17 00:00:00 2001 From: Marius Eggert Date: Thu, 26 Jan 2023 17:15:04 +0100 Subject: [PATCH 02/29] also fixed validity flag --- mission/controller/acs/SensorProcessing.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/mission/controller/acs/SensorProcessing.cpp b/mission/controller/acs/SensorProcessing.cpp index a8fd1576..5b4ddc84 100644 --- a/mission/controller/acs/SensorProcessing.cpp +++ b/mission/controller/acs/SensorProcessing.cpp @@ -129,6 +129,7 @@ void SensorProcessing::processMgm(const float *mgm0Value, bool mgm0valid, const for (uint8_t i = 0; i < 3; i++) { mgmVecTotDerivative[i] = (mgmVecTot[i] - savedMgmVecTot[i]) / timeDiff; savedMgmVecTot[i] = mgmVecTot[i]; + mgmVecTotDerivativeValid = true; } } timeOfSavedMagFieldEst = timeOfMgmMeasurement; From 24d2405fc8f6841db776f2f1e7315ce60a497f24 Mon Sep 17 00:00:00 2001 From: meggert Date: Fri, 27 Jan 2023 11:18:55 +0100 Subject: [PATCH 03/29] added calibration matrices for testing --- mission/controller/acs/AcsParameters.h | 36 ++++++++++++++------------ 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/mission/controller/acs/AcsParameters.h b/mission/controller/acs/AcsParameters.h index a62b373d..2fd5ab27 100644 --- a/mission/controller/acs/AcsParameters.h +++ b/mission/controller/acs/AcsParameters.h @@ -37,23 +37,27 @@ class AcsParameters /*: public HasParametersIF*/ { float mgm3orientationMatrix[3][3] = {{0, 0, 1}, {0, -1, 0}, {1, 0, 0}}; float mgm4orientationMatrix[3][3] = {{0, 0, -1}, {-1, 0, 0}, {0, 1, 0}}; - float mgm0hardIronOffset[3] = {0.0, 0.0, 0.0};//{19.89364, -29.94111, -31.07508}; - float mgm1hardIronOffset[3] = {0.0, 0.0, 0.0};//{10.95500, -8.053403, -33.36383}; - float mgm2hardIronOffset[3] = {0.0, 0.0, 0.0};//{15.72181, -26.87090, -62.19010}; - float mgm3hardIronOffset[3] = {0.0, 0.0, 0.0}; - float mgm4hardIronOffset[3] = {0.0, 0.0, 0.0}; + float mgm0hardIronOffset[3] = {-3.009521e1, 1.600983e1, -3.025359e1}; + float mgm1hardIronOffset[3] = {-3.255443e1, 1.118625e1, -8.400313e0}; + float mgm2hardIronOffset[3] = {-6.194874e1, 1.561503e1, -2.911635e1}; + float mgm3hardIronOffset[3] = {-3.986654e1, 1.413371e1, -9.778686e0}; + float mgm4hardIronOffset[3] = {-3.046779e1, 1.690829e1, -6.597055e0}; - float mgm0softIronInverse[3][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};/*{{1420.727e-3, 9.352825e-3, -127.1979e-3}, - {9.352825e-3, 1031.965e-3, -80.02734e-3}, - {-127.1979e-3, -80.02734e-3, 934.8899e-3}};*/ - float mgm1softIronInverse[3][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};/*{{126.7325e-2, -4.146410e-2, -18.37963e-2}, - {-4.146410e-2, 109.3310e-2, -5.246314e-2}, - {-18.37963e-2, -5.246314e-2, 105.7300e-2}};*/ - float mgm2softIronInverse[3][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};/*{{143.0438e-2, 7.095763e-2, 15.67482e-2}, - {7.095763e-2, 99.65167e-2, -6.958760e-2}, - {15.67482e-2, -6.958760e-2, 94.50124e-2}};*/ - float mgm3softIronInverse[3][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}; - float mgm4softIronInverse[3][3] = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}}; + float mgm0softIronInverse[3][3] = {{9.385532e-1, -1.261877e-1, -8.086912e-2}, + {-1.261877e-1, 1.415967e0, -6.953750e-3}, + {-8.086912e-2, -6.953750e-3, 1.014963e0}}; + float mgm1softIronInverse[3][3] = {{1.054248e0, -1.867005e-1, -4.884622e-2}, + {-1.867005e-1, 1.272026e0, -4.212676e-2}, + {-4.884622e-2, -4.212676e-2, 1.091061e0}}; + float mgm2softIronInverse[3][3] = {{9.474586e-1, 1.506282e-1, -7.002351e-2}, + {1.506282e-1, 1.427704e0, 7.247630e-2}, + {-7.002351e-2, 7.247630e-2, 9.822354e-1}}; + float mgm3softIronInverse[3][3] = {{1.082337e0, 1.971590e-1, -6.910370e-2}, + {1.971590e-1, 1.265329e0, 1.301571e-2}, + {-6.910370e-2, 1.301571e-2, 1.072459e0}}; + float mgm4softIronInverse[3][3] = {{1.094184e0, -1.765240e-2, -3.580871e-2}, + {-1.765240e-2, 1.250533e0, 8.302781e-3}, + {-3.580871e-2, 8.302781e-3, 1.325068e0}}; float mgm02variance[3] = {1, 1, 1}; float mgm13variance[3] = {1, 1, 1}; float mgm4variance[3] = {1, 1, 1}; From 45eadb8302ce00f9bd092d719492c08f8bcfdc62 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Tue, 31 Jan 2023 10:08:28 +0100 Subject: [PATCH 04/29] added new calibration matrices --- mission/controller/acs/AcsParameters.h | 40 +++++++++++++------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/mission/controller/acs/AcsParameters.h b/mission/controller/acs/AcsParameters.h index 2fd5ab27..1fe5f29c 100644 --- a/mission/controller/acs/AcsParameters.h +++ b/mission/controller/acs/AcsParameters.h @@ -37,27 +37,27 @@ class AcsParameters /*: public HasParametersIF*/ { float mgm3orientationMatrix[3][3] = {{0, 0, 1}, {0, -1, 0}, {1, 0, 0}}; float mgm4orientationMatrix[3][3] = {{0, 0, -1}, {-1, 0, 0}, {0, 1, 0}}; - float mgm0hardIronOffset[3] = {-3.009521e1, 1.600983e1, -3.025359e1}; - float mgm1hardIronOffset[3] = {-3.255443e1, 1.118625e1, -8.400313e0}; - float mgm2hardIronOffset[3] = {-6.194874e1, 1.561503e1, -2.911635e1}; - float mgm3hardIronOffset[3] = {-3.986654e1, 1.413371e1, -9.778686e0}; - float mgm4hardIronOffset[3] = {-3.046779e1, 1.690829e1, -6.597055e0}; + float mgm0hardIronOffset[3] = {3.303907e0,4.009162e0,-1.677380e1}; + float mgm1hardIronOffset[3] = {-2.494258e0,3.526886e0,3.593006e0}; + float mgm2hardIronOffset[3] = {-1.630907e1,5.543566e0,-1.619287e1}; + float mgm3hardIronOffset[3] = {-8.612960e-1,2.752825e0,-1.101764e0}; + float mgm4hardIronOffset[3] = {1.696131e0,4.624440e0,2.449785e-1}; - float mgm0softIronInverse[3][3] = {{9.385532e-1, -1.261877e-1, -8.086912e-2}, - {-1.261877e-1, 1.415967e0, -6.953750e-3}, - {-8.086912e-2, -6.953750e-3, 1.014963e0}}; - float mgm1softIronInverse[3][3] = {{1.054248e0, -1.867005e-1, -4.884622e-2}, - {-1.867005e-1, 1.272026e0, -4.212676e-2}, - {-4.884622e-2, -4.212676e-2, 1.091061e0}}; - float mgm2softIronInverse[3][3] = {{9.474586e-1, 1.506282e-1, -7.002351e-2}, - {1.506282e-1, 1.427704e0, 7.247630e-2}, - {-7.002351e-2, 7.247630e-2, 9.822354e-1}}; - float mgm3softIronInverse[3][3] = {{1.082337e0, 1.971590e-1, -6.910370e-2}, - {1.971590e-1, 1.265329e0, 1.301571e-2}, - {-6.910370e-2, 1.301571e-2, 1.072459e0}}; - float mgm4softIronInverse[3][3] = {{1.094184e0, -1.765240e-2, -3.580871e-2}, - {-1.765240e-2, 1.250533e0, 8.302781e-3}, - {-3.580871e-2, 8.302781e-3, 1.325068e0}}; + float mgm0softIronInverse[3][3] = {{9.687712e-1,1.144510e-2,-9.601610e-2}, + {1.144510e-2,1.391574e0,-1.169994e-1}, + {-9.601610e-2,-1.169994e-1,1.025668e0}}; + float mgm1softIronInverse[3][3] = {{1.086339e0,-4.341287e-2,-5.870281e-2}, + {-4.341287e-2,1.274588e0,-1.893176e-1}, + {-5.870281e-2,-1.893176e-1,1.077651e0}}; + float mgm2softIronInverse[3][3] = {{9.554406e-1,7.009618e-2,-7.924296e-2}, + {7.009618e-2,1.428436e0,1.504623e-1}, + {-7.924296e-2,1.504623e-1,9.978038e-1}}; + float mgm3softIronInverse[3][3] = {{1.091974e0,1.492663e-2-5.993296e-2}, + {1.492663e-2,1.263068e0,2.013953e-1}, + {-5.993296e-2,2.013953e-1,1.055083e0}}; + float mgm4softIronInverse[3][3] = {{1.100341e0,-7.430518e-4,-3.810031e-2}, + {-7.430518e-4,1.259561e0,-1.951225e-2}, + {-3.810031e-2,-1.951225e-2,1.342584e0}}; float mgm02variance[3] = {1, 1, 1}; float mgm13variance[3] = {1, 1, 1}; float mgm4variance[3] = {1, 1, 1}; From 18af6228a0d617f47b0a56a457d9e57a825733ab Mon Sep 17 00:00:00 2001 From: meggert Date: Tue, 7 Feb 2023 09:30:20 +0100 Subject: [PATCH 05/29] added final calibration matrices --- mission/controller/acs/AcsParameters.h | 41 +++++++++++++------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/mission/controller/acs/AcsParameters.h b/mission/controller/acs/AcsParameters.h index 1fe5f29c..ab8114bb 100644 --- a/mission/controller/acs/AcsParameters.h +++ b/mission/controller/acs/AcsParameters.h @@ -37,27 +37,28 @@ class AcsParameters /*: public HasParametersIF*/ { float mgm3orientationMatrix[3][3] = {{0, 0, 1}, {0, -1, 0}, {1, 0, 0}}; float mgm4orientationMatrix[3][3] = {{0, 0, -1}, {-1, 0, 0}, {0, 1, 0}}; - float mgm0hardIronOffset[3] = {3.303907e0,4.009162e0,-1.677380e1}; - float mgm1hardIronOffset[3] = {-2.494258e0,3.526886e0,3.593006e0}; - float mgm2hardIronOffset[3] = {-1.630907e1,5.543566e0,-1.619287e1}; - float mgm3hardIronOffset[3] = {-8.612960e-1,2.752825e0,-1.101764e0}; - float mgm4hardIronOffset[3] = {1.696131e0,4.624440e0,2.449785e-1}; + float mgm0hardIronOffset[3] = {6.116487, 6.796264, -19.188060}; + float mgm1hardIronOffset[3] = {-1.077152, 2.080583, 1.974483}; + float mgm2hardIronOffset[3] = {-19.285857, 5.401821, -16.096297}; + float mgm3hardIronOffset[3] = {-0.634033, 2.787695, 0.092036}; + float mgm4hardIronOffset[3] = {1.722133, 4.511870, 0.379980}; + + float mgm0softIronInverse[3][3] = {{1.163335, 0.137584, 0.203908}, + {0.137584, 0.625606, 0.045537}, + {0.203908, 0.045537, 1.095923}}; + float mgm1softIronInverse[3][3] = {{0.972071, 0.131166, 0.042151}, + {0.131166, 0.803260, 0.034779}, + {0.042151, 0.034779, 0.923417}}; + float mgm2softIronInverse[3][3] = {{1.234863, -0.157745, 0.070813}, + {-0.157745, 0.746707, -0.062080}, + {0.070813, -0.062080, 1.122514}}; + float mgm3softIronInverse[3][3] = {{0.956890, -0.134841, 0.054017}, + {-0.134841, 0.811361, -0.015383}, + {0.054017, -0.015383, 0.939153}}; + float mgm4softIronInverse[3][3] = {{0.913163, 0.011058, 0.023273}, + {0.011058, 0.792295, 0.002921}, + {0.023273, 0.002921, 0.739496}}; - float mgm0softIronInverse[3][3] = {{9.687712e-1,1.144510e-2,-9.601610e-2}, - {1.144510e-2,1.391574e0,-1.169994e-1}, - {-9.601610e-2,-1.169994e-1,1.025668e0}}; - float mgm1softIronInverse[3][3] = {{1.086339e0,-4.341287e-2,-5.870281e-2}, - {-4.341287e-2,1.274588e0,-1.893176e-1}, - {-5.870281e-2,-1.893176e-1,1.077651e0}}; - float mgm2softIronInverse[3][3] = {{9.554406e-1,7.009618e-2,-7.924296e-2}, - {7.009618e-2,1.428436e0,1.504623e-1}, - {-7.924296e-2,1.504623e-1,9.978038e-1}}; - float mgm3softIronInverse[3][3] = {{1.091974e0,1.492663e-2-5.993296e-2}, - {1.492663e-2,1.263068e0,2.013953e-1}, - {-5.993296e-2,2.013953e-1,1.055083e0}}; - float mgm4softIronInverse[3][3] = {{1.100341e0,-7.430518e-4,-3.810031e-2}, - {-7.430518e-4,1.259561e0,-1.951225e-2}, - {-3.810031e-2,-1.951225e-2,1.342584e0}}; float mgm02variance[3] = {1, 1, 1}; float mgm13variance[3] = {1, 1, 1}; float mgm4variance[3] = {1, 1, 1}; From a9fcb6a183d6de7263ed48ef944cb8049e7fa85b Mon Sep 17 00:00:00 2001 From: meggert Date: Tue, 7 Feb 2023 09:46:19 +0100 Subject: [PATCH 06/29] update changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b15c4f12..c835c81c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,10 +17,17 @@ change warranting a new major release: # [unreleased] +## Changed + +- Readded calibration matrices for MGM calibration + ## Fixed - Bugfix in FSFW where the sequence flags of the PUS packets were set to continuation segment (0b00) instead of unsegmented (0b11). +- Bugfixes in 'SensofProcessing' where previously MGM values would be calibrated before being + transformed in body RF. However, the calibration values are in the body RF. Also fixed the + validity flag of 'mgmVecTotDerivative'. # [v1.23.0] 2023-02-01 From c8e376a625192f9ff46aaa0f493c54f73f0087b4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 7 Feb 2023 10:03:51 +0100 Subject: [PATCH 07/29] add missing pool read guards --- linux/devices/GpsHyperionLinuxController.cpp | 61 +++++++++----------- linux/devices/GpsHyperionLinuxController.h | 7 ++- 2 files changed, 31 insertions(+), 37 deletions(-) diff --git a/linux/devices/GpsHyperionLinuxController.cpp b/linux/devices/GpsHyperionLinuxController.cpp index 6bbbcfb7..3c19ca72 100644 --- a/linux/devices/GpsHyperionLinuxController.cpp +++ b/linux/devices/GpsHyperionLinuxController.cpp @@ -44,6 +44,7 @@ ReturnValue_t GpsHyperionLinuxController::checkModeCommand(Mode_t mode, Submode_ } } if (mode == MODE_OFF) { + PoolReadGuard pg(&gpsSet); gpsSet.setValidity(false, true); } return returnvalue::OK; @@ -217,7 +218,7 @@ ReturnValue_t GpsHyperionLinuxController::handleGpsReadData() { modeCommanded = false; } gpsSet.setValidity(false, true); - } else if (gps.satellites_used > 0) { + } else if (gps.satellites_used > 0 && validFix) { gpsSet.setValidity(true, true); } @@ -250,46 +251,20 @@ ReturnValue_t GpsHyperionLinuxController::handleGpsReadData() { gpsSet.speed.setValid(false); } -#if LIBGPS_VERSION_MINOR <= 17 - gpsSet.unixSeconds.value = gps.fix.time; -#else - gpsSet.unixSeconds.value = gps.fix.time.tv_sec; -#endif timeval time = {}; - time.tv_sec = gpsSet.unixSeconds.value; #if LIBGPS_VERSION_MINOR <= 17 - double fractionalPart = gps.fix.time - std::floor(gps.fix.time); + gpsSet.unixSeconds.value = std::floor(gps.fix.time); + double fractionalPart = gps.fix.time - gpsSet.unixSeconds.value; time.tv_usec = fractionalPart * 1000.0 * 1000.0; #else + gpsSet.unixSeconds.value = gps.fix.time.tv_sec; time.tv_usec = gps.fix.time.tv_nsec / 1000; #endif - std::time_t t = std::time(nullptr); - if (time.tv_sec == t) { - timeIsConstantCounter++; - } else { - timeIsConstantCounter = 0; - } - if (timeInit and validFix) { - if (not utility::timeSanityCheck()) { -#if OBSW_VERBOSE_LEVEL >= 1 - time_t timeRaw = time.tv_sec; - std::tm *timeTm = std::gmtime(&timeRaw); - sif::info << "Setting invalid system time from GPS data directly: " - << std::put_time(timeTm, "%c %Z") << std::endl; -#endif - // For some reason, the clock needs to be somewhat correct for NTP to work. Really dumb.. - Clock::setClock(&time); - } - timeInit = false; - } - // If the received time does not change anymore for whatever reason, do not set it here - // to avoid stale times. Also, don't do it too often often to avoid jumping times - if (timeIsConstantCounter < 20 and timeUpdateCd.hasTimedOut()) { - // Update the system time here for now. NTP seems to be unable to do so for whatever reason. - // Further tests have shown that the time seems to be set by NTPD after some time.. - // Clock::setClock(&time); - timeUpdateCd.resetTimer(); - } + time.tv_sec = gpsSet.unixSeconds.value; + // If the time is totally wrong (e.g. year 2000 after system reset because we do not have a RTC + // and no time file available) we set it with the roughly valid time from the GPS. + // NTP might only work if the time difference between sys time and current time is not too large. + overwriteTimeIfNotSane(time, validFix); Clock::TimeOfDay_t timeOfDay = {}; Clock::convertTimevalToTimeOfDay(&time, &timeOfDay); @@ -325,3 +300,19 @@ ReturnValue_t GpsHyperionLinuxController::handleGpsReadData() { } return returnvalue::OK; } + +void GpsHyperionLinuxController::overwriteTimeIfNotSane(timeval time, bool validFix) { + if (not timeInit and validFix) { + if (not utility::timeSanityCheck()) { +#if OBSW_VERBOSE_LEVEL >= 1 + time_t timeRaw = time.tv_sec; + std::tm *timeTm = std::gmtime(&timeRaw); + sif::info << "Overwriting invalid system time from GPS data directly: " + << std::put_time(timeTm, "%c %Z") << std::endl; +#endif + // For some reason, the clock needs to be somewhat correct for NTP to work. Really dumb.. + Clock::setClock(&time); + } + timeInit = true; + } +} diff --git a/linux/devices/GpsHyperionLinuxController.h b/linux/devices/GpsHyperionLinuxController.h index d2dc91b6..5b0a84cd 100644 --- a/linux/devices/GpsHyperionLinuxController.h +++ b/linux/devices/GpsHyperionLinuxController.h @@ -59,17 +59,20 @@ class GpsHyperionLinuxController : public ExtendedControllerBase { ReadModes readMode = ReadModes::SOCKET; Countdown maxTimeToReachFix = Countdown(MAX_SECONDS_TO_REACH_FIX * 1000); bool modeCommanded = true; - bool timeInit = true; + bool timeInit = false; bool gpsNotOpenSwitch = true; bool gpsReadFailedSwitch = true; bool debugHyperionGps = false; int32_t noModeSetCntr = 0; - uint32_t timeIsConstantCounter = 0; Countdown timeUpdateCd = Countdown(60); // Returns true if the function should be called again or false if other // controller handling can be done. bool readGpsDataFromGpsd(); + // If the time is totally wrong (e.g. year 2000 after system reset because we do not have a RTC) + // we set it with the roughly valid time from the GPS. For some reason, NTP might only work + // if the time difference between sys time and current time is not too large + void overwriteTimeIfNotSane(timeval time, bool validFix); }; #endif /* MISSION_DEVICES_GPSHYPERIONHANDLER_H_ */ From 07ca7388427e69586b6b3e7357e1ad20ab33fdb2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 7 Feb 2023 10:12:28 +0100 Subject: [PATCH 08/29] some more tweaks --- linux/devices/GpsHyperionLinuxController.cpp | 23 ++++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/linux/devices/GpsHyperionLinuxController.cpp b/linux/devices/GpsHyperionLinuxController.cpp index 3c19ca72..c3e7bc73 100644 --- a/linux/devices/GpsHyperionLinuxController.cpp +++ b/linux/devices/GpsHyperionLinuxController.cpp @@ -225,25 +225,34 @@ ReturnValue_t GpsHyperionLinuxController::handleGpsReadData() { gpsSet.satInUse.value = gps.satellites_used; gpsSet.satInView.value = gps.satellites_visible; + bool latValid = false; if (std::isfinite(gps.fix.latitude)) { // Negative latitude -> South direction gpsSet.latitude.value = gps.fix.latitude; - } else { - gpsSet.latitude.setValid(false); + if(gps.fix.mode >= 2) { + latValid = true; + } } + gpsSet.latitude.setValid(latValid); + bool longValid = false; if (std::isfinite(gps.fix.longitude)) { // Negative longitude -> West direction gpsSet.longitude.value = gps.fix.longitude; - } else { - gpsSet.longitude.setValid(false); + if(gps.fix.mode >= 2) { + longValid = true; + } } + gpsSet.latitude.setValid(longValid); + bool altitudeValid = false; if (std::isfinite(gps.fix.altitude)) { gpsSet.altitude.value = gps.fix.altitude; - } else { - gpsSet.altitude.setValid(false); + if(gps.fix.mode == 3) { + altitudeValid = true; + } } + gpsSet.altitude.setValid(altitudeValid); if (std::isfinite(gps.fix.speed)) { gpsSet.speed.value = gps.fix.speed; @@ -277,7 +286,7 @@ ReturnValue_t GpsHyperionLinuxController::handleGpsReadData() { if (debugHyperionGps) { sif::info << "-- Hyperion GPS Data --" << std::endl; #if LIBGPS_VERSION_MINOR <= 17 - time_t timeRaw = gps.fix.time; + time_t timeRaw = gpsSet.unixSeconds.value; #else time_t timeRaw = gps.fix.time.tv_sec; #endif From d6aa6875ccb88c2cca7f9ffd9d50698b081d4526 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 7 Feb 2023 10:22:12 +0100 Subject: [PATCH 09/29] typos and other minor adaptions --- linux/devices/GpsHyperionLinuxController.cpp | 67 +++++++++++--------- 1 file changed, 38 insertions(+), 29 deletions(-) diff --git a/linux/devices/GpsHyperionLinuxController.cpp b/linux/devices/GpsHyperionLinuxController.cpp index c3e7bc73..7554b805 100644 --- a/linux/devices/GpsHyperionLinuxController.cpp +++ b/linux/devices/GpsHyperionLinuxController.cpp @@ -199,19 +199,17 @@ ReturnValue_t GpsHyperionLinuxController::handleGpsReadData() { } bool validFix = false; - static_cast(validFix); // 0: Not seen, 1: No fix, 2: 2D-Fix, 3: 3D-Fix - int newFixMode = gps.fix.mode; - if (newFixMode == 2 or newFixMode == 3) { + if (gps.fix.mode == 2 or gps.fix.mode == 3) { validFix = true; } - if (gpsSet.fixMode.value != newFixMode) { - triggerEvent(GpsHyperion::GPS_FIX_CHANGE, gpsSet.fixMode.value, newFixMode); + if (gpsSet.fixMode.value != gps.fix.mode) { + triggerEvent(GpsHyperion::GPS_FIX_CHANGE, gpsSet.fixMode.value, gps.fix.mode); } - gpsSet.fixMode.value = newFixMode; + gpsSet.fixMode.value = gps.fix.mode; if (gps.fix.mode == 0 or gps.fix.mode == 1) { if (modeCommanded and maxTimeToReachFix.hasTimedOut()) { - // We are supposed to be on and functioning, but not fix was found + // We are supposed to be on and functioning, but no fix was found if (mode == MODE_ON or mode == MODE_NORMAL) { mode = MODE_OFF; } @@ -229,7 +227,7 @@ ReturnValue_t GpsHyperionLinuxController::handleGpsReadData() { if (std::isfinite(gps.fix.latitude)) { // Negative latitude -> South direction gpsSet.latitude.value = gps.fix.latitude; - if(gps.fix.mode >= 2) { + if (gps.fix.mode >= 2) { latValid = true; } } @@ -239,7 +237,7 @@ ReturnValue_t GpsHyperionLinuxController::handleGpsReadData() { if (std::isfinite(gps.fix.longitude)) { // Negative longitude -> West direction gpsSet.longitude.value = gps.fix.longitude; - if(gps.fix.mode >= 2) { + if (gps.fix.mode >= 2) { longValid = true; } } @@ -248,7 +246,7 @@ ReturnValue_t GpsHyperionLinuxController::handleGpsReadData() { bool altitudeValid = false; if (std::isfinite(gps.fix.altitude)) { gpsSet.altitude.value = gps.fix.altitude; - if(gps.fix.mode == 3) { + if (gps.fix.mode == 3) { altitudeValid = true; } } @@ -260,29 +258,40 @@ ReturnValue_t GpsHyperionLinuxController::handleGpsReadData() { gpsSet.speed.setValid(false); } - timeval time = {}; + if (TIME_SET != (TIME_SET & gps.set)) { + timeval time = {}; #if LIBGPS_VERSION_MINOR <= 17 - gpsSet.unixSeconds.value = std::floor(gps.fix.time); - double fractionalPart = gps.fix.time - gpsSet.unixSeconds.value; - time.tv_usec = fractionalPart * 1000.0 * 1000.0; + gpsSet.unixSeconds.value = std::floor(gps.fix.time); + double fractionalPart = gps.fix.time - gpsSet.unixSeconds.value; + time.tv_usec = fractionalPart * 1000.0 * 1000.0; #else - gpsSet.unixSeconds.value = gps.fix.time.tv_sec; - time.tv_usec = gps.fix.time.tv_nsec / 1000; + gpsSet.unixSeconds.value = gps.fix.time.tv_sec; + time.tv_usec = gps.fix.time.tv_nsec / 1000; #endif - time.tv_sec = gpsSet.unixSeconds.value; - // If the time is totally wrong (e.g. year 2000 after system reset because we do not have a RTC - // and no time file available) we set it with the roughly valid time from the GPS. - // NTP might only work if the time difference between sys time and current time is not too large. - overwriteTimeIfNotSane(time, validFix); + time.tv_sec = gpsSet.unixSeconds.value; + // If the time is totally wrong (e.g. year 2000 after system reset because we do not have a RTC + // and no time file available) we set it with the roughly valid time from the GPS. + // NTP might only work if the time difference between sys time and current time is not too + // large. + overwriteTimeIfNotSane(time, validFix); + Clock::TimeOfDay_t timeOfDay = {}; + Clock::convertTimevalToTimeOfDay(&time, &timeOfDay); + gpsSet.year = timeOfDay.year; + gpsSet.month = timeOfDay.month; + gpsSet.day = timeOfDay.day; + gpsSet.hours = timeOfDay.hour; + gpsSet.minutes = timeOfDay.minute; + gpsSet.seconds = timeOfDay.second; + } else { + gpsSet.unixSeconds.setValid(false); + gpsSet.year.setValid(false); + gpsSet.month.setValid(false); + gpsSet.day.setValid(false); + gpsSet.hours.setValid(false); + gpsSet.minutes.setValid(false); + gpsSet.seconds.setValid(false); + } - Clock::TimeOfDay_t timeOfDay = {}; - Clock::convertTimevalToTimeOfDay(&time, &timeOfDay); - gpsSet.year = timeOfDay.year; - gpsSet.month = timeOfDay.month; - gpsSet.day = timeOfDay.day; - gpsSet.hours = timeOfDay.hour; - gpsSet.minutes = timeOfDay.minute; - gpsSet.seconds = timeOfDay.second; if (debugHyperionGps) { sif::info << "-- Hyperion GPS Data --" << std::endl; #if LIBGPS_VERSION_MINOR <= 17 From d6b60723d9e6e3942cbb095e8123d422c93b6ee4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 7 Feb 2023 12:53:30 +0100 Subject: [PATCH 10/29] bump fsfw --- fsfw | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsfw b/fsfw index 38789e05..69c94645 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 38789e053b65cfa14604fc625e7bcc8ca03a3f17 +Subproject commit 69c94645df81c2fc9d538a0f19d2c6552e1c73a7 From ab0a3bfd45165f804b0a437cbdc3347ac262e183 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 7 Feb 2023 14:02:46 +0100 Subject: [PATCH 11/29] some fixes and tweaks --- linux/devices/GpsHyperionLinuxController.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/linux/devices/GpsHyperionLinuxController.cpp b/linux/devices/GpsHyperionLinuxController.cpp index 7554b805..aa55b696 100644 --- a/linux/devices/GpsHyperionLinuxController.cpp +++ b/linux/devices/GpsHyperionLinuxController.cpp @@ -102,6 +102,7 @@ ReturnValue_t GpsHyperionLinuxController::performOperation(uint8_t opCode) { if (not callAgainImmediately) { handleQueue(); poolManager.performHkOperation(); + TaskFactory::delayTask(200); } } // Should never be reached. @@ -155,7 +156,7 @@ bool GpsHyperionLinuxController::readGpsDataFromGpsd() { }; if (readMode == ReadModes::SOCKET) { // Perform other necessary handling if not data seen for 0.2 seconds. - if (gps_waiting(&gps, 200000)) { + if (gps_waiting(&gps, 0)) { if (-1 == gps_read(&gps)) { readError(); return false; @@ -258,7 +259,7 @@ ReturnValue_t GpsHyperionLinuxController::handleGpsReadData() { gpsSet.speed.setValid(false); } - if (TIME_SET != (TIME_SET & gps.set)) { + if (TIME_SET == (TIME_SET & gps.set)) { timeval time = {}; #if LIBGPS_VERSION_MINOR <= 17 gpsSet.unixSeconds.value = std::floor(gps.fix.time); From 36ed787db1fc8ad4157ad5a9f57b0b522bf3d6fe Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 7 Feb 2023 14:16:43 +0100 Subject: [PATCH 12/29] improve SW switch handling - also add CANT_GET_FIX event --- linux/devices/GpsHyperionLinuxController.cpp | 40 +++++++++---------- linux/devices/GpsHyperionLinuxController.h | 15 +++++-- .../devicedefinitions/GPSDefinitions.h | 3 ++ 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/linux/devices/GpsHyperionLinuxController.cpp b/linux/devices/GpsHyperionLinuxController.cpp index aa55b696..ee5f2321 100644 --- a/linux/devices/GpsHyperionLinuxController.cpp +++ b/linux/devices/GpsHyperionLinuxController.cpp @@ -34,7 +34,6 @@ ReturnValue_t GpsHyperionLinuxController::checkModeCommand(Mode_t mode, Submode_ uint32_t *msToReachTheMode) { if (not modeCommanded) { if (mode == MODE_ON or mode == MODE_OFF) { - gpsNotOpenSwitch = true; // 5h time to reach fix *msToReachTheMode = MAX_SECONDS_TO_REACH_FIX; maxTimeToReachFix.resetTimer(); @@ -46,6 +45,7 @@ ReturnValue_t GpsHyperionLinuxController::checkModeCommand(Mode_t mode, Submode_ if (mode == MODE_OFF) { PoolReadGuard pg(&gpsSet); gpsSet.setValidity(false, true); + oneShotSwitches.reset(); } return returnvalue::OK; } @@ -102,7 +102,6 @@ ReturnValue_t GpsHyperionLinuxController::performOperation(uint8_t opCode) { if (not callAgainImmediately) { handleQueue(); poolManager.performHkOperation(); - TaskFactory::delayTask(200); } } // Should never be reached. @@ -115,25 +114,24 @@ ReturnValue_t GpsHyperionLinuxController::initialize() { return result; } auto openError = [&](const char *type, int error) { - if (gpsNotOpenSwitch) { - // Opening failed + // Opening failed #if FSFW_VERBOSE_LEVEL >= 1 - sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Opening GPSMM " << type - << " failed | Error " << error << " | " << gps_errstr(error) << std::endl; + sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Opening GPSMM " << type + << " failed | Error " << error << " | " << gps_errstr(error) << std::endl; #endif - gpsNotOpenSwitch = false; - } }; if (readMode == ReadModes::SOCKET) { int retval = gps_open("localhost", DEFAULT_GPSD_PORT, &gps); if (retval != 0) { openError("Socket", retval); + return ObjectManager::CHILD_INIT_FAILED; } gps_stream(&gps, WATCH_ENABLE | WATCH_JSON, nullptr); } else if (readMode == ReadModes::SHM) { int retval = gps_open(GPSD_SHARED_MEMORY, "", &gps); if (retval != 0) { openError("SHM", retval); + return ObjectManager::CHILD_INIT_FAILED; } } return result; @@ -147,8 +145,8 @@ void GpsHyperionLinuxController::performControlOperation() {} bool GpsHyperionLinuxController::readGpsDataFromGpsd() { auto readError = [&]() { - if (gpsReadFailedSwitch) { - gpsReadFailedSwitch = false; + if (oneShotSwitches.gpsReadFailedSwitch) { + oneShotSwitches.gpsReadFailedSwitch = false; sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: Reading GPS data failed | " "Error " << errno << " | " << gps_errstr(errno) << std::endl; @@ -156,23 +154,21 @@ bool GpsHyperionLinuxController::readGpsDataFromGpsd() { }; if (readMode == ReadModes::SOCKET) { // Perform other necessary handling if not data seen for 0.2 seconds. - if (gps_waiting(&gps, 0)) { + if (gps_waiting(&gps, 200000)) { if (-1 == gps_read(&gps)) { readError(); return false; } + oneShotSwitches.gpsReadFailedSwitch = true; if (MODE_SET != (MODE_SET & gps.set)) { - if (mode == MODE_ON) { - if (noModeSetCntr >= 0) { - noModeSetCntr++; - } - if (noModeSetCntr == 10) { - // TODO: Trigger event here - sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: No mode could be " - "read for 10 consecutive reads" - << std::endl; - noModeSetCntr = -1; - } + if (mode != MODE_OFF and maxTimeToReachFix.hasTimedOut() and + oneShotSwitches.cantGetFixSwitch) { + // TODO: Trigger event here + sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: No mode could be " + "read for 10 consecutive reads" + << std::endl; + triggerEvent(GpsHyperion::CANT_GET_FIX, maxTimeToReachFix.timeout); + oneShotSwitches.cantGetFixSwitch = false; // did not event get mode, nothing to see. return false; } diff --git a/linux/devices/GpsHyperionLinuxController.h b/linux/devices/GpsHyperionLinuxController.h index 5b0a84cd..5d4a35ff 100644 --- a/linux/devices/GpsHyperionLinuxController.h +++ b/linux/devices/GpsHyperionLinuxController.h @@ -58,10 +58,19 @@ class GpsHyperionLinuxController : public ExtendedControllerBase { const char* currentClientBuf = nullptr; ReadModes readMode = ReadModes::SOCKET; Countdown maxTimeToReachFix = Countdown(MAX_SECONDS_TO_REACH_FIX * 1000); - bool modeCommanded = true; + bool modeCommanded = false; bool timeInit = false; - bool gpsNotOpenSwitch = true; - bool gpsReadFailedSwitch = true; + + struct OneShotSwitches { + void reset() { + gpsReadFailedSwitch = true; + cantGetFixSwitch = true; + } + bool gpsReadFailedSwitch = true; + bool cantGetFixSwitch = true; + + } oneShotSwitches; + bool debugHyperionGps = false; int32_t noModeSetCntr = 0; Countdown timeUpdateCd = Countdown(60); diff --git a/mission/devices/devicedefinitions/GPSDefinitions.h b/mission/devices/devicedefinitions/GPSDefinitions.h index 0b88cfa5..2ac7781d 100644 --- a/mission/devices/devicedefinitions/GPSDefinitions.h +++ b/mission/devices/devicedefinitions/GPSDefinitions.h @@ -13,6 +13,9 @@ static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::GPS_HANDLER; //! [EXPORT] : [COMMENT] Fix has changed. P1: Old fix. P2: New fix //! 0: Not seen, 1: No Fix, 2: 2D-Fix, 3: 3D-Fix static constexpr Event GPS_FIX_CHANGE = event::makeEvent(SUBSYSTEM_ID, 0, severity::INFO); +//! [EXPORT] : [COMMENT] Could not get fix in maximum allowed time. P1: Maximum allowed time +//! to get a fix after the GPS was switched on. +static constexpr Event CANT_GET_FIX = event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW); static constexpr DeviceCommandId_t GPS_REPLY = 0; static constexpr DeviceCommandId_t TRIGGER_RESET_PIN_GNSS = 5; From ecc61d184baf438ded0aa6c4f64a9e57869b9d89 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 7 Feb 2023 14:22:03 +0100 Subject: [PATCH 13/29] remove TODO --- linux/devices/GpsHyperionLinuxController.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/linux/devices/GpsHyperionLinuxController.cpp b/linux/devices/GpsHyperionLinuxController.cpp index ee5f2321..8d868512 100644 --- a/linux/devices/GpsHyperionLinuxController.cpp +++ b/linux/devices/GpsHyperionLinuxController.cpp @@ -163,10 +163,8 @@ bool GpsHyperionLinuxController::readGpsDataFromGpsd() { if (MODE_SET != (MODE_SET & gps.set)) { if (mode != MODE_OFF and maxTimeToReachFix.hasTimedOut() and oneShotSwitches.cantGetFixSwitch) { - // TODO: Trigger event here - sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: No mode could be " - "read for 10 consecutive reads" - << std::endl; + sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: No mode could be set in allowed " + << maxTimeToReachFix.timeout / 1000 << " seconds" << std::endl; triggerEvent(GpsHyperion::CANT_GET_FIX, maxTimeToReachFix.timeout); oneShotSwitches.cantGetFixSwitch = false; // did not event get mode, nothing to see. From 540bd63f4cc058defcfab66cae1fd5c83e584114 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 7 Feb 2023 14:22:18 +0100 Subject: [PATCH 14/29] afmt --- linux/devices/GpsHyperionLinuxController.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/linux/devices/GpsHyperionLinuxController.cpp b/linux/devices/GpsHyperionLinuxController.cpp index 8d868512..e4bd8c7f 100644 --- a/linux/devices/GpsHyperionLinuxController.cpp +++ b/linux/devices/GpsHyperionLinuxController.cpp @@ -163,7 +163,8 @@ bool GpsHyperionLinuxController::readGpsDataFromGpsd() { if (MODE_SET != (MODE_SET & gps.set)) { if (mode != MODE_OFF and maxTimeToReachFix.hasTimedOut() and oneShotSwitches.cantGetFixSwitch) { - sif::warning << "GPSHyperionHandler::readGpsDataFromGpsd: No mode could be set in allowed " + sif::warning + << "GPSHyperionHandler::readGpsDataFromGpsd: No mode could be set in allowed " << maxTimeToReachFix.timeout / 1000 << " seconds" << std::endl; triggerEvent(GpsHyperion::CANT_GET_FIX, maxTimeToReachFix.timeout); oneShotSwitches.cantGetFixSwitch = false; From b2de4ee08c668a73b98ba6361b6c78c0a6a71eb4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 7 Feb 2023 16:57:24 +0100 Subject: [PATCH 15/29] use full polling for gps_wating, manual delay --- linux/devices/GpsHyperionLinuxController.cpp | 12 ++++++++++-- tmtc | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/linux/devices/GpsHyperionLinuxController.cpp b/linux/devices/GpsHyperionLinuxController.cpp index e4bd8c7f..7350aebc 100644 --- a/linux/devices/GpsHyperionLinuxController.cpp +++ b/linux/devices/GpsHyperionLinuxController.cpp @@ -45,7 +45,10 @@ ReturnValue_t GpsHyperionLinuxController::checkModeCommand(Mode_t mode, Submode_ if (mode == MODE_OFF) { PoolReadGuard pg(&gpsSet); gpsSet.setValidity(false, true); + // There can't be a fix with a device that is off. + triggerEvent(GpsHyperion::GPS_FIX_CHANGE, gpsSet.fixMode.value, 0); oneShotSwitches.reset(); + modeCommanded = false; } return returnvalue::OK; } @@ -102,6 +105,7 @@ ReturnValue_t GpsHyperionLinuxController::performOperation(uint8_t opCode) { if (not callAgainImmediately) { handleQueue(); poolManager.performHkOperation(); + TaskFactory::delayTask(250); } } // Should never be reached. @@ -152,9 +156,13 @@ bool GpsHyperionLinuxController::readGpsDataFromGpsd() { << errno << " | " << gps_errstr(errno) << std::endl; } }; + // GPS is off, no point in reading data from GPSD. + if(mode == MODE_OFF) { + return false; + } if (readMode == ReadModes::SOCKET) { // Perform other necessary handling if not data seen for 0.2 seconds. - if (gps_waiting(&gps, 200000)) { + if (gps_waiting(&gps, 0)) { if (-1 == gps_read(&gps)) { readError(); return false; @@ -212,7 +220,7 @@ ReturnValue_t GpsHyperionLinuxController::handleGpsReadData() { modeCommanded = false; } gpsSet.setValidity(false, true); - } else if (gps.satellites_used > 0 && validFix) { + } else if (gps.satellites_used > 0 && validFix && mode != MODE_OFF) { gpsSet.setValidity(true, true); } diff --git a/tmtc b/tmtc index d6445d38..8a96e21d 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit d6445d38a8eb644a5e1bd27f0fc56d29e93c030d +Subproject commit 8a96e21d1a1ca790cd1053594495dd74beb12133 From f5ba8595607592350a51c2792e9ace567207d281 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 7 Feb 2023 17:01:07 +0100 Subject: [PATCH 16/29] comment fix --- linux/devices/GpsHyperionLinuxController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/devices/GpsHyperionLinuxController.cpp b/linux/devices/GpsHyperionLinuxController.cpp index 7350aebc..ec9cb61a 100644 --- a/linux/devices/GpsHyperionLinuxController.cpp +++ b/linux/devices/GpsHyperionLinuxController.cpp @@ -161,7 +161,7 @@ bool GpsHyperionLinuxController::readGpsDataFromGpsd() { return false; } if (readMode == ReadModes::SOCKET) { - // Perform other necessary handling if not data seen for 0.2 seconds. + // Poll the GPS. if (gps_waiting(&gps, 0)) { if (-1 == gps_read(&gps)) { readError(); From 4f2853e1b81e742258465676b8196bf8e92f7b89 Mon Sep 17 00:00:00 2001 From: meggert Date: Tue, 7 Feb 2023 18:07:19 +0100 Subject: [PATCH 17/29] adapted new acs submodes for checkModeCommand --- mission/controller/AcsController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mission/controller/AcsController.cpp b/mission/controller/AcsController.cpp index 8a58eb90..2e53d17c 100644 --- a/mission/controller/AcsController.cpp +++ b/mission/controller/AcsController.cpp @@ -426,7 +426,7 @@ ReturnValue_t AcsController::checkModeCommand(Mode_t mode, Submode_t submode, return INVALID_SUBMODE; } } else if ((mode == MODE_ON) || (mode == MODE_NORMAL)) { - if ((submode > 6) || (submode < 2)) { + if ((submode > acs::PTG_TARGET_INERTIAL) || (submode < acs::SAFE)) { return INVALID_SUBMODE; } else { return returnvalue::OK; From 2580b7cb20b92598a652dcd620a1a2d7f3593dbf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 7 Feb 2023 19:37:23 +0100 Subject: [PATCH 18/29] proper handling for git sha hash --- CMakeLists.txt | 5 ++++- cmake/EiveHelpers.cmake | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 97b1b2a0..25e63e69 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -171,7 +171,10 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git) list(GET GIT_INFO 1 OBSW_VERSION_MAJOR) list(GET GIT_INFO 2 OBSW_VERSION_MINOR) list(GET GIT_INFO 3 OBSW_VERSION_REVISION) - list(GET GIT_INFO 4 OBSW_VERSION_CST_GIT_SHA1) + list(LENGTH GIT_INFO LIST_LEN) + if(LIST_LEN GREATER 4) + list(GET GIT_INFO 4 OBSW_VERSION_CST_GIT_SHA1) + endif() if(NOT OBSW_VERSION_MAJOR) set(OBSW_VERSION_MAJOR ${OBSW_VERSION_MAJOR_IF_GIT_FAILS}) endif() diff --git a/cmake/EiveHelpers.cmake b/cmake/EiveHelpers.cmake index 1a717552..6410bf28 100644 --- a/cmake/EiveHelpers.cmake +++ b/cmake/EiveHelpers.cmake @@ -4,7 +4,7 @@ # 2. Major version # 3. Minor version # 4. Revision -# 5. git SHA hash and commits since tag +# 5. (Optional) git SHA hash and commits since tag when applicable function(determine_version_with_git) include(GetGitRevisionDescription) git_describe(VERSION ${ARGN}) @@ -22,7 +22,10 @@ function(determine_version_with_git) list(APPEND GIT_INFO ${_VERSION_MAJOR}) list(APPEND GIT_INFO ${_VERSION_MINOR}) list(APPEND GIT_INFO ${_VERSION_PATCH}) - list(APPEND GIT_INFO ${VERSION_SHA1}) + if(NOT VERSION_SHA1 STREQUAL VERSION) + list(APPEND GIT_INFO ${VERSION_SHA1}) + endif() set(GIT_INFO ${GIT_INFO} PARENT_SCOPE) + message(STATUS "GIT INFO: ${GIT_INFO}") message(STATUS "eive | Set git version info into GIT_INFO from the git tag ${VERSION}") endfunction() From 7514071d799e31e4348d69ed7f697697c1b16a37 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 7 Feb 2023 19:39:29 +0100 Subject: [PATCH 19/29] remove stray printout --- cmake/EiveHelpers.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/cmake/EiveHelpers.cmake b/cmake/EiveHelpers.cmake index 6410bf28..b210739e 100644 --- a/cmake/EiveHelpers.cmake +++ b/cmake/EiveHelpers.cmake @@ -26,6 +26,5 @@ function(determine_version_with_git) list(APPEND GIT_INFO ${VERSION_SHA1}) endif() set(GIT_INFO ${GIT_INFO} PARENT_SCOPE) - message(STATUS "GIT INFO: ${GIT_INFO}") message(STATUS "eive | Set git version info into GIT_INFO from the git tag ${VERSION}") endfunction() From 9373a244131b8b9dcbf8738ff34c521ace99cb45 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 7 Feb 2023 19:40:32 +0100 Subject: [PATCH 20/29] bump changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5eceb87..e6fee72b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,12 @@ change warranting a new major release: # [unreleased] +## Fixed + +- Build system: Fixed small bug, where the version itself was + stored as the git SHA hash in `commonConfig.h`. This will be + an empty string now for regular versions. + # [v1.25.0] 2023-02-06 eive-tmtc version: v2.12.0 From 6a24e1b9357ec0a53da11ffcbbdaace7bf493c52 Mon Sep 17 00:00:00 2001 From: meggert Date: Tue, 7 Feb 2023 20:11:16 +0100 Subject: [PATCH 21/29] updated MGM calibration values --- mission/controller/acs/AcsParameters.h | 32 +++++++++++++------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/mission/controller/acs/AcsParameters.h b/mission/controller/acs/AcsParameters.h index a7b2d631..c4653590 100644 --- a/mission/controller/acs/AcsParameters.h +++ b/mission/controller/acs/AcsParameters.h @@ -41,23 +41,23 @@ class AcsParameters /*: public HasParametersIF*/ { float mgm1hardIronOffset[3] = {-1.077152, 2.080583, 1.974483}; float mgm2hardIronOffset[3] = {-19.285857, 5.401821, -16.096297}; float mgm3hardIronOffset[3] = {-0.634033, 2.787695, 0.092036}; - float mgm4hardIronOffset[3] = {1.722133, 4.511870, 0.379980}; + float mgm4hardIronOffset[3] = {2.702743, 5.236043, 0.726229}; - float mgm0softIronInverse[3][3] = {{1.163335, 0.137584, 0.203908}, - {0.137584, 0.625606, 0.045537}, - {0.203908, 0.045537, 1.095923}}; - float mgm1softIronInverse[3][3] = {{0.972071, 0.131166, 0.042151}, - {0.131166, 0.803260, 0.034779}, - {0.042151, 0.034779, 0.923417}}; - float mgm2softIronInverse[3][3] = {{1.234863, -0.157745, 0.070813}, - {-0.157745, 0.746707, -0.062080}, - {0.070813, -0.062080, 1.122514}}; - float mgm3softIronInverse[3][3] = {{0.956890, -0.134841, 0.054017}, - {-0.134841, 0.811361, -0.015383}, - {0.054017, -0.015383, 0.939153}}; - float mgm4softIronInverse[3][3] = {{0.913163, 0.011058, 0.023273}, - {0.011058, 0.792295, 0.002921}, - {0.023273, 0.002921, 0.739496}}; + float mgm0softIronInverse[3][3] = {{0.910192, -0.188413, -0.161522}, + {-0.188413, 1.642303, -0.033184}, + {-0.161522, -0.033184, 0.943904}}; + float mgm1softIronInverse[3][3] = {{1.053508, -0.170225, -0.041678}, + {-0.170225, 1.274465, -0.040231}, + {-0.041678, -0.040231, 1.086352}}; + float mgm2softIronInverse[3][3] = {{0.931086, 0.172675, -0.043084}, + {0.172675, 1.541296, 0.065489}, + {-0.043084, 0.065489, 1.001238}}; + float mgm3softIronInverse[3][3] = {{1.073353, 0.177266, -0.058832}, + {0.177266, 1.262156, 0.010478}, + {-0.058832, 0.010478, 1.068345}}; + float mgm4softIronInverse[3][3] = {{1.114887, -0.007534, -0.037072}, + {-0.007534, 1.253879, 0.006812}, + {-0.037072, 0.006812, 1.313158}}; float mgm02variance[3] = {1, 1, 1}; float mgm13variance[3] = {1, 1, 1}; From d6a40487934e17c42b38bce1e7a85b6f04385e2c Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 8 Feb 2023 01:32:18 +0100 Subject: [PATCH 22/29] bump FSFW, TMTC and changelog --- CHANGELOG.md | 1 + fsfw | 2 +- tmtc | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6fee72b..ddeee97b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ change warranting a new major release: - Build system: Fixed small bug, where the version itself was stored as the git SHA hash in `commonConfig.h`. This will be an empty string now for regular versions. +- Bump FSFW for important fix in PUS mode service. # [v1.25.0] 2023-02-06 diff --git a/fsfw b/fsfw index 38789e05..84dc7ac0 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 38789e053b65cfa14604fc625e7bcc8ca03a3f17 +Subproject commit 84dc7ac0ce4f16d93a6a5a5fcd453b2fde206dba diff --git a/tmtc b/tmtc index d6445d38..f16e27b7 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit d6445d38a8eb644a5e1bd27f0fc56d29e93c030d +Subproject commit f16e27b79b9996f5a6c246cea560b783eb566d7e From 489c813bcc637bd519b0b14eb40cb625b4988224 Mon Sep 17 00:00:00 2001 From: meggert Date: Wed, 8 Feb 2023 11:05:35 +0100 Subject: [PATCH 23/29] better fit for acs::OFF with SUBMODE_NONE --- mission/acsDefs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mission/acsDefs.h b/mission/acsDefs.h index 8869d6ff..63824131 100644 --- a/mission/acsDefs.h +++ b/mission/acsDefs.h @@ -7,7 +7,7 @@ namespace acs { enum CtrlSubmode { - OFF = HasModesIF::MODE_OFF, + OFF = HasModesIF::SUBMODE_NONE, SAFE = 10, DETUMBLE = 11, IDLE = 12, From c170bff7202dca5e0fd958d68db0a52ebfb08ef9 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 8 Feb 2023 11:08:38 +0100 Subject: [PATCH 24/29] add release checklist --- CHANGELOG.md | 2 ++ CMakeLists.txt | 14 +++++++------- bsp_hosted/OBSWConfig.h.in | 1 - bsp_q7s/OBSWConfig.h.in | 1 - bsp_q7s/core/CoreController.cpp | 13 +++++++++---- bsp_q7s/core/CoreController.h | 8 ++++++++ common/config/OBSWVersion.h | 10 ---------- fsfw | 2 +- mission/system/objects/AcsSubsystem.cpp | 4 ++-- release_checklist.md | 12 ++++++++++++ unittest/rebootLogic/src/CoreController.h | 2 +- 11 files changed, 42 insertions(+), 27 deletions(-) delete mode 100644 common/config/OBSWVersion.h create mode 100644 release_checklist.md diff --git a/CHANGELOG.md b/CHANGELOG.md index ddeee97b..336fce6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,8 @@ change warranting a new major release: ## Fixed +- Single sourcing the version information into `CMakeLists.txt`. The `git describe` functionality + is only used to retrieve the git SHA hash now. Also removed `OBSWVersion.h` accordingly. - Build system: Fixed small bug, where the version itself was stored as the git SHA hash in `commonConfig.h`. This will be an empty string now for regular versions. diff --git a/CMakeLists.txt b/CMakeLists.txt index 25e63e69..f670b6f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,9 +9,9 @@ # ############################################################################## cmake_minimum_required(VERSION 3.13) -set(OBSW_VERSION_MAJOR_IF_GIT_FAILS 1) -set(OBSW_VERSION_MINOR_IF_GIT_FAILS 25) -set(OBSW_VERSION_REVISION_IF_GIT_FAILS 0) +set(OBSW_VERSION_MAJOR 1) +set(OBSW_VERSION_MINOR 25) +set(OBSW_VERSION_REVISION 0) # set(CMAKE_VERBOSE TRUE) @@ -168,12 +168,12 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git) set(GIT_INFO ${GIT_INFO} CACHE STRING "Version information retrieved with git describe") - list(GET GIT_INFO 1 OBSW_VERSION_MAJOR) - list(GET GIT_INFO 2 OBSW_VERSION_MINOR) - list(GET GIT_INFO 3 OBSW_VERSION_REVISION) + # CMakeLists.txt is now single source of information. list(GET GIT_INFO 1 + # OBSW_VERSION_MAJOR) list(GET GIT_INFO 2 OBSW_VERSION_MINOR) list(GET + # GIT_INFO 3 OBSW_VERSION_REVISION) list(LENGTH GIT_INFO LIST_LEN) if(LIST_LEN GREATER 4) - list(GET GIT_INFO 4 OBSW_VERSION_CST_GIT_SHA1) + list(GET GIT_INFO 4 OBSW_VERSION_CST_GIT_SHA1) endif() if(NOT OBSW_VERSION_MAJOR) set(OBSW_VERSION_MAJOR ${OBSW_VERSION_MAJOR_IF_GIT_FAILS}) diff --git a/bsp_hosted/OBSWConfig.h.in b/bsp_hosted/OBSWConfig.h.in index e58e534d..5e6fcc2c 100644 --- a/bsp_hosted/OBSWConfig.h.in +++ b/bsp_hosted/OBSWConfig.h.in @@ -7,7 +7,6 @@ #define FSFWCONFIG_OBSWCONFIG_H_ #include "commonConfig.h" -#include "OBSWVersion.h" /*******************************************************************/ /** All of the following flags should be enabled for mission code */ diff --git a/bsp_q7s/OBSWConfig.h.in b/bsp_q7s/OBSWConfig.h.in index 5dff001c..9273e4e9 100644 --- a/bsp_q7s/OBSWConfig.h.in +++ b/bsp_q7s/OBSWConfig.h.in @@ -8,7 +8,6 @@ #include "commonConfig.h" #include "q7sConfig.h" -#include "OBSWVersion.h" /*******************************************************************/ /** All of the following flags should be enabled for mission code */ diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 23c6cc4f..50c662d7 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -5,7 +5,7 @@ #include #include -#include "OBSWVersion.h" +#include "commonConfig.h" #include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/timemanager/Stopwatch.h" #include "fsfw/version.h" @@ -179,6 +179,11 @@ ReturnValue_t CoreController::initializeAfterTaskCreation() { ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, const uint8_t *data, size_t size) { switch (actionId) { + case (ANNOUNCE_VERSION): { + // uint32_t p1= + triggerEvent(VERSION_INFO); + return HasActionsIF::EXECUTION_FINISHED; + } case (LIST_DIRECTORY_INTO_FILE): { return actionListDirectoryIntoFile(actionId, commandedBy, data, size); } @@ -673,9 +678,9 @@ ReturnValue_t CoreController::initVersionFile() { sif::warning << "CoreController::versionFileInit: Retrieving uname line failed" << std::endl; } - std::string fullObswVersionString = "OBSW: v" + std::to_string(SW_VERSION) + "." + - std::to_string(SW_SUBVERSION) + "." + - std::to_string(SW_REVISION); + std::string fullObswVersionString = "OBSW: v" + std::to_string(common::OBSW_VERSION_MAJOR) + "." + + std::to_string(common::OBSW_VERSION_MINOR) + "." + + std::to_string(common::OBSW_VERSION_REVISION); char versionString[16] = {}; fsfw::FSFW_VERSION.getVersion(versionString, sizeof(versionString)); std::string fullFsfwVersionString = "FSFW: v" + std::string(versionString); diff --git a/bsp_q7s/core/CoreController.h b/bsp_q7s/core/CoreController.h index 4d9d5ee8..9cbc6340 100644 --- a/bsp_q7s/core/CoreController.h +++ b/bsp_q7s/core/CoreController.h @@ -74,6 +74,8 @@ class CoreController : public ExtendedControllerBase { static constexpr dur_millis_t DEFAULT_SD_CARD_CHECK_TIMEOUT = 60000; static constexpr ActionId_t LIST_DIRECTORY_INTO_FILE = 0; + static constexpr ActionId_t ANNOUNCE_VERSION = 1; + static constexpr ActionId_t ANNOUNCE_CURRENT_IMAGE = 2; static constexpr ActionId_t SWITCH_REBOOT_FILE_HANDLING = 5; static constexpr ActionId_t RESET_REBOOT_COUNTERS = 6; static constexpr ActionId_t SWITCH_IMG_LOCK = 7; @@ -109,6 +111,12 @@ class CoreController : public ExtendedControllerBase { //! [EXPORT] : [COMMENT] No SD card was active. Core controller will attempt to re-initialize //! a SD card. static constexpr Event NO_SD_CARD_ACTIVE = event::makeEvent(SUBSYSTEM_ID, 4, severity::HIGH); + //! [EXPORT] : [COMMENT] + //! P1: Byte 0: Major, Byte 1: Minor, Byte 2: Patch, Byte 3: Has Git Hash + //! P2: First four letters of Git SHA is the last byte of P1 is set. + static constexpr Event VERSION_INFO = event::makeEvent(SUBSYSTEM_ID, 5, severity::INFO); + //! [EXPORT] : [COMMENT] P1: Current Chip, P2: Current Copy + static constexpr Event CURRENT_IMAGE_INFO = event::makeEvent(SUBSYSTEM_ID, 6, severity::INFO); CoreController(object_id_t objectId); virtual ~CoreController(); diff --git a/common/config/OBSWVersion.h b/common/config/OBSWVersion.h deleted file mode 100644 index 36233c3b..00000000 --- a/common/config/OBSWVersion.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef COMMON_CONFIG_OBSWVERSION_H_ -#define COMMON_CONFIG_OBSWVERSION_H_ - -const char* const SW_NAME = "eive"; - -#define SW_VERSION 1 -#define SW_SUBVERSION 12 -#define SW_REVISION 1 - -#endif /* COMMON_CONFIG_OBSWVERSION_H_ */ diff --git a/fsfw b/fsfw index 84dc7ac0..84bbef01 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 84dc7ac0ce4f16d93a6a5a5fcd453b2fde206dba +Subproject commit 84bbef016712096147e8cf3f2cec87f317d9e7e7 diff --git a/mission/system/objects/AcsSubsystem.cpp b/mission/system/objects/AcsSubsystem.cpp index f5b8a0ce..6f7bbf7c 100644 --- a/mission/system/objects/AcsSubsystem.cpp +++ b/mission/system/objects/AcsSubsystem.cpp @@ -58,7 +58,7 @@ void AcsSubsystem::handleEventMessages() { case EventMessage::EVENT_MESSAGE: if (event.getEvent() == acs::SAFE_RATE_VIOLATION) { CommandMessage msg; - ModeMessage::setCmdModeModeMessage(msg, acs::CtrlSubmode::DETUMBLE, 0); + ModeMessage::setCmdModeMessage(msg, acs::CtrlSubmode::DETUMBLE, 0); ReturnValue_t result = commandQueue->sendMessage(commandQueue->getId(), &msg); if (result != returnvalue::OK) { sif::error << "AcsSubsystem: sending DETUMBLE mode cmd to self has failed" << std::endl; @@ -66,7 +66,7 @@ void AcsSubsystem::handleEventMessages() { } if (event.getEvent() == acs::SAFE_RATE_RECOVERY) { CommandMessage msg; - ModeMessage::setCmdModeModeMessage(msg, acs::CtrlSubmode::SAFE, 0); + ModeMessage::setCmdModeMessage(msg, acs::CtrlSubmode::SAFE, 0); ReturnValue_t result = commandQueue->sendMessage(commandQueue->getId(), &msg); if (result != returnvalue::OK) { sif::error << "AcsSubsystem: sending IDLE mode cmd to self has failed" << std::endl; diff --git a/release_checklist.md b/release_checklist.md new file mode 100644 index 00000000..b4f08165 --- /dev/null +++ b/release_checklist.md @@ -0,0 +1,12 @@ +OBSW Release Checklist +========= + +# Pre-Release + +1. Update version in `CMakeLists.txt` +2. Verify that the Q7S, Q7S EM and Host build are working +3. Wait for CI/CD results + +# Post-Release + +1. Create a new release with tag on `EGit` diff --git a/unittest/rebootLogic/src/CoreController.h b/unittest/rebootLogic/src/CoreController.h index 1846c27f..0d89b215 100644 --- a/unittest/rebootLogic/src/CoreController.h +++ b/unittest/rebootLogic/src/CoreController.h @@ -76,4 +76,4 @@ class CoreController { SdCardManager* sdcMan = nullptr; RebootFile rebootFile = {}; bool doPerformRebootFileHandling = true; -}; \ No newline at end of file +}; From d0c8c2a418104cff03084743b4b611a255023c0f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 8 Feb 2023 11:12:12 +0100 Subject: [PATCH 25/29] revert some change --- unittest/rebootLogic/src/CoreController.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unittest/rebootLogic/src/CoreController.h b/unittest/rebootLogic/src/CoreController.h index 0d89b215..1846c27f 100644 --- a/unittest/rebootLogic/src/CoreController.h +++ b/unittest/rebootLogic/src/CoreController.h @@ -76,4 +76,4 @@ class CoreController { SdCardManager* sdcMan = nullptr; RebootFile rebootFile = {}; bool doPerformRebootFileHandling = true; -}; +}; \ No newline at end of file From 37988fbfd454f9df9967ad86cee8c54a9bec7f52 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 8 Feb 2023 11:17:08 +0100 Subject: [PATCH 26/29] complete impl --- bsp_q7s/core/CoreController.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 50c662d7..d892bc74 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -180,8 +180,20 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_ const uint8_t *data, size_t size) { switch (actionId) { case (ANNOUNCE_VERSION): { - // uint32_t p1= - triggerEvent(VERSION_INFO); + uint32_t p1 = (common::OBSW_VERSION_MAJOR << 24) | (common::OBSW_VERSION_MINOR << 16) | + (common::OBSW_VERSION_REVISION << 8); + uint32_t p2 = 0; + if (strcmp("", common::OBSW_VERSION_CST_GIT_SHA1) != 0) { + p1 |= 1; + // Only copy first 4 letters of git hash + memcpy(&p2, common::OBSW_VERSION_CST_GIT_SHA1 + 3, 4); + } + + triggerEvent(VERSION_INFO, p1, p2); + return HasActionsIF::EXECUTION_FINISHED; + } + case (ANNOUNCE_CURRENT_IMAGE): { + triggerEvent(CURRENT_IMAGE_INFO, CURRENT_CHIP, CURRENT_COPY); return HasActionsIF::EXECUTION_FINISHED; } case (LIST_DIRECTORY_INTO_FILE): { From b7ec4e3b2043feebba3bb5f403443ff5727690df Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 8 Feb 2023 11:21:39 +0100 Subject: [PATCH 27/29] bump tmtc --- tmtc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tmtc b/tmtc index f16e27b7..ef42b1a1 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit f16e27b79b9996f5a6c246cea560b783eb566d7e +Subproject commit ef42b1a179c8cede6092ba328cc7baa92916c26f From de95a1ba61148e3cb51925ad9419423cdc170708 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 8 Feb 2023 11:22:57 +0100 Subject: [PATCH 28/29] add new events --- generators/bsp_q7s_events.csv | 2 ++ generators/events/translateEvents.cpp | 10 ++++++++-- generators/objects/translateObjects.cpp | 2 +- linux/fsfwconfig/events/translateEvents.cpp | 10 ++++++++-- linux/fsfwconfig/objects/translateObjects.cpp | 2 +- tmtc | 2 +- 6 files changed, 21 insertions(+), 7 deletions(-) diff --git a/generators/bsp_q7s_events.csv b/generators/bsp_q7s_events.csv index 2e39b641..b6e2cc88 100644 --- a/generators/bsp_q7s_events.csv +++ b/generators/bsp_q7s_events.csv @@ -244,3 +244,5 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path 14002;0x36b2;REBOOT_MECHANISM_TRIGGERED;MEDIUM;The reboot mechanism was triggered. P1: First 16 bits: Last Chip, Last 16 bits: Last Copy, P2: Each byte is the respective reboot count for the slots;bsp_q7s/core/CoreController.h 14003;0x36b3;REBOOT_HW;MEDIUM;;bsp_q7s/core/CoreController.h 14004;0x36b4;NO_SD_CARD_ACTIVE;HIGH;No SD card was active. Core controller will attempt to re-initialize a SD card.;bsp_q7s/core/CoreController.h +14005;0x36b5;VERSION_INFO;INFO;P1: Byte 0: Major, Byte 1: Minor, Byte 2: Patch, Byte 3: Has Git Hash P2: First four letters of Git SHA is the last byte of P1 is set.;bsp_q7s/core/CoreController.h +14006;0x36b6;CURRENT_IMAGE_INFO;INFO;P1: Current Chip, P2: Current Copy;bsp_q7s/core/CoreController.h diff --git a/generators/events/translateEvents.cpp b/generators/events/translateEvents.cpp index e810f4d1..44dc3f24 100644 --- a/generators/events/translateEvents.cpp +++ b/generators/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 245 translations. + * @brief Auto-generated event translation file. Contains 247 translations. * @details - * Generated on: 2023-02-03 10:52:53 + * Generated on: 2023-02-08 11:22:40 */ #include "translateEvents.h" @@ -245,6 +245,8 @@ const char *REBOOT_SW_STRING = "REBOOT_SW"; const char *REBOOT_MECHANISM_TRIGGERED_STRING = "REBOOT_MECHANISM_TRIGGERED"; const char *REBOOT_HW_STRING = "REBOOT_HW"; const char *NO_SD_CARD_ACTIVE_STRING = "NO_SD_CARD_ACTIVE"; +const char *VERSION_INFO_STRING = "VERSION_INFO"; +const char *CURRENT_IMAGE_INFO_STRING = "CURRENT_IMAGE_INFO"; const char *translateEvents(Event event) { switch ((event & 0xFFFF)) { @@ -728,6 +730,10 @@ const char *translateEvents(Event event) { return REBOOT_HW_STRING; case (14004): return NO_SD_CARD_ACTIVE_STRING; + case (14005): + return VERSION_INFO_STRING; + case (14006): + return CURRENT_IMAGE_INFO_STRING; default: return "UNKNOWN_EVENT"; } diff --git a/generators/objects/translateObjects.cpp b/generators/objects/translateObjects.cpp index 9707189d..873bc547 100644 --- a/generators/objects/translateObjects.cpp +++ b/generators/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 152 translations. - * Generated on: 2023-02-03 10:52:53 + * Generated on: 2023-02-08 11:22:40 */ #include "translateObjects.h" diff --git a/linux/fsfwconfig/events/translateEvents.cpp b/linux/fsfwconfig/events/translateEvents.cpp index e810f4d1..44dc3f24 100644 --- a/linux/fsfwconfig/events/translateEvents.cpp +++ b/linux/fsfwconfig/events/translateEvents.cpp @@ -1,7 +1,7 @@ /** - * @brief Auto-generated event translation file. Contains 245 translations. + * @brief Auto-generated event translation file. Contains 247 translations. * @details - * Generated on: 2023-02-03 10:52:53 + * Generated on: 2023-02-08 11:22:40 */ #include "translateEvents.h" @@ -245,6 +245,8 @@ const char *REBOOT_SW_STRING = "REBOOT_SW"; const char *REBOOT_MECHANISM_TRIGGERED_STRING = "REBOOT_MECHANISM_TRIGGERED"; const char *REBOOT_HW_STRING = "REBOOT_HW"; const char *NO_SD_CARD_ACTIVE_STRING = "NO_SD_CARD_ACTIVE"; +const char *VERSION_INFO_STRING = "VERSION_INFO"; +const char *CURRENT_IMAGE_INFO_STRING = "CURRENT_IMAGE_INFO"; const char *translateEvents(Event event) { switch ((event & 0xFFFF)) { @@ -728,6 +730,10 @@ const char *translateEvents(Event event) { return REBOOT_HW_STRING; case (14004): return NO_SD_CARD_ACTIVE_STRING; + case (14005): + return VERSION_INFO_STRING; + case (14006): + return CURRENT_IMAGE_INFO_STRING; default: return "UNKNOWN_EVENT"; } diff --git a/linux/fsfwconfig/objects/translateObjects.cpp b/linux/fsfwconfig/objects/translateObjects.cpp index 9707189d..873bc547 100644 --- a/linux/fsfwconfig/objects/translateObjects.cpp +++ b/linux/fsfwconfig/objects/translateObjects.cpp @@ -2,7 +2,7 @@ * @brief Auto-generated object translation file. * @details * Contains 152 translations. - * Generated on: 2023-02-03 10:52:53 + * Generated on: 2023-02-08 11:22:40 */ #include "translateObjects.h" diff --git a/tmtc b/tmtc index ef42b1a1..dedfe1c9 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit ef42b1a179c8cede6092ba328cc7baa92916c26f +Subproject commit dedfe1c977fbe47a2d6a50e56e01eed9fe48b869 From 02f03495259c09e1ab70e402bfe852c9852643f7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 8 Feb 2023 11:53:20 +0100 Subject: [PATCH 29/29] done --- bsp_q7s/core/CoreController.cpp | 5 ++++- tmtc | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index d892bc74..116b4fc9 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -185,8 +185,11 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_ uint32_t p2 = 0; if (strcmp("", common::OBSW_VERSION_CST_GIT_SHA1) != 0) { p1 |= 1; + auto shaAsStr = std::string(common::OBSW_VERSION_CST_GIT_SHA1); + size_t posDash = shaAsStr.find("-"); + auto gitHash = shaAsStr.substr(posDash + 2, 4); // Only copy first 4 letters of git hash - memcpy(&p2, common::OBSW_VERSION_CST_GIT_SHA1 + 3, 4); + memcpy(&p2, gitHash.c_str(), 4); } triggerEvent(VERSION_INFO, p1, p2); diff --git a/tmtc b/tmtc index dedfe1c9..4086e794 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit dedfe1c977fbe47a2d6a50e56e01eed9fe48b869 +Subproject commit 4086e7947b4458bcbbd47c78e67c23d3a47885c8