scale dipole of controller to by the MTQ expected range
Some checks are pending
EIVE/eive-obsw/pipeline/head Build started...
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
Marius Eggert 2023-02-02 10:47:58 +01:00
parent acba821afd
commit 4bed0fd563
2 changed files with 11 additions and 10 deletions

View File

@ -54,21 +54,22 @@ void ActuatorCmd::cmdSpeedToRws(const int32_t *speedRw0, const int32_t *speedRw1
VectorOperations<double>::add(speedRws, deltaSpeed, rwCmdSpeed, 4); VectorOperations<double>::add(speedRws, deltaSpeed, rwCmdSpeed, 4);
} }
void ActuatorCmd::cmdDipolMtq(const double *dipolMoment, double *dipolMomentUnits) { void ActuatorCmd::cmdDipolMtq(const double *dipolMoment, double *dipolMomentActuator) {
// Convert to Unit frame // Convert to actuator frame
MatrixOperations<double>::multiply(*acsParameters.magnetorquesParameter.inverseAlignment, MatrixOperations<double>::multiply(*acsParameters.magnetorquesParameter.inverseAlignment,
dipolMoment, dipolMomentUnits, 3, 3, 1); dipolMoment, dipolMomentActuator, 3, 3, 1);
// Scaling along largest element if dipol exceeds maximum // Scaling along largest element if dipol exceeds maximum
double maxDipol = acsParameters.magnetorquesParameter.DipolMax; double maxDipol = acsParameters.magnetorquesParameter.DipolMax;
double maxValue = 0; double maxValue = 0;
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
if (abs(dipolMomentUnits[i]) > maxDipol) { if (abs(dipolMomentActuator[i]) > maxDipol) {
maxValue = abs(dipolMomentUnits[i]); maxValue = abs(dipolMomentActuator[i]);
} }
} }
if (maxValue > maxDipol) { if (maxValue > maxDipol) {
double scalingFactor = maxDipol / maxValue; double scalingFactor = maxDipol / maxValue;
VectorOperations<double>::mulScalar(dipolMomentUnits, scalingFactor, dipolMomentUnits, 3); VectorOperations<double>::mulScalar(dipolMomentActuator, scalingFactor, dipolMomentActuator, 3);
} }
// scale dipole from 1 Am^2 to 1e^-4 Am^2
VectorOperations<double>::mulScalar(dipolMomentActuator, 1e4, dipolMomentActuator, 3);
} }

View File

@ -35,9 +35,9 @@ class ActuatorCmd {
* @brief: cmdDipolMtq() gives the commanded dipol moment for the magnetorques * @brief: cmdDipolMtq() gives the commanded dipol moment for the magnetorques
* *
* @param: dipolMoment given dipol moment in spacecraft frame * @param: dipolMoment given dipol moment in spacecraft frame
* dipolMomentUnits resulting dipol moment for every unit * dipolMomentActuator resulting dipol moment in actuator reference frame
*/ */
void cmdDipolMtq(const double *dipolMoment, double *dipolMomentUnits); void cmdDipolMtq(const double *dipolMoment, double *dipolMomentActuator);
protected: protected:
private: private: