Hey, the sample time of the GRAMPC s-function is inherited (-1). The sampling time is set the s-function grampc_run_Sfct in line 204 "ssSetSampleTime(S, 0, -1);". Therefore, I guess there is a problem in your model. Is “MPC-Subsystem” really the name of your GRAMPC s-function or did you put the s-function in another subsystem? Best regards Tobias
Hey, in the red rectangle you don't need to add anything. To the additional build information (the blue rectangle) you have to add <grampc_root>/matlab/include and <grampc_root>/include in the field "Include directories". In the field "Source files" (in the blue rectangle) you have to add all files in the folder <grampc_root>/src, similiar to how you added them in the red rectangle. Beside this, your problem description file (e.g. probfct.c) and the file <grampc_root>/matlab/src/grampc_run_Sfct.c...
You are almost right about your second question. However, the files must be specified as additional build information, as it is stated in the documentation. I.e. in the fields below your red rectangle. Regards, Tobias
Dear Andinet you must add the GRAMPC source and header files to your Simulink model so that these files can be correctly compiled and linked. The last paragraph on page 36 of the documentation (Section 5.2.2 Interface to Matlab/Simulink) explains you how to do this. Best regards Tobias
Hello botNet, if you change the datatype in grampc_init.h, you need to recompile both the example and the whole toolbox. For example, if you use the matlab interface, the command [vec,grampc] = startMPC(200,2); should work after changing the datatype. Best regards Tobias
Hello Giulio, just use a for loop to copy the data form the input array into the userparam array. For this purpose, you can use a typecast to get a typeRNum pointer to the userparam memory as it is done in various problem functions in the example folder. Thor is the prediction horizon, which is internally sampled by Nhor grid points. dt is the sampling time of the MPC. For more details, please refer to the GRAMPC documentation. Regards, Tobias
Hello Giulio, If you want to change the userparam in Simulink at runtime, you need to add an additional input to the provided s-fuction grampc_run_Sfct.c. You can specify the dimensions of this input according to your needs. In the function mdlOutputs you can read the input data from the additional pin and overwrite the userparam data before calling the function grampc_run. Regards, Tobias
GRAMPC V2.1
Version 2.1
Dear Ulices Santa Cruz, Unfortunately, we have no experience with the real-time implementation of GRAMPC on a Raspberry Pi. One possibility would be to use the Raspberry Pi Support from Simulink https://www.mathworks.com/hardware-support/raspberry-pi-simulink.html in combination with the GRAMPC s-function. Another possibility is of course to use GRAMPC directly in a C or C++ program. In addition, depending on the sampling rate of your system a real-time operating system may be necessary. A guide...
minor bugfix, all comments now comply with the C90 standard
GRAMPC v2.0
GRAMPC v2.0
GRAMPC version 2.0
Hello, Nhor must be greater than 1. Best regards
Hello, In the current version of GRAMPC, Nhor must be greater than 1. Best regards
bugfix: by removing the macro isfinite, the endcost were also removed
"master branch" refers to the main git branch. If you download or checkout the current version of grampc, the macro will not be included because it was removed by me. I'm sorry, but I'm not going to open any link, so i can't see your image, however, as mentioned before you can download the current version and everything should be fine.
You will find the answer in my first two contributions to this discussion.
Hello, you must compile the probfct file during the first run and after every change. To do this, set the compile flag (line 35) to 1. With best regards
I also removed this macro in the master branch. Best regards
macro isfinite and some unnecessary variables removed,
Hello, your compiler does not support the macro isfinite. However, in most cases this if-condition (line 658 in grampc_run.c) can be removed. Therefore, try to delete this statement and recompile the toolbox. Best regards
Hello, xdes denotes, a set point that is constant over the horizon. If you want to use variable values for the set point, for example, you must use pCost. Depending on the integration algorithm, you must find the right index in the pCost vector and may interpolate these values using the time value t. (e.g. in case of ruku45) You have correctly understood the meaning of Nhor. Nhor can be set to Thor/dt, however, if your system is very stiff or not, it may be sensible to raise or to reduce the numer...
Hello, xdes denotes, a set point that is constant over the horizon. If you want to use variable values for the set point, you have to use pCost for example. Depending on the integration algorithm, you must find the right index in the pCost vector and may interpolate these values using the time value t. (e.g. in case of ruku45) You have correctly understood the meaning of Nhor. Nhor can be set to Thor/dt, however, if your system is very stiff or not, it may be sensible to raise or to reduce the numer...
Hello, xdes denotes, a set point that is constant over the horizon. If you want to use a variable values for the set point, you have to use pCost for example. Depending on the integration algorithm, you must find the right index in the pCost vector and may interpolate these values using the time value t. (e.g. in case of ruku45) You have correctly understood the meaning of Nhor. Nhor can be set to Thor/dt, however, if your system is very stiff or not, it may be sensible to raise or to reduce the...
Grampc version 1.1
Is the grampc folder part of your matlab path? If so, maybe the make file for the...
Are you sure that you run make (and not make clean) in the folder 'D:\grampc_v1.0\matlab'...
Hello Willian UEL Thank you for your interest in GRAMPC. Before you can run the initData.m...