Arduino_Constrained_MPC_Library icon indicating copy to clipboard operation
Arduino_Constrained_MPC_Library copied to clipboard

Please help with code debugging!

Open mirlevesque opened this issue 3 years ago • 1 comments

Hi there, I am trying to utilize your code to control a wave energy converter using an STM32F4 feather! I have not been able to verify the code on my computer yet, and would appreciate help on debugging. I get an error of "'Serial' was not declared in this scope" referring to line 1310, "Serial.println("");" in the matrix code. At one point I was able to move past this issue (I don't recall how) and I got a different error pertaining to SP. Arduino IDE specifically took issue with this line: "Matrix SP((MPC_HP_LEN*SS_Z_LEN), 1);". Any help would be greatly appreciated! These errors were found when compiling the code on Arduino IDE.

mirlevesque avatar Nov 19 '22 18:11 mirlevesque

Here is the error pertaining to SP mentioned above:

In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,
                 from c:\program files\windowsapps\arduinollc.arduinoide_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,
                 from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,
                 from sketch\mpc_constrained_naive_engl.ino.cpp:1:
C:\Users\rgm222\Documents\Arduino\libraries\mpc/mpc.h:59:26: error: expected ',' or '...' before '(' token
     bool bUpdate(Matrix &SP, Matrix &x, Matrix &u);
                          ^
In file included from C:\Users\rgm222\OneDrive\Documents\Arduino\mpc_constrained_naive_engl\mpc_constrained_naive_engl.ino:5:0:
C:\Users\rgm222\Documents\Arduino\libraries\mpc/mpc.h:50:7: error: size of type 'MPC' is too large ('37686' bytes)
 class MPC
       ^~~
In file included from c:\program files\windowsapps\arduinollc.arduinoide_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\io.h:99:0,
                 from c:\program files\windowsapps\arduinollc.arduinoide_1.8.57.0_x86__mdqgnx93n4wtt\hardware\tools\avr\avr\include\avr\pgmspace.h:90,
                 from C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.57.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\cores\arduino/Arduino.h:28,
                 from sketch\mpc_constrained_naive_engl.ino.cpp:1:
mpc_constrained_naive_engl:21:8: error: expected unqualified-id before 'volatile'
 Matrix SP((MPC_HP_LEN*SS_Z_LEN), 1);
        ^
mpc_constrained_naive_engl:21:8: error: expected ')' before 'volatile'
mpc_constrained_naive_engl:21:8: error: expected ')' before 'volatile'
C:\Users\rgm222\OneDrive\Documents\Arduino\mpc_constrained_naive_engl\mpc_constrained_naive_engl.ino: In function 'void loop()':
mpc_constrained_naive_engl:85:21: error: request for member 'InsertSubMatrix' in '*(volatile uint16_t*)(61 + 32)', which is of non-class type 'volatile uint16_t {aka volatile unsigned int}'
             SP = SP.InsertSubMatrix(SP, (_i*SS_Z_LEN), 0, ((_i+1)*SS_Z_LEN), 0, SS_Z_LEN, 1);
                     ^~~~~~~~~~~~~~~
mpc_constrained_naive_engl:87:17: error: request for member 'InsertSubMatrix' in '*(volatile uint16_t*)(61 + 32)', which is of non-class type 'volatile uint16_t {aka volatile unsigned int}'
         SP = SP.InsertSubMatrix(SP_NEXT, ((MPC_HP_LEN-1)*SS_Z_LEN), 0, 0, 0, SS_Z_LEN, 1);
                 ^~~~~~~~~~~~~~~
mpc_constrained_naive_engl:95:33: error: no matching function for call to 'MPC::bUpdate(volatile uint16_t&, Matrix&, Matrix&)'
         MPC_HIL.bUpdate(SP, x, u);
                                 ^
In file included from C:\Users\rgm222\OneDrive\Documents\Arduino\mpc_constrained_naive_engl\mpc_constrained_naive_engl.ino:5:0:
C:\Users\rgm222\Documents\Arduino\libraries\mpc/mpc.h:59:10: note: candidate: bool MPC::bUpdate(Matrix&)
     bool bUpdate(Matrix &SP, Matrix &x, Matrix &u);
          ^~~~~~~
C:\Users\rgm222\Documents\Arduino\libraries\mpc/mpc.h:59:10: note:   candidate expects 1 argument, 3 provided
mpc_constrained_naive_engl:115:152: error: invalid types 'volatile uint16_t {aka volatile unsigned int}[int]' for array subscript
             snprintf(bufferTxSer, sizeof(bufferTxSer)-1, "%.3f %i %.3f %.3f %.3f %.3f", ((float)_maxu64compuTime)/1000., MPC_HIL.cntIterActiveSet, SP[0][0], SP[1][0], z[0][0], z[1][0]);
                                                                                                                                                        ^
mpc_constrained_naive_engl:115:162: error: invalid types 'volatile uint16_t {aka volatile unsigned int}[int]' for array subscript
             snprintf(bufferTxSer, sizeof(bufferTxSer)-1, "%.3f %i %.3f %.3f %.3f %.3f", ((float)_maxu64compuTime)/1000., MPC_HIL.cntIterActiveSet, SP[0][0], SP[1][0], z[0][0], z[1][0]);
                                                                                                                                                                  ^
exit status 1
expected unqualified-id before 'volatile'

rebeccamccabe avatar Nov 19 '22 19:11 rebeccamccabe