Activity for GRAMPC

  • Karthik Karthik posted a comment on discussion General Discussion

    Dear @avoelz, Thanks a lot for the clarification and detailed explanation. 1) If the dynamics can be formulated as ordinary differential equation or index-1 differential algebraic equation, GRAMPC should be applicable. For most systems this is probably the case. However, I can't tell for sure without more details about the actual system. Reply :- Understood. 2) You can definitely do MPC for robot manipulators with GRAMPC. You need the forward dynamics which can either be computed in a symbolic manner,...

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Karthik, was thinking whether the same will be applicable for a rocket example with depleting mass ?. So GRAMPC is not applicable here too ? Sorry for the confusion. If the dynamics can be formulated as ordinary differential equation or index-1 differential algebraic equation, GRAMPC should be applicable. For most systems this is probably the case. However, I can't tell for sure without more details about the actual system. Also even if we use ABA, GRAMPC software may be of less help for the...

  • Karthik Karthik posted a comment on discussion General Discussion

    Dear @avoelz Thanks for the reply. It took some time to go through basics of RNEA and ABA.. Can you please clarify the following a) I was thinking whether the same will be applicable for a rocket example with depleting mass ?. So GRAMPC is not applicable here too ? Sorry for the confusion. b) Also even if we use ABA, GRAMPC software may be of less help for the manipulator dynamics case and its better to code from scratch ? c) For kinematics solving, GRAMPC will suffice ryt Please correct if wrong....

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Karthik, for this paper I had reimplemented the core algorithm of GRAMPC in C++ in order to keep it as simple as possible and to tailor it to the special case of rigid body dynamics. In principle it would also be possible to implement the same algorithm within GRAMPC but it would be quite a lot of effort and I doubt that enough people would use this special variant to justify the effort. However, GRAMPC can still be used for MPC of systems with rigid body dynamics. It just requires using forward...

  • Karthik Karthik posted a comment on discussion General Discussion

    Dear @avoelz, While going through one of the published papers from your team (https://ieeexplore.ieee.org/document/9867380), there is a reference to the usage of NMPC with state dependent mass matrix in system dynamics as given below. A. Volz and K. Graichen, “Gradient-based nonlinear model predictive control for systems with state-dependent mass matrix,” in Proc. of the Conference on Decision and Control (CDC), 2021, pp. 1012–1017. Whether GRAMPC can solve such problems ? Thanks n Regards, Karthik...

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Karthik, I guess that you can ignore the warnings. After all, this file is only relevant for the RODAS integrator and it is not very likely that you will use RODAS in an embedded MPC application. Best regards, Andreas Völz

  • Karthik Karthik posted a comment on discussion General Discussion

    Dear @avoelz, Thanks for the response and Sorry I missed it. I am able to build the program without any errors but with following warnings. Hope its not a major issue. ...\src\grampc\include/f2cmod.h:90:1: warning: function declaration isn't a prototype [-Wstrict-prototypes] typedef int / Unknown procedure type /(U_fp)(); ^~~~~~~ ...\src\grampc\include/f2cmod.h:91:1: warning: function declaration isn't a prototype [-Wstrict-prototypes] typedef / Subroutine / int(S_fp)(); I need to see the performance...

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Ethan, In my model, Thor=6, Nhor=61, dt=0.02 In this case GRAMPC discretizes the horizon Thor=6 with Nhor=61 sampling points, which means they have a spacing of 6/(61-1) = 0.1, that is, grampc.rws.t is the vector [0, 0.1, 0.2, 0.3, ..., 5.7, 5.8, 5.9, 6.0] Now, it would be sufficient to pass the predicted disturbances at these 61 sampling points to GRAMPC, in which case you would need (t-t0)/0.1 to compute the index into the userparam array. On the other hand, your MPC is running with the sampling...

  • Ethan Ethan posted a comment on discussion General Discussion

    Dear Andreas Völz I feel so sorry for the delayed response as I have been occupied with other work recently. (1) I don't understand "The MHE example in GRAMPC chooses them in such a way that the sampling time along the prediction horizon corresponds to the sampling time of the controller. " Because, in the MHE example, it seems like "typeInt index" is also set to be " (int)floor( (t-t0) / dt + 0.00001)" . That's why I use "typeInt index = (int)floor( (t-t0) / dt + 0.00001)" in my model first. In...

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Ethan, (1): I would expect Thor/(Nhor-1) but you have programmed it. What are the specific values of Thor, Nhor and dt in your case? The MHE example in GRAMPC chooses them in such a way that the sampling time along the prediction horizon corresponds to the sampling time of the controller. This definitely simplifies such tasks where you want to take predicted values into account. Otherwise, setting the values in userparam before calling grampc_run is just a little bit more complex. (2): You can...

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Karthik, since there exist so many different microcontrollers, it is impossible for us to provide examples or tutorials for each of them. The manufacturer of your controller probably provides some minimal examples for running own programs on the controller. I would take these as starting points and then integrate GRAMPC. If you need more help, then you should at least share such a minimal example. Best regards, Andreas Völz

  • Andreas Völz Andreas Völz modified a comment on discussion General Discussion

    Hi, I am a PhD student in optimization based control and would like to evaluate GRAMPC for implementing NMPC. I had setup the tool in my PC and able to run few examples. I had gone through documentation and some published papers also and tried PYGRAMPC also. I would like to know the compilation steps of GRAMPC for a RISC-V micro-controller. I understand its already implemented for dSpace, RH850 etc. Is there any tutorial for implementation on embedded controller (similar to the PC implementation...

  • Karthik Karthik modified a comment on discussion General Discussion

    Hi, I am a PhD student in optimization based control and would like to evaluate GRAMPC for implementing NMPC. I had setup the tool in my PC and able to run few examples. I had gone through documentation and some published papers also and tried PYGRAMPC also. I would like to know the compilation steps of GRAMPC for a RISC-V micro-controller. I understand its already implemented for dSpace, RH850 etc. Is there any tutorial for implementation on embedded controller (similar to the PC implementation...

  • Karthik Karthik posted a comment on discussion General Discussion

    Hi, I am a PhD student in optimization based control and would like to evaluate GRAMPC for implementing NMPC. I had setup the tool in my PC and able to run few examples. I had gone through documentation and some published papers also and tried PYGRAMPC also. I would like to know the compilation steps of GRAMPC for a RISC-V micro-controller. I understand its already implemented for dSpace, RH850 etc. Is there any tutorial for implementation on embedded controller (similar to the PC implementation...

  • Ethan Ethan posted a comment on discussion General Discussion

    Hi everyone, I want to add external measured disturbances to my model (MATLAB/Simulink interface) in the form of discrete points over a period of time in the predicted horizon. So, I made the following modifications to the ffct in probfct.c. /** System function f(t,x,u,p,userparam) ------------------------------------ **/ void ffct(typeRNum *out, ctypeRNum t, ctypeRNum *x, ctypeRNum *u, ctypeRNum *p, typeUSERPARAM *userparam) { ctypeRNum* Sys = (ctypeRNum*)userparam; /***omission part***/ ctypeRNum...

  • Krysten Lambeth Krysten Lambeth posted a comment on discussion General Discussion

    Thank you for the suggestion. In the process of creating the simpler example, I found an error that had been overlooked through multiple code checks. All is fixed now!

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Krysten, I don't think I have ever seen the penalties explode so fast to PenaltyMax. Maybe the error is related to wrong gradients of the constraint, but this is really just a guess. I am now on vacation during the next weeks and won't have time to look into this problem. Maybe you can reduce it to a minimal working example (probfct,c, initData.m and startMPC.m) that still shows the behaviour and then share it with me? Best regards, Andreas Völz

  • Krysten Lambeth Krysten Lambeth posted a comment on discussion General Discussion

    Hello, I can't seem to satisfy the inequality constraint in my GRAMPC. I've tried varying user.opt.ConstraintsAbsTol, the maximum penalty, the penalty increase/decrease factors, and changing user.opt.ConstraintsHandling to extpen. None of these are affecting the simulation results. The constraint is quickly violated, and the penalty goes to whatever the maximum is and remains there for most of the simulation. I don't think this is due to the problem being infeasible. I'm using Lyapunov MPC, and the...

  • Bilal Mubdir Bilal Mubdir posted a comment on discussion General Discussion

    Thank you so much for the answer, I will take a look at that section on the manual and the example as well. I know that minimizing the Jerk or Snap are easier using another method. In fact, the problem I working on is more complicated and it is not to minimise the jerk but I was just trying to give an example to know more about optimizing the time. thank you so much again

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Bilal, the closest example is the double_integrator_OCP that is also described in the GRAMPC manual in Section 6.2.1. It also includes a free end time, terminal equality constraints and inequality constraints. For your use case you would have to extend it to a triple integrator and then adjust the constraints. In order to minimize with respect to time all you have to do is weight the time in the cost functional and set the option OptimTime to on. Note however that GRAMPC may not be the ideal...

  • Bilal Mubdir Bilal Mubdir posted a comment on discussion General Discussion

    Dear All, I would like to formulate an optimization problem to generate a trajectory with an optimal time (T), where a specific cost function is intended to be minimized. I'm looking for tips on how to formulate the problem in GRMPC, I checked the examples but I didn't find any similar case. Attached is a summary of the problem, noting that T is a decision variable. So the main question is how to formulate the problem in such a way that T is a decision variable.

  • Krysten Lambeth Krysten Lambeth posted a comment on discussion General Discussion

    Hi Genc, See attached for my trajectory tracking MPC. It's framed as a parameter optimization problem in order to test out trajectory tracking by driving the states with a PD feedback controller. The parameter optimization part itself doesn't appear to work, actually, as it never updates the initial guess. I didn't troubleshoot this aspect since it wasn't my end goal, but I hope that the trajectory aspect is helpful!

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Carlos, in the C++ interface the problem description is implemented as a class and the userparam field is used to store the pointer to the instance of this class. See the code in grampc/cpp/src/problem_description.cpp where the actual probfct interface is implemented. Therefore, userparam is no longer available in the C++ interface. However, it is also no longer necessary since in C++ you can store data in attributes of the class and then access it from all methods. In the C variant this was...

  • Carlos Vazquez de Lara Kallas Carlos Vazquez de Lara Kallas posted a comment on discussion General Discussion

    Hello, I am currently trying to implement a small example in C++. In the problem_description.hpp the userparam field does not occur. Why is that? Do I have to add it myself? Is there an example completely implemented in C++? Thank you!

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Genc, it is out of scope to explain the whole algorithm behind GRAMPC. We have done this in the journal paper in Optimization and Engineering and also in the documentation that comes along with the code. * First, all trajectories are stored in discretized manner. * Each gradient iteration performs a forward integration of the system dynamics, * then a backward integration of the adjoint dynamics (involves partial derivatives of cost and system dynamics with respect to the states x), * then an...

  • Genc Yavuz Genc Yavuz posted a comment on discussion General Discussion

    Hello Krysten, could you share the solution of your Simple GRAMPC Example? This would be very helpful. Best regards, Genc Yavuz

  • Genc Yavuz Genc Yavuz posted a comment on discussion General Discussion

    Dear Andreas, I have discovered that the lfct function is called often, depending on the parameters Nhor, T and dt. Also I have varying x values at every lfct call. How exactly does this work? Is lfct called at every step dt and thereby the cost function over the horizon T is evaluated stepwise? Is this the internal discretization that is done in the algorithm? This would mean that I would only have to incorporate the discrete reference points at the current timestep t+dt and not all the values along...

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Genc, Now, if I want to incorporate an output y = f(x, u) into my cost function in order to follow an output reference ydes, in my understanding I can define ydes with userparam. Is it possible to define the output inside the function lfct, depending on x and u? Is there anything special, besides the "normal" structure of GRAMPC I need to be aware of? The cost functions can be arbitrary nonlinear functions depending on t, x, u and p so there is nothing special to consider when using some transformed...

  • Genc Yavuz Genc Yavuz posted a comment on discussion General Discussion

    Dear Andreas Völz, First of all, thank you for the detailed explanation, they are very helpful and help understanding the time dependencies more. Now, if I want to incorporate an output y = f(x, u) into my cost function in order to follow an output reference ydes, in my understanding I can define ydes with userparam. Is it possible to define the output inside the function lfct, depending on x and u? Is there anything special, besides the "normal" structure of GRAMPC I need to be aware of? Also, in...

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Genc, In my understanding grampc.sol.xnext is the same as the first x in grampc.rws.x. This seems to be wrong, as it is dependent from Nhor at whch position rws.x and sol.xnext are the same. Why is that? If I set Nhor to 401, rws.x at position 101 corresponds to sol.xnext The first element in the workspace grampc.rws.x is always equal to grampc.param.x0, that is, the initial state from which the integration starts. The value of grampc.sol.xnext is an estimate of the predicted trajectory x(dt)...

  • Genc Yavuz Genc Yavuz posted a comment on discussion General Discussion

    Hello, I am sorry for not answering, I have not worked on GRAMPC in the last weeks. The problem came up because I tried to give sth back to my Matlab code from the probfct definition by assigning it to userparam, what messed up the parameter structure. I still have some general questions about GRAMPC though. Despite reading every discussion on this page and reading the manual there are still some points I did not understand. In my understanding grampc.sol.xnext is the same as the first x in grampc.rws.x....

  • Krysten Lambeth Krysten Lambeth posted a comment on discussion General Discussion

    Hi Andreas, That worked! I saved t0 as a parameter per your suggestion and just subtracted it in ffct, dfdp, etc. Even in the more complex script, this solution works perfectly. Best, Krysten

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Krysten, thanks for sharing the minimal example. Using GRAMPC to optimize over feedback gains instead of control inputs is a quite interesting usecase that we probably have not tested so far. Our initial motivation to add the parameter optimization was rather to enable moving horizon estimation. It took me a while to debug your problem, but I think I found at least one main issue. GRAMPC passes the global time t0+t (running from t0 to t0+Thor) to ffct, dfdx_vec, dfdu_vec, dfdp_vec while it passes...

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Genc Yavuz, can you share the code or at least the relevant parts of it? Note that the estim_penmin function internally calls grampc_run which then calls your problem functions so it is important that the userparameters are correctly initialized before the call of estim_penmin. Maybe you extend the userparam vector after estim_penmin? In this case it could happen that your problem function reads from an invalid memory location. Best regards, Andreas Völz

  • Genc Yavuz Genc Yavuz posted a comment on discussion General Discussion

    Hello, I have a problem with my weights and constraints that I am defining in userparam. I have very weird errors when initializing the OCP in Matlab. Sometimes x0 has wrong dimension, then PenaltyMin has an invalid value, although I have quadruple-checked these values and they are 100% correct. By comparing my current code to the code from earlier stages, I saw that the only difference is in the definition of userparam. In the newer version, I defined more values in userparam than in the older one....

  • Krysten Lambeth Krysten Lambeth posted a comment on discussion General Discussion

    Ok, I've simplified it to a double integrator where the two gains in a PD control law need to be optimized. The initial guesses should stabilize the system, but I'm getting the same problem as before. I re-downloaded GRAMPVC v2.2 and built this version off of the template files to ensure no changes had been made to the src, include, or matlab folders that could affect the memory. If you are able to identify where the memory issue is occurring, I will be very grateful.

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Krysten, it is quite difficult to help here with always only a part of the code available. If you get different results with each run, the reason is typically that you read from the wrong memory locations. This can happen in C, for example when variables are not initialized properly or when you read with pointers (or arrays) beyond your allocated memory. One option would be that you reduce your code to a minimal working example that still shows the problematic behaviour or I can try to create...

  • Krysten Lambeth Krysten Lambeth posted a comment on discussion General Discussion

    Thanks! Here is my updated output with line breaks. It's not printing anything in lfct within probfct.c, though. I have the print command coded at the top of lfct as follows: void lfct(typeRNum *out, ctypeRNum t, ctypeRNum *x, ctypeRNum *u, ctypeRNum *p, ctypeRNum *xdes, ctypeRNum *udes, typeUSERPARAM *userparam) { printf("%s\n",("We're now in lfct")); If I can get this to work, I can change what's contained in printf to show xd for that iteration. I'm concerned there's some issue with xd because...

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Your should add a line break to all your printf statements, so printf("%s\n",("We're now in dl/dx")). Currently you get everything in one line but I also saw "evaluateCost" which maybe your output in the lfct.

  • Krysten Lambeth Krysten Lambeth posted a comment on discussion General Discussion

    Yes, it compiles. When I run the startMPC MATLAB file, it prints the messages contained in grampc_run.c and grampc_run_Cmex.c after printing the GRAMPC parameters. Each message is displayed twice when I run one iteration.

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Debugging using a simpler example is always good. So what is the output of your simpler program? Does it compile? Can you see messages printed?

  • Krysten Lambeth Krysten Lambeth posted a comment on discussion General Discussion

    Hi Andreas, Thank you again for your detailed advice, and I apologize for the continued questions. I've tried both approaches. If I solve the OCP in startMPC.m but stop the code before it moves to the next step, I'm able to view grampc.rws.x. Unfortunately, even with MaxMultIter = 1, MaxGradIter = 1, and Tsim = dt, these are still suspiciously similar. I've attempted to use myPrint and printf in the problem function. While both of these print functions work if I include them in grampc_run_Cmex.c...

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Krysten, the code pSys[t/d_t] does not compile because t/d_t is of floating point type but array access requires integer types. With int step = t/d_t; you perform an implicit type cast from floating point to integer. Alternatively you could use pSys[(int)(t/d_t)] with an explicit type cast. In principle it is possible to use a debugger to go through the code step by step. While this is easy if you run GRAMPC as pure C code, it is more involved if you start it from Matlab and probably even more...

  • Krysten Lambeth Krysten Lambeth posted a comment on discussion General Discussion

    You're right; I needed to add a +1 to the index for pSys. As for Q, I've now simplified it as a vector instead of a sparse matrix. Perhaps this is a silly question, but since I'm not overly familiar with C, is there any way I can verify that step and xd are being correctly defined (i.e., print them out)? I ask because I initially received compilation errors regarding the index for pSys not being an integer because it depends on the quotient of two doubles, t/d_t. I played around with it and was able...

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Krysten, this definitely goes into the right direction. You should take care that if you want to cover a horizon Thor=1.0s with sampling points every 0.1s then you need Nhor=11 because the sampling time along the horizon is Thor/(Nhor-1). You should also take care that Matlab starts counting from 1 whereas C code starts counting from 0. The element pSys[13] is thus the 14th element in the Matlab vector. Your first step is 0 for t=0 and therefore your first xd is selected from pSys[13+2*0+0]...

  • Krysten Lambeth Krysten Lambeth posted a comment on discussion General Discussion

    Hi Andreas, I did found this example helpful (https://sourceforge.net/p/grampc/discussion/general/thread/21114e01aa/) . I created a vector with a length equal to the prediction horizon length (10 steps, or 0.1s, in my case). This vector is added to grampc.userparam and updated at each step in the Trajectory Generator subsystem. Then, the cost function uses the vector xd (instead of xdes), where xd's value depends on userparam and time t. Relevant code is below. I've included an image which shows...

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Krysten Lambeth, yes, xdes and udes have always been parameters of size Nx and Nu that were simply passed to the cost functions and their derivatives. In order to take time-varying references into account, you always had to work with userparam (or pCost in v1.0 and v1.1). However, we generally see this as advantage since one can realize arbitrary complex usecases with the userparam field. Do you need help with implementing your usecase via userparam? Best regards, Andreas Völz

  • Krysten Lambeth Krysten Lambeth posted a comment on discussion General Discussion

    Hi Andreas, Thank you so much for the clarification. Follow-up question - was this also the case for the older version of GRAMPC (as shown in the attached image)? That is, would the old version also hold xdes constant for the prediction horizon?

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Krysten Lambeth, thank you for your interest in GRAMPC. You are right that xdes is assumed constant over the prediction horizon, it is just a convenience parameter for the typical setpoint stabilization tasks. Trajectory tracking should be implemented via the userparam field depending on the problem-specific representation (e.g. discrete sampling points along the horizon or a polynomial trajectory). To get started, see for example the past questions: https://sourceforge.net/p/grampc/discussion/general/thread/7add8e634f/...

  • Krysten Lambeth Krysten Lambeth posted a comment on discussion General Discussion

    I have a time-varying trajectory that is piecewise continuous (based on a finite state machine) and would be difficult to incorporate into probfct.c. My understanding is that in the image attached, GRAMPC will consider xdes to be held constant over the prediction horizon. In other words, only the first point in the trajectory will be passed to probfct.c. Is that correct?

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Marta Lom, thank you for your interest in GRAMPC. Where do you think a discrete-time problem is used internally? Of course the trajectories are discretized, but the numerical solution works by iterative forward and backward integration of the differential equations. The good news is that we have already implemented a "discrete" integrator that allows to implement discrete-time systems in the probfct. The bad news is that it is not yet public and is planned for version 2.3. Can you give some...

  • Marta Lom Marta Lom posted a comment on discussion General Discussion

    Hello, the GRAMPC needs a problem definition in continous time, although internally a discrete-time problem is used for computation. Is it possible to define the problem in discrete-time? Best regards, Marta Lom

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Raahul, if it is only a MATLAB+GCC issue without relation to GRAMPC, then you better ask for help in another place. However, if it is clearly related to GRAMPC, we can of course help you here. To this end, you should describe in detail what you have done and what are the error messages that you get. Best regards, Andreas Völz

  • RAAHUL RAAHUL posted a comment on discussion General Discussion

    Hey everyone, I'm currently facing an issue executing a file in MATLAB, and I'm seeking some assistance. Despite installing GCC as a compiler, I'm encountering difficulties compiling the file properly. I've ensured that MATLAB recognizes the directory containing the file and configured MATLAB to use the GCC compiler. However, despite these efforts, the file isn't executing as expected. Could anyone offer some guidance or troubleshooting tips to help resolve this issue? Any insights or suggestions...

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Wong, as I have said, grampc_estim_penmin internally calls grampc_run which requires that the userparameters are well defined. In your case, the disturbance-related fields are only set in the Simulink model but not within initData prior to the call of grampc_estim_penmin. You should change line 98 of initData.m to something like Wf = zeros(1, user.opt.Nhor); userparam = [ pSys , pCost , boxz, Wf ] ; and then the call of [grampc, ~] = CmexFiles.grampc_estim_penmin_Cmex(grampc,1); should work...

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Mengke, do you use a version control system (e.g. Git)? If yes, you could check which files have been changed between now and the last time it worked. Otherwise, if it previously worked well and only failed now, I would try to delete all build-related files (i.e. clean the whole workspace) and attempt a full rebuild of all project-related files. You could also check whether you can compile GRAMPC and your probfct on its own, that is, without using Simulink. Best regards, Andreas Völz

  • liumengke liumengke posted a comment on discussion General Discussion

    Hi Everyone, I met a fatal error in my simulation yesterday. This is a matlab-carsim cosimulation project. It was working well one week ago. However, when I rebuilt the functions and try to start the same project as before. I noti there is a fatal error, the detail looks like this: Error evaluating 'OpenFcn' callback of SubSystem block 'test_integratedAAWS/Click to compile the toolbox'. Callback string is 'cd(fileparts(which(gcs))) curdir = cd; cd('../ GRAMPC_v2.2/matlab/') make clean cd(curdir)'...

  • Ethan Ethan posted a comment on discussion General Discussion

    Dear Andreas Völz, Thanks very much for your reply. Just as you guess, when the call of grampc_estim_penmin_Cmex in initData is removed, the program works well. However, the problem still exists (the parameters of PenaltyMin which is in the setting of Multipliers & penalties cannot be determined for a suitable value) after I checked the whole program carefully again and even reduced the order of the state-space model. Now, I am uncertain about the underlying issue, and I would greatly appreciate...

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Wong, it is difficult to help with the few information available. My first guess would be that grampc_estim_penmin (typically called from initData.m) computes an invalid value for your problem (maybe inf or nan). Please remove the call of grampc_estim_penmin_Cmex in initData to check this. Note that this function internally calls grampc_run, which requires that the problem is well-defined after the initialization. If your problem relies on some user parameters that are only set in the MPC loop...

  • Ethan Ethan modified a comment on discussion General Discussion

    Dear Andreas Völz, Some new problems appear in my program. My program works well without adding any inequality constraints. However, an error occurs when I add some simple inequality constraints in my program. After the pobfct is compiled, the grampc seems cannot be Initialized and Matalb gives an error of ' PenaltyMin : Invalid value for option. '. /** Inequality constraints h(t,x(t),u(t),p,uperparam) <= 0 ------------------------------------------------------ **/ void hfct(typeRNum *out, ctypeRNum...

  • Ethan Ethan posted a comment on discussion General Discussion

    Dear Andreas Völz, Some new problems appear in my program. My program works well without adding any inequality constraints. However, an error occurs when I add some simple inequality constraints in my program. After the pobfct is compiled, the grampc seems cannot be Initialized and Matalb gives an error of ' PenaltyMin : Invalid value for option. '. /** Inequality constraints h(t,x(t),u(t),p,uperparam) <= 0 ------------------------------------------------------ **/ void hfct(typeRNum *out, ctypeRNum...

  • Ethan Ethan posted a comment on discussion General Discussion

    Dear Andreas Völz, Thanks very much for your help. With your guidance, my program seems to be working well. Best regards, Wong.

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Wong, the actual / true disturbance should be added to the simulation. For example, in startMPC.m when integrating the system to obtain the next state. If you can measure the current disturbance and assume that it remains constant over the prediction horizon, you can store it within the MPC loop in a userparam field and consider it in the ffct and possibly dfdx_vec, dfdu_vec. This is what you should test first. If you have a prediction model for the disturbance, meaning that you can get estimates...

  • Ethan Ethan posted a comment on discussion General Discussion

    Hi everyone, first of all, thanks to all developers for providing us with this toolbox. I want to add external measured disturbances to my model (MATLAB interface) in the form of discrete points over a period of time in the predicted horizon. I 've already read the discussion of https://sourceforge.net/p/grampc/discussion/general/thread/bac9bb8d7b/. But things are a little difference, and I have no idea what to do next. /** System function f(t,x,u,p,userparam) ------------------------------------...

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Haig, if "indirect function calls" also includes the usage of function pointers, then there are some spots in GRAMPC that need to be modified: - function evaluate_sys in grampc_run.c (line 595) to directly call the integrator - function evaluate_adjsys in grampc_run.c (line 625) to directly call the integrator - function evaluate_cost in grampc_run.c (line 1262) to directly call the integrator None of these is difficult to change, since the usage of function pointers is not strictly needed here....

  • Haig Conti Georges Sajelian Haig Conti Georges Sajelian posted a comment on discussion General Discussion

    Dear Andreas Völz, Excluding all cpp/hpp-files removed the linker error and the synthesis started. Thank you for noticing that mistake! Now the "fun" begins: all indirect/virtual function calls are not supported by the synthesis... These problems are however out of the GRAMPC scope as they are only synthesis related. I thank you for all the help! Best regards Haig Conti Georges Sajelian Technical University of Darmstadt Self-Organizing Systems Lab

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Haig, if I understand you correctly, using functions from stdlib.h, stdio.h, math.h and string.h is not a problem, because the HLS generates appropriate code, right? I have seen in your list of warnings that you have included the file problem_description.hpp from GRAMPC's C++ interface. This could be the reason for the linker error if you compile the C++ interface together with the probfct_QUADROTOR.c since then you have two implementations of the probfct interface (one in probfct_QUADROTOR.c...

  • Haig Conti Georges Sajelian Haig Conti Georges Sajelian posted a comment on discussion General Discussion

    Dear Andreas Völz, I have run some tests in a seperate test-case and concluded that the usage of "math.h"-Macros in the grampc_macro.h should not be a problem as they seem to be supported natively. Functions such as "printf()" shouldn't cause any problems as well. They will just be ignored by the synthesis. I have found no option to increase the information on errors, only one to decrease it. I still think GRAMPC is the right fit for our study case, however, my time available for this project is...

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Haig, Sadly (unless I am missing some hidden errors), this should be the whole error message that is produced (see attachments). Maybe there is some option (like --verbose) that can be activated to get more detailed error messages? In addition the Console is issuing a lot of warnings about unused parameters in the problem_description.hpp, probfct_QUADROTOR.c. and some other files. Maybe the problem lies there? Unused parameters do not lead to linker errors, so this should not be the problem....

  • Haig Conti Georges Sajelian Haig Conti Georges Sajelian posted a comment on discussion General Discussion

    Dear Andreas Völz, thank you for replying so fast. Sadly (unless I am missing some hidden errors), this should be the whole error message that is produced (see attachments). In addition the Console is issuing a lot of warnings about unused parameters in the problem_description.hpp, probfct_QUADROTOR.c. and some other files. Maybe the problem lies there? Another thing that might be an issue is the usage of any kind of print function or data read/write. I have undefined PRINTRES in the main and tried...

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Haig, I think that you have not posted the complete error message of the linker. A linker error typically includes something like "undefined reference to function ..." or "multiple definition of ...", where the name of the function is an important hint on how to fix the error. A common reason for such linker errors is that not all relevant source or library files are included in the linking process. Best regards, Andreas Völz

  • Haig Conti Georges Sajelian Haig Conti Georges Sajelian posted a comment on discussion General Discussion

    Greetings all, currently I am trying to implement GRAMPC on an FPGA for the Crazyflie (Quadrotor), by using High-Level Synthesis. I have already read the other posts on embedded implementations (using CFLAG -DFIXEDSIZE etc.). However I am receiving an linker error: Error in llvm-link while executing "source C:/Users/usr/AppData/Roaming/Xilinx/Vitis/test090903/solution1/csynth.tcl" invoked from within "hls::main C:/Users/usr/AppData/Roaming/Xilinx/Vitis/test090903/solution1/csynth.tcl" ("uplevel"...

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Yifan Zhang, basically, you should still be able to use the Matlab/Simulink-interface of GRAMPC. However, depending on your modifications to the C-code of GRAMPC you also have to modify some parts of the mex-interface. From your error messages it appears that you have changed the interface of grampc_init, which then requires that you also change the function calls of grampc_init in all of the mex-files. If possible, I would suggest to keep the changes to the function definitions of GRAMPC as...

  • Yifan Zhang Yifan Zhang posted a comment on discussion General Discussion

    Hi all, here is Yifan, first of all great thanks to all the development of such a magnificent work! I am currently working on a MPC-Control project which allows the controller to track a reference trajectory. For the purpose of tracking i have written some C functions to read and use the Trajectory data, besides i have also modified some original source file to to make this work. The Program runs in C (main.c file) pretty well, for the next step I would like to build a Simulink model in Matlab, for...

  • Bin Zhong Bin Zhong posted a comment on discussion General Discussion

    Dear Andreas Völz, You are life saver !Great thanks for your kind help, this question bothered me for the past two days. Best regards, Bin

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Bin Zhong, I have tested your code and think the main problem was that your trajectory is not feasible for the system. In the attached code I have modified the desired trajectory, the initial state and removed the wrong lines in startMPC. With these changes, the first state follows the trajectory as expected. To further improve the result, the desired control value should be adapted in such a way that exact tracking has zero cost. Best regards, Andreas Völz

  • Bin Zhong Bin Zhong posted a comment on discussion General Discussion

    Andreas Völz, Great thanks for your timely reply ! Thanks for your suggestion. I have tried to modified the code as: % run MPC and save results grampc.userparam(11) = vec.t(i); %update the current time [grampc,vec.CPUtime(i)] = CmexFiles.grampc_run_Cmex(grampc); vec = grampc_update_struct_sol(grampc, vec, i); But the result shows that the state still convergent to the constant setpoint, i.e., x_des[1.2, 0], while not track the trajectory: x_ref = 1 * sin(2 * 3.14 * (t0 + t)); I have also tried to...

  • Bin Zhong Bin Zhong posted a comment on discussion General Discussion

    Andreas Völz, Great thanks for your timely reply ! Thanks for your suggestion. I have tried to modified the code as: % run MPC and save results grampc.userparam(11) = vec.t(i); %update the current time [grampc,vec.CPUtime(i)] = CmexFiles.grampc_run_Cmex(grampc); vec = grampc_update_struct_sol(grampc, vec, i); But the result shows that the state still convergent to the constant setpoint, i.e., x_des[1.2, 0], while not track the trajectory: x_ref = 1 * sin(2 * 3.14 * (t0 + t)); I have also tried to...

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear Bin Zhong, you need to set the respective entry of userparam to the current time before the call to grampc_run, that is like grampc.userparam(11) = vec.t(i); [grampc,vec.CPUtime(i)] = CmexFiles.grampc_run_Cmex(grampc); See also https://sourceforge.net/p/grampc/discussion/general/thread/cd2e89b28f/#cf73/f55d where the same is done in C code. Best regards, Andreas Völz

  • Bin Zhong Bin Zhong posted a comment on discussion General Discussion

    Hi, Here is Bin. I am working on the GRAMPC implementation, first of all, great thanks to all the developers for providing such a convenient tool!! I have finished the problem formulation by modifying the BallOnPlate example. ~~~void ffct(typeRNum out, ctypeRNum t, ctypeRNum x, ctypeRNum u, ctypeRNum p, typeUSERPARAM userparam) { ctypeRNum pSys = (ctypeRNum*)userparam; ctypeRNum A = pSys[0]; ctypeRNum B = pSys[1]; ctypeRNum J = pSys[2]; ctypeRNum tau_g = pSys[3]; out[0] = x[1]; out[1] = (u[0] - A...

  • WenChao Xu WenChao Xu posted a comment on discussion General Discussion

    Dear Andreas Völz, I've got it, thank you! Best regards, WenChao Xu.

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear WenChao, yes, I meant that, use the MPC for the mechanical system and a low-level controller for the electrical subsystem. If the electrical system is fast enough and the controller well-tuned, you won't see any difference in the resulting system behaviour. Best regards, Andreas Völz

  • WenChao Xu WenChao Xu posted a comment on discussion General Discussion

    Dear Andreas Völz Thank you for your reply! Therefore, if you have a system structure with such different time constants, a cascaded approach might be the better solution. Does the cascading method refer to performing MPC control on the mechanical structure to obtain a current signal, and then cascading a current controller behind it? Uh-huh, I see. Thank you! Best regards WenChao Xu.

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear WenChao, thanks for the more detailed information. Given that the electrical subsystem is typically much faster than the mechanical subsystem, you should honestly ask yourself whether it is of advantage to include the voltage-current dynamics in the MPC. You would probably have to decrease the sampling time, increase the number of discretization steps, or shorten the prediction horizon. However, if the horizon is too short, you could get problems with stabilizing the mechanical subsystem. Therefore,...

  • WenChao Xu WenChao Xu posted a comment on discussion General Discussion

    Dear Andreas Völz, Note that GRAMPC's integrator "ruku45" is a method with variable step size that should work for most problems. Besides, you could test "rodas", which uses a variable step size, too. I'm going to try these two integrators. I have a doubt. The step size of the integrator I used in the prediction horizon was either equal to the sampling time, or at least a fixed step size. I have not used an integrator with a variable step size. Isn't the step size of the integrator not strictly kept...

  • WenChao Xu WenChao Xu posted a comment on discussion General Discussion

    Dear Andreas Völz, Thank you for your reply! My dynamic model is a single-link flexible-joint manipulator, which is a 4th-order model, and then on this basis I added the dynamic model of the servo motor to make it a 5th-order model, and The optimization variable of MPC is changed from the winding current to the joint voltage, so that PWM control can be performed directly. The discretization (numerical integration) of the prediction model over the entire prediction time domain is normal when using...

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Can you maybe state the dynamical equations of the system that you want to control?

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear WenChao, what do you mean by "the discretization of the dynamic model will fail"? Can you please explain the problem in more detail? Note that GRAMPC's integrator "ruku45" is a method with variable step size that should work for most problems. Besides, you could test "rodas", which uses a variable step size, too. However, I am not convinced that this is truly the source of your problems. If the MPC without additional integrator worked with "heun", then the MPC with additional integrator should...

  • WenChao Xu WenChao Xu posted a comment on discussion General Discussion

    The reason for this is that the model of the motor and the joint of the manipulator is coupled in my dynamic model, resulting in the existence of two sub-models with a large gap in dynamic characteristics. RKC does not solve this problem either.

  • WenChao Xu WenChao Xu modified a comment on discussion General Discussion

    Hello, everyone! First of all, the constraints and penalties on the control input rate I asked before are implemented using augmented state variables as the author said. The main problem lies in the adjustment of parameters, especially the need to enlarge the prediction horizon. Then, I encountered another problem during the test, that is, the discretization of the dynamic model will fail no matter whether I use the default RK2 or RK4 in the text. I guess the specific reason should be that there...

  • WenChao Xu WenChao Xu posted a comment on discussion General Discussion

    Hello, everyone! First of all, the constraints and penalties on the control input rate I asked before are implemented using augmented state variables as the author said. The main problem lies in the adjustment of parameters, especially the need to enlarge the prediction horizon. Then, I encountered another problem during the test, that is, the discretization of the dynamic model will fail no matter whether I use the default RK2 or RK4 in the text. I guess the specific reason should be that there...

  • WenChao Xu WenChao Xu modified a comment on discussion General Discussion

    Dear Andreas Völz, I tested it, and did the same test with another model, and it seems the result is still not good. I'm checking to see if there are any errors. Best regards WenChao Xu.

  • WenChao Xu WenChao Xu posted a comment on discussion General Discussion

    Dear Andreas Völz, I tested it, and did the same test with another model, and it seems the result is still not good. I'm checking to see if there are any errors. Best regards Andreas Völz.

  • Andreas Völz Andreas Völz posted a comment on discussion General Discussion

    Dear WenChao Xu, another idea would be to test the rate limits first for the simpler task of setpoint stabilization. That is, replace the reference trajectory with constant desired values and see whether you can tune the MPC for exponentially decreasing cost. Best regards, Andreas Völz

  • WenChao Xu WenChao Xu modified a comment on discussion General Discussion

    Dear Andreas Völz, Thank you for your reply! Yes, I also implemented dhdx_vec.I'm going to modify the code now. Otherwise, I could try to implement a minimal working example, but it could take some time, since I have a lot of things to do currently. It doesn't matter, you just do your own thing, don't spend time writing examples. I hope you will become an academic leader soon, thank you 💖 Best regards, WenChao Xu.

  • WenChao Xu WenChao Xu modified a comment on discussion General Discussion

    Dear Andreas Völz, Thank you for your reply! Yes, I also implemented dhdx_vec.I'm going to modify the code now. Otherwise, I could try to implement a minimal working example, but it could take some time, since I have a lot of things to do currently. It doesn't matter, you are busy with your own work, I will be very grateful if you can reply! I hope you will become an academic leader soon. thank you 💖 Best regards, WenChao Xu.

  • WenChao Xu WenChao Xu modified a comment on discussion General Discussion

    Dear Andreas Völz, Thank you for your reply! Yes, I also implemented dhdx_vec.I'm going to modify the code now. Otherwise, I could try to implement a minimal working example, but it could take some time, since I have a lot of things to do currently. It doesn't matter, you are busy with your own work, I hope you will become an academic leader soon, I will be very grateful if you can reply! Thank you 💖 Best regards, WenChao Xu.

  • WenChao Xu WenChao Xu posted a comment on discussion General Discussion

    Dear Andreas Völz, Thank you for your reply! Yes, I also implemented dhdx_vec.I'm going to modify the code now. Best regards, WenChao Xu.

1 >