Arduino_Unconstrained_MPC_Library
Arduino_Unconstrained_MPC_Library copied to clipboard
Matrix size problem (3rd implementation)
trafficstars
In the third implementation (the numerically robust one), R_L matrix is defined with a size of {(MPC_HP_LEN*SS_Z_LEN + MPC_HU_LEN*SS_U_LEN), MPC_HP_LEN*SS_Z_LEN}.
But R_L is multiplied with dU(k)_optimal during the problem formulation. As dU(k)_optimal has a size of {MPC_HU_LEN*SS_U_LEN,1}, the R_L matrix should have a size of {(MPC_HP_LEN*SS_Z_LEN + MPC_HU_LEN*SS_U_LEN), MPC_HU_LEN*SS_U_LEN}.
This size is confirmed by the fact that GammaLeft is (SQ*CTHETA) over SR :
SQhas a size of{MPC_HP_LEN*SS_Z_LEN, MPC_HP_LEN*SS_Z_LEN}CTHETAhas a size of{MPC_HP_LEN*SS_Z_LEN, MPC_HU_LEN*SS_U_LEN}- Thus,
SQ*CTHETAhas a size of{MPC_HP_LEN*SS_Z_LEN, MPC_HU_LEN*SS_U_LEN} SRhas a size of{MPC_HU_LEN*SS_U_LEN, MPC_HU_LEN*SS_U_LEN}- Therefore
(SQ*CTHETA)overSRhas a size of{(MPC_HP_LEN*SS_Z_LEN + MPC_HU_LEN*SS_U_LEN), MPC_HU_LEN*SS_U_LEN} Q_L * R_L = GammaLeft, so the number of columns ofR_Lis the number of columns ofGammaLeft, which isMPC_HU_LEN*SS_U_LENand notMPC_HP_LEN*SS_Z_LEN
In your model, it does not seem to be an issue because MPC_HU_LEN*SS_U_LEN is 8 and MPC_HP_LEN*SS_Z_LEN is 14, i.e. MPC_HU_LEN*SS_U_LEN < MPC_HP_LEN*SS_Z_LEN.
Nonetheless, thank you for this amazing open source code Best regards