First Version of ACS Controller #329

Merged
muellerr merged 106 commits from acs-ctrl-v1 into develop 2022-12-02 16:21:58 +01:00
3 changed files with 47 additions and 32 deletions
Showing only changes of commit 0a5bd6ef73 - Show all commits

View File

@ -226,6 +226,9 @@ AcsParameters::~AcsParameters() {}
case 0x3: case 0x3:
parameterWrapper->set(gyrHandlingParameters.gyr3orientationMatrix); parameterWrapper->set(gyrHandlingParameters.gyr3orientationMatrix);
break; break;
case 0x4:
parameterWrapper->set(gyrHandlingParameters.gyrFusionWeight);
break;
default: default:
return INVALID_IDENTIFIER_ID; return INVALID_IDENTIFIER_ID;
} }

View File

@ -753,6 +753,7 @@ class AcsParameters /*: public HasParametersIF*/ {
double gyr1orientationMatrix[3][3] = {{0, 0, -1}, {0, 1, 0}, {1, 0, 0}}; double gyr1orientationMatrix[3][3] = {{0, 0, -1}, {0, 1, 0}, {1, 0, 0}};
double gyr2orientationMatrix[3][3] = {{0, 0, -1}, {0, -1, 0}, {-1, 0, 0}}; double gyr2orientationMatrix[3][3] = {{0, 0, -1}, {0, -1, 0}, {-1, 0, 0}};
double gyr3orientationMatrix[3][3] = {{0, 0, -1}, {0, 1, 0}, {1, 0, 0}}; double gyr3orientationMatrix[3][3] = {{0, 0, -1}, {0, 1, 0}, {1, 0, 0}};
float gyrFusionWeight = 0.8;
} gyrHandlingParameters; } gyrHandlingParameters;
struct RwHandlingParameters { struct RwHandlingParameters {

View File

@ -1,10 +1,3 @@
/*
* SensorProcessing.cpp
*
* Created on: 7 Mar 2022
* Author: Robin Marquardt
*/
#include "SensorProcessing.h" #include "SensorProcessing.h"
#include <fsfw/globalfunctions/constants.h> #include <fsfw/globalfunctions/constants.h>
@ -397,59 +390,77 @@ void SensorProcessing::processGyr(
gyr3ValueBody[3] = {0, 0, 0}; gyr3ValueBody[3] = {0, 0, 0};
bool validUnit[4] = {false, false, false, false}; bool validUnit[4] = {false, false, false, false};
uint8_t validCount = 0;
if (gyr0axXvalid && gyr0axYvalid && gyr0axZvalid) { if (gyr0axXvalid && gyr0axYvalid && gyr0axZvalid) {
const double gyr0Value[3] = {gyr0axXvalue, gyr0axYvalue, gyr0axZvalue}; const double gyr0Value[3] = {gyr0axXvalue, gyr0axYvalue, gyr0axZvalue};
MatrixOperations<double>::multiply(gyrParameters->gyr0orientationMatrix[0], gyr0Value, MatrixOperations<double>::multiply(gyrParameters->gyr0orientationMatrix[0], gyr0Value,
gyr0ValueBody, 3, 3, 1); gyr0ValueBody, 3, 3, 1);
validCount += 1;
validUnit[0] = true; validUnit[0] = true;
} }
if (gyr1axXvalid && gyr1axYvalid && gyr1axZvalid) { if (gyr1axXvalid && gyr1axYvalid && gyr1axZvalid) {
const double gyr1Value[3] = {gyr1axXvalue, gyr1axYvalue, gyr1axZvalue}; const double gyr1Value[3] = {gyr1axXvalue, gyr1axYvalue, gyr1axZvalue};
MatrixOperations<double>::multiply(gyrParameters->gyr1orientationMatrix[0], gyr1Value, MatrixOperations<double>::multiply(gyrParameters->gyr1orientationMatrix[0], gyr1Value,
gyr1ValueBody, 3, 3, 1); gyr1ValueBody, 3, 3, 1);
validCount += 1;
validUnit[1] = true; validUnit[1] = true;
} }
if (gyr2axXvalid && gyr2axYvalid && gyr2axZvalid) { if (gyr2axXvalid && gyr2axYvalid && gyr2axZvalid) {
const double gyr2Value[3] = {gyr2axXvalue, gyr2axYvalue, gyr2axZvalue}; const double gyr2Value[3] = {gyr2axXvalue, gyr2axYvalue, gyr2axZvalue};
MatrixOperations<double>::multiply(gyrParameters->gyr2orientationMatrix[0], gyr2Value, MatrixOperations<double>::multiply(gyrParameters->gyr2orientationMatrix[0], gyr2Value,
gyr2ValueBody, 3, 3, 1); gyr2ValueBody, 3, 3, 1);
validCount += 1;
validUnit[2] = true; validUnit[2] = true;
} }
if (gyr3axXvalid && gyr3axYvalid && gyr3axZvalid) { if (gyr3axXvalid && gyr3axYvalid && gyr3axZvalid) {
const double gyr3Value[3] = {gyr3axXvalue, gyr3axYvalue, gyr3axZvalue}; const double gyr3Value[3] = {gyr3axXvalue, gyr3axYvalue, gyr3axZvalue};
MatrixOperations<double>::multiply(gyrParameters->gyr3orientationMatrix[0], gyr3Value, MatrixOperations<double>::multiply(gyrParameters->gyr3orientationMatrix[0], gyr3Value,
gyr3ValueBody, 3, 3, 1); gyr3ValueBody, 3, 3, 1);
validCount += 1;
validUnit[3] = true; validUnit[3] = true;
} }
/* -------- SatRateEst: Middle Value ------- */ /* -------- SatRateEst: Middle Value ------- */
double gyrValues[3][4] = { // take ADIS measurements, if both avail
{gyr0ValueBody[0], gyr1ValueBody[0], gyr2ValueBody[0], gyr3ValueBody[0]}, // if just one ADIS measurement avail, perform sensor fusion
{gyr0ValueBody[1], gyr1ValueBody[1], gyr2ValueBody[1], gyr3ValueBody[1]}, if (validUnit[0] && validUnit[2]) {
{gyr0ValueBody[2], gyr1ValueBody[2], gyr2ValueBody[2], gyr3ValueBody[2]}}; double gyr02ValuesSum[3];
double gyrValidValues[3][validCount]; VectorOperations<double>::add(gyr0ValueBody, gyr2ValueBody, gyr02ValuesSum, 3);
uint8_t j = 0; VectorOperations<double>::mulScalar(gyr02ValuesSum, .5, satRatEst, 3);
for (uint8_t i = 0; i < validCount; i++) { } else if ((validUnit[0] || validUnit[2]) && !(validUnit[1] || validUnit[3])) {
if (validUnit[i]) { if (validUnit[0]) {
gyrValidValues[0][j] = gyrValues[0][i]; satRatEst = gyr0ValueBody;
gyrValidValues[1][j] = gyrValues[1][i]; } else if (validUnit[2]) {
gyrValidValues[2][j] = gyrValues[2][i]; satRatEst = gyr2ValueBody;
j += 1;
} }
} } else if ((validUnit[1]) && (validUnit[3])) {
// Selection Sort double gyr13ValuesSum[3];
double gyrValidValuesSort[3][validCount]; double gyr13ValuesMean[3];
MathOperations<double>::selectionSort(*gyrValidValues, *gyrValidValuesSort, 3, validCount); VectorOperations<double>::add(gyr1ValueBody, gyr3ValueBody, gyr13ValuesSum, 3);
VectorOperations<double>::mulScalar(gyr13ValuesSum, .5, gyr13ValuesMean, 3);
if (validUnit[0]) {
satRatEst[0] = (1 - gyrParameters->gyrFusionWeight) * gyrParameters->gyrFusionWeight *
gyr13ValuesMean[0] +
gyrParameters->gyrFusionWeight * gyr0ValueBody[0];
satRatEst[1] = (1 - gyrParameters->gyrFusionWeight) * gyrParameters->gyrFusionWeight *
gyr13ValuesMean[1] +
gyrParameters->gyrFusionWeight * gyr0ValueBody[1];
satRatEst[2] = (1 - gyrParameters->gyrFusionWeight) * gyrParameters->gyrFusionWeight *
gyr13ValuesMean[2] +
gyrParameters->gyrFusionWeight * gyr0ValueBody[2];
uint8_t n = ceil(validCount / 2); } else if (validUnit[2]) {
satRatEst[0] = gyrValidValuesSort[0][n]; satRatEst[0] = (1 - gyrParameters->gyrFusionWeight) * gyrParameters->gyrFusionWeight *
satRatEst[1] = gyrValidValuesSort[1][n]; gyr13ValuesMean[0] +
satRatEst[2] = gyrValidValuesSort[2][n]; gyrParameters->gyrFusionWeight * gyr2ValueBody[0];
satRatEst[1] = (1 - gyrParameters->gyrFusionWeight) * gyrParameters->gyrFusionWeight *
gyr13ValuesMean[1] +
gyrParameters->gyrFusionWeight * gyr2ValueBody[1];
satRatEst[2] = (1 - gyrParameters->gyrFusionWeight) * gyrParameters->gyrFusionWeight *
gyr13ValuesMean[2] +
gyrParameters->gyrFusionWeight * gyr2ValueBody[2];
} else
satRatEst = gyr13ValuesMean;
} else if (validUnit[1]) {
satRatEst = gyr1ValueBody;
} else if (validUnit[3]) {
satRatEst = gyr3ValueBody;
}
*satRateEstValid = true; *satRateEstValid = true;
} }