From fd4be08796cc1b1e94f2b00d8b623416c905098a Mon Sep 17 00:00:00 2001 From: meggert Date: Mon, 27 Feb 2023 16:37:09 +0100 Subject: [PATCH] removed instance of AcsParameters as part of actuatorCmd --- mission/controller/acs/ActuatorCmd.cpp | 25 ++++++++++++++----------- mission/controller/acs/ActuatorCmd.h | 12 +++++++----- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/mission/controller/acs/ActuatorCmd.cpp b/mission/controller/acs/ActuatorCmd.cpp index 8cda84d6..7ea6d567 100644 --- a/mission/controller/acs/ActuatorCmd.cpp +++ b/mission/controller/acs/ActuatorCmd.cpp @@ -10,13 +10,14 @@ #include "util/CholeskyDecomposition.h" #include "util/MathOperations.h" -ActuatorCmd::ActuatorCmd(AcsParameters *acsParameters_) { acsParameters = *acsParameters_; } +ActuatorCmd::ActuatorCmd() {} ActuatorCmd::~ActuatorCmd() {} -void ActuatorCmd::scalingTorqueRws(const double *rwTrq, double *rwTrqScaled) { +void ActuatorCmd::scalingTorqueRws(const double *rwTrq, double *rwTrqScaled, + AcsParameters::RwHandlingParameters *rwHandlingParameters) { // Scaling the commanded torque to a maximum value - double maxTrq = acsParameters.rwHandlingParameters.maxTrq; + double maxTrq = rwHandlingParameters->maxTrq; double maxValue = 0; for (int i = 0; i < 4; i++) { // size of torque, always 4 ? @@ -33,17 +34,17 @@ void ActuatorCmd::scalingTorqueRws(const double *rwTrq, double *rwTrqScaled) { void ActuatorCmd::cmdSpeedToRws(const int32_t speedRw0, const int32_t speedRw1, const int32_t speedRw2, const int32_t speedRw3, - const double *rwTorque, int32_t *rwCmdSpeed) { + const double *rwTorque, int32_t *rwCmdSpeed, + AcsParameters *acsParameters) { using namespace Math; // Calculating the commanded speed in RPM for every reaction wheel int32_t speedRws[4] = {speedRw0, speedRw1, speedRw2, speedRw3}; double deltaSpeed[4] = {0, 0, 0, 0}; - double commandTime = acsParameters.onBoardParams.sampleTime, - inertiaWheel = acsParameters.rwHandlingParameters.inertiaWheel; double radToRpm = 60 / (2 * PI); // factor for conversion to RPM // W_RW = Torque_RW / I_RW * delta t [rad/s] - double factor = commandTime / inertiaWheel * radToRpm; + double factor = acsParameters->onBoardParams.sampleTime / + acsParameters->rwHandlingParameters.inertiaWheel * radToRpm; int32_t deltaSpeedInt[4] = {0, 0, 0, 0}; VectorOperations::mulScalar(rwTorque, factor, deltaSpeed, 4); for (int i = 0; i < 4; i++) { @@ -53,13 +54,15 @@ void ActuatorCmd::cmdSpeedToRws(const int32_t speedRw0, const int32_t speedRw1, VectorOperations::mulScalar(rwCmdSpeed, 10, rwCmdSpeed, 4); } -void ActuatorCmd::cmdDipolMtq(const double *dipolMoment, int16_t *dipolMomentActuator) { +void ActuatorCmd::cmdDipolMtq(const double *dipolMoment, int16_t *dipolMomentActuator, + AcsParameters::MagnetorquerParameter *magnetorquerParameter) { + sif::debug << magnetorquerParameter->dipolMax << std::endl; // Convert to actuator frame double dipolMomentActuatorDouble[3] = {0, 0, 0}; - MatrixOperations::multiply(*acsParameters.magnetorquesParameter.inverseAlignment, - dipolMoment, dipolMomentActuatorDouble, 3, 3, 1); + MatrixOperations::multiply(*magnetorquerParameter->inverseAlignment, dipolMoment, + dipolMomentActuatorDouble, 3, 3, 1); // Scaling along largest element if dipol exceeds maximum - double maxDipol = acsParameters.magnetorquesParameter.DipolMax; + double maxDipol = magnetorquerParameter->dipolMax; double maxValue = 0; for (int i = 0; i < 3; i++) { if (abs(dipolMomentActuator[i]) > maxDipol) { diff --git a/mission/controller/acs/ActuatorCmd.h b/mission/controller/acs/ActuatorCmd.h index 969bd782..ca0deb5b 100644 --- a/mission/controller/acs/ActuatorCmd.h +++ b/mission/controller/acs/ActuatorCmd.h @@ -8,7 +8,7 @@ class ActuatorCmd { public: - ActuatorCmd(AcsParameters *acsParameters_); // Input mode ? + ActuatorCmd(); // Input mode ? virtual ~ActuatorCmd(); /* @@ -17,7 +17,8 @@ class ActuatorCmd { * @param: rwTrq given torque for reaction wheels * rwTrqScaled possible scaled torque */ - void scalingTorqueRws(const double *rwTrq, double *rwTrqScaled); + void scalingTorqueRws(const double *rwTrq, double *rwTrqScaled, + AcsParameters::RwHandlingParameters *rwHandlingParameters); /* * @brief: cmdSpeedToRws() will set the maximum possible torque for the reaction @@ -29,7 +30,8 @@ class ActuatorCmd { * reaction wheel */ void cmdSpeedToRws(const int32_t speedRw0, const int32_t speedRw1, const int32_t speedRw2, - const int32_t speedRw3, const double *rwTorque, int32_t *rwCmdSpeed); + const int32_t speedRw3, const double *rwTorque, int32_t *rwCmdSpeed, + AcsParameters *acsParameters); /* * @brief: cmdDipolMtq() gives the commanded dipol moment for the magnetorques @@ -37,11 +39,11 @@ class ActuatorCmd { * @param: dipolMoment given dipol moment in spacecraft frame * dipolMomentActuator resulting dipol moment in actuator reference frame */ - void cmdDipolMtq(const double *dipolMoment, int16_t *dipolMomentActuator); + void cmdDipolMtq(const double *dipolMoment, int16_t *dipolMomentActuator, + AcsParameters::MagnetorquerParameter *magnetorquerParameter); protected: private: - AcsParameters acsParameters; }; #endif /* ACTUATORCMD_H_ */