Prevent STR Blinding #859

Merged
meggert merged 35 commits from prevent-str-blinding into main 2024-02-27 13:48:20 +01:00
2 changed files with 24 additions and 13 deletions
Showing only changes of commit 75654277b2 - Show all commits

View File

@ -915,7 +915,7 @@ class AcsParameters : public HasParametersIF {
struct StrParameters {
double exclusionAngle = 20. * DEG2RAD;
double boresightAxis[3] = {0.7593, 0.0000, -0.6508}; // geometry frame
double boresightAxis[3] = {0.7593, 0.0000, -0.6508}; // body rf
} strParameters;
struct GpsParameters {

View File

@ -102,8 +102,8 @@ void Guidance::targetQuatPtgGs(timeval timeAbsolute, const double timeDelta,
acsParameters->gsTargetModeControllerParameters.altitudeTgt, posGroundStationF);
// target direction in the ECI frame
double posSatI[3] = {2030378.44284257, -56784.9332372798, 6567201.63882364},
posGroundStationI[3] = {3693004.40032203, -2049075.29966484, 4764086.46806924},
double posSatI[3] = {3808618.68633079, -1163140.41530084, 5612341.3560814},
posGroundStationI[3] = {3737093.20736689, -1967773.50625331, 4763980.76688758},
groundStationDirI[3] = {0, 0, 0};
// CoordinateTransformations::positionEcfToEci(posSatF, posSatI, &timeAbsolute);
// CoordinateTransformations::positionEcfToEci(posGroundStationF, posGroundStationI,
@ -187,6 +187,8 @@ void Guidance::targetQuatPtgGs(timeval timeAbsolute, const double timeDelta,
limitReferenceRotation(xAxisIX, targetQuat);
targetRotationRate(timeDelta, targetQuat, targetSatRotRate);
std::memcpy(xAxisIXprev, xAxisIX, sizeof(xAxisIXprev));
}
void Guidance::targetQuatPtgNadir(timeval timeAbsolute, const double timeDelta,
@ -239,6 +241,10 @@ void Guidance::targetRotationRate(const double timeDelta, double quatIX[4], doub
}
void Guidance::limitReferenceRotation(const double xAxisIX[3], double quatIX[4]) {
sif::debug << "xAxisIX = [" << xAxisIX[0] << " " << xAxisIX[1] << " " << xAxisIX[2] << "]"
<< std::endl;
sif::debug << "quatIX = [" << quatIX[3] << " " << quatIX[0] << " " << quatIX[1] << " "
<< quatIX[2] << "]" << std::endl;
if ((VectorOperations<double>::norm(quatIXprev, 4) == 0) or
(VectorOperations<double>::norm(xAxisIXprev, 3) == 0)) {
return;
@ -247,10 +253,11 @@ void Guidance::limitReferenceRotation(const double xAxisIX[3], double quatIX[4])
// check required rotation and return if below limit
double quatXprevX[4] = {0, 0, 0, 0}, quatXprevI[4] = {0, 0, 0, 0};
QuaternionOperations::inverse(quatIXprev, quatXprevI);
QuaternionOperations::multiply(quatXprevI, quatIX, quatXprevX);
double phiMax = acsParameters->gsTargetModeControllerParameters.omMax *
acsParameters->onBoardParams.sampleTime;
if (std::acos(quatXprevX[3]) < phiMax) {
QuaternionOperations::multiply(quatIX, quatXprevI, quatXprevX);
QuaternionOperations::normalize(quatXprevX);
double phiMax = acsParameters->gsTargetModeControllerParameters.omMax * 1;
// acsParameters->onBoardParams.sampleTime;
if (2 * std::acos(quatXprevX[3]) < phiMax) {
return;
}
@ -263,14 +270,16 @@ void Guidance::limitReferenceRotation(const double xAxisIX[3], double quatIX[4])
VectorOperations<double>::normalize(phiXvec, phiXvec, 3);
double quatXprevXtilde[4] = {0, 0, 0, 0}, quatIXtilde[4] = {0, 0, 0, 0};
VectorOperations<double>::mulScalar(phiXvec, std::cos(phiX / 2.), phiXvec, 3);
VectorOperations<double>::mulScalar(phiXvec, -std::sin(phiX / 2.), phiXvec, 3);
std::memcpy(quatXprevXtilde, phiXvec, sizeof(phiXvec));
quatXprevXtilde[3] = cos(phiX / 2.);
QuaternionOperations::multiply(quatIXprev, quatXprevXtilde, quatIXtilde);
QuaternionOperations::normalize(quatXprevXtilde);
QuaternionOperations::multiply(quatXprevXtilde, quatIXprev, quatIXtilde);
// use the residual rotation up to the maximum
double quatXXtilde[4] = {0, 0, 0, 0}, quatXI[4] = {0, 0, 0, 0};
QuaternionOperations::multiply(quatXI, quatIXtilde, quatXXtilde);
QuaternionOperations::inverse(quatIX, quatXI);
QuaternionOperations::multiply(quatIXtilde, quatXI, quatXXtilde);
double phiResidual = 0, phiResidualVec[3] = {0, 0, 0};
phiResidual = std::sqrt((phiMax * phiMax) - (phiX * phiX));
@ -278,14 +287,16 @@ void Guidance::limitReferenceRotation(const double xAxisIX[3], double quatIX[4])
VectorOperations<double>::normalize(phiResidualVec, phiResidualVec, 3);
double quatXhatXTilde[4] = {0, 0, 0, 0}, quatXTildeXhat[4] = {0, 0, 0, 0};
VectorOperations<double>::mulScalar(phiResidualVec, std::cos(phiResidual / 2.), phiResidualVec,
VectorOperations<double>::mulScalar(phiResidualVec, std::sin(phiResidual / 2.), phiResidualVec,
3);
std::memcpy(quatXhatXTilde, phiResidualVec, sizeof(phiResidualVec));
quatXhatXTilde[3] = cos(phiResidual / 2.);
quatXhatXTilde[3] = std::cos(phiResidual / 2.);
QuaternionOperations::normalize(quatXhatXTilde);
// calculate final quaternion
QuaternionOperations::inverse(quatXhatXTilde, quatXTildeXhat);
QuaternionOperations::multiply(quatIXtilde, quatXTildeXhat, quatIX);
QuaternionOperations::multiply(quatXTildeXhat, quatIXtilde, quatIX);
QuaternionOperations::normalize(quatIX);
}
void Guidance::comparePtg(double currentQuat[4], double currentSatRotRate[3], double targetQuat[4],