From b9e4c51d826471635f2aeced2012218e9d0ba231 Mon Sep 17 00:00:00 2001 From: meggert Date: Tue, 13 Feb 2024 16:59:50 +0100 Subject: [PATCH] set stuff const that should be const --- mission/controller/acs/Guidance.cpp | 35 ++++++++++++++--------------- mission/controller/acs/Guidance.h | 9 ++++---- 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/mission/controller/acs/Guidance.cpp b/mission/controller/acs/Guidance.cpp index 7a630eef..cc0a20d9 100644 --- a/mission/controller/acs/Guidance.cpp +++ b/mission/controller/acs/Guidance.cpp @@ -36,9 +36,9 @@ void Guidance::targetQuatPtgIdle(timeval timeAbsolute, const double timeDelta, targetRotationRate(timeDelta, targetQuat, targetSatRotRate); } -void Guidance::targetQuatPtgTarget(timeval timeAbsolute, const double timeDelta, double posSatF[3], - double velSatF[3], double targetQuat[4], - double targetSatRotRate[3]) { +void Guidance::targetQuatPtgTarget(timeval timeAbsolute, const double timeDelta, + const double posSatF[3], const double velSatF[3], + double targetQuat[4], double targetSatRotRate[3]) { //------------------------------------------------------------------------------------- // Calculation of target quaternion for target pointing //------------------------------------------------------------------------------------- @@ -115,18 +115,16 @@ void Guidance::targetQuatPtgGs(timeval timeAbsolute, const double timeDelta, VectorOperations::normalize(groundStationDirI, xAxisIX, 3); VectorOperations::mulScalar(xAxisIX, -1, xAxisIX, 3); - // normalize sun vector in ECI - double sunDirNormalizedI[3] = {0, 0, 0}; // get earth vector in ECI - double earthDirNormalizedI[3] = {0, 0, 0}; - VectorOperations::normalize(posSatI, earthDirNormalizedI, 3); - VectorOperations::mulScalar(earthDirNormalizedI, -1, earthDirNormalizedI, 3); + double earthDirI[3] = {0, 0, 0}; + VectorOperations::normalize(posSatI, earthDirI, 3); + VectorOperations::mulScalar(earthDirI, -1, earthDirI, 3); // sun avoidance calculations double sunPerpendicularX[3] = {0, 0, 0}, sunFloorYZ[3] = {0, 0, 0}; - VectorOperations::mulScalar( - xAxisIX, VectorOperations::dot(xAxisIX, sunDirNormalizedI), sunPerpendicularX, 3); - VectorOperations::subtract(sunDirNormalizedI, sunPerpendicularX, sunFloorYZ, 3); + VectorOperations::mulScalar(xAxisIX, VectorOperations::dot(xAxisIX, sunDirI), + sunPerpendicularX, 3); + VectorOperations::subtract(sunDirI, sunPerpendicularX, sunFloorYZ, 3); VectorOperations::normalize(sunFloorYZ, sunFloorYZ, 3); double sunWeight = 0, strVecSun[3] = {0, 0, 0}, strVecSunX[3] = {0, 0, 0}, strVecSunZ[3] = {0, 0, 0}; @@ -136,13 +134,13 @@ void Guidance::targetQuatPtgGs(timeval timeAbsolute, const double timeDelta, strVecSunZ, 3); VectorOperations::add(strVecSunX, strVecSunZ, strVecSun, 3); VectorOperations::normalize(strVecSun, strVecSun, 3); - sunWeight = VectorOperations::dot(strVecSun, sunDirNormalizedI); + sunWeight = VectorOperations::dot(strVecSun, sunDirI); // earth avoidance calculations double earthPerpendicularX[3] = {0, 0, 0}, earthFloorYZ[3] = {0, 0, 0}; - VectorOperations::mulScalar( - xAxisIX, VectorOperations::dot(xAxisIX, earthDirNormalizedI), earthPerpendicularX, 3); - VectorOperations::subtract(earthDirNormalizedI, earthPerpendicularX, earthFloorYZ, 3); + VectorOperations::mulScalar(xAxisIX, VectorOperations::dot(xAxisIX, earthDirI), + earthPerpendicularX, 3); + VectorOperations::subtract(earthDirI, earthPerpendicularX, earthFloorYZ, 3); VectorOperations::normalize(earthFloorYZ, earthFloorYZ, 3); double earthWeight = 0, strVecEarth[3] = {0, 0, 0}, strVecEarthX[3] = {0, 0, 0}, strVecEarthZ[3] = {0, 0, 0}; @@ -152,7 +150,7 @@ void Guidance::targetQuatPtgGs(timeval timeAbsolute, const double timeDelta, strVecEarthZ, 3); VectorOperations::add(strVecEarthX, strVecEarthZ, strVecEarth, 3); VectorOperations::normalize(strVecEarth, strVecEarth, 3); - earthWeight = VectorOperations::dot(strVecEarth, earthDirNormalizedI); + earthWeight = VectorOperations::dot(strVecEarth, earthDirI); if ((sunWeight == 0.0) and (earthWeight == 0.0)) { // if this actually ever happens i will eat a broom @@ -187,8 +185,9 @@ void Guidance::targetQuatPtgGs(timeval timeAbsolute, const double timeDelta, targetRotationRate(timeDelta, targetQuat, targetSatRotRate); } -void Guidance::targetQuatPtgNadir(timeval timeAbsolute, const double timeDelta, double posSatE[3], - double velSatE[3], double targetQuat[4], double refSatRate[3]) { +void Guidance::targetQuatPtgNadir(timeval timeAbsolute, const double timeDelta, + const double posSatE[3], const double velSatE[3], + double targetQuat[4], double refSatRate[3]) { //------------------------------------------------------------------------------------- // Calculation of target quaternion for Nadir pointing //------------------------------------------------------------------------------------- diff --git a/mission/controller/acs/Guidance.h b/mission/controller/acs/Guidance.h index 6fbce0a4..5284ba01 100644 --- a/mission/controller/acs/Guidance.h +++ b/mission/controller/acs/Guidance.h @@ -9,7 +9,6 @@ #include #include #include -#include #include #include @@ -26,12 +25,12 @@ class Guidance { void targetQuatPtgIdle(timeval timeAbsolute, const double timeDelta, const double sunDirI[3], const double posSatF[4], double targetQuat[4], double targetSatRotRate[3]); - void targetQuatPtgTarget(timeval timeAbsolute, const double timeDelta, double posSatF[3], - double velSatE[3], double quatIX[4], double targetSatRotRate[3]); + void targetQuatPtgTarget(timeval timeAbsolute, const double timeDelta, const double posSatF[3], + const double velSatE[3], double quatIX[4], double targetSatRotRate[3]); void targetQuatPtgGs(timeval timeAbsolute, const double timeDelta, const double posSatF[3], const double sunDirI[3], double quatIX[4], double targetSatRotRate[3]); - void targetQuatPtgNadir(timeval timeAbsolute, const double timeDelta, double posSatF[3], - double velSatF[3], double targetQuat[4], double refSatRate[3]); + void targetQuatPtgNadir(timeval timeAbsolute, const double timeDelta, const double posSatF[3], + const double velSatF[3], double targetQuat[4], double refSatRate[3]); void targetRotationRate(const double timeDelta, double quatInertialTarget[4], double *targetSatRotRate);