fixed scaling of mtq dipole commands

This commit is contained in:
Marius Eggert 2023-03-07 13:53:46 +01:00
parent 903c0c8258
commit fd405e61a4

View File

@ -55,14 +55,11 @@ void ActuatorCmd::cmdDipolMtq(const double *dipolMoment, int16_t *dipolMomentAct
MatrixOperations<double>::multiply(inverseAlignment, dipolMoment, dipolMomentActuatorDouble, 3, 3, MatrixOperations<double>::multiply(inverseAlignment, dipolMoment, dipolMomentActuatorDouble, 3, 3,
1); 1);
// Scaling along largest element if dipol exceeds maximum // Scaling along largest element if dipol exceeds maximum
double maxValue = 0; uint8_t maxIdx = 0;
for (int i = 0; i < 3; i++) { VectorOperations<double>::maxAbsValue(dipolMomentActuatorDouble, 3, &maxIdx);
if (abs(dipolMomentActuator[i]) > maxDipol) { double maxAbsValue = abs(dipolMomentActuatorDouble[maxIdx]);
maxValue = abs(dipolMomentActuator[i]); if (maxAbsValue > maxDipol) {
} double scalingFactor = maxDipol / maxAbsValue;
}
if (maxValue > maxDipol) {
double scalingFactor = maxDipol / maxValue;
VectorOperations<double>::mulScalar(dipolMomentActuatorDouble, scalingFactor, VectorOperations<double>::mulScalar(dipolMomentActuatorDouble, scalingFactor,
dipolMomentActuatorDouble, 3); dipolMomentActuatorDouble, 3);
} }