chenyutao36 / matmpc Goto Github PK
View Code? Open in Web Editor NEWHome Page: https://matmpc-docs.readthedocs.io/en/latest/
License: GNU General Public License v3.0
Home Page: https://matmpc-docs.readthedocs.io/en/latest/
License: GNU General Public License v3.0
Hi,
when following the installation instructions for Windows, the mex_core/compile_hpipm.m script does not run successfully. Turns out that the paths defined in that file do not point to the 'C:\msys64' folder anymore. This change has been introduced with the most recent commit (6291f59
) and I assume that it was not intended this way.
Kind regards & thanks for this awesome tool!
Mario
Hello,
Thank you for the very nice work. This is a great toolbox with a lot of potential.
I have been playing around with the toolbox and while your examples work and some of my models also worked well, I noticed some issues which I could not explain. Basically, in some scenarios, the system does not manage to achieve the target value of the DoF even if it could. It gets close but not quite there and the optimality criterion and the objective become near zero even though we did not quite reach the goal.
I boiled it down to this example. Create an ultra-simple:
You can find the model here:
%% Dimensions
nx=2; % No. of differential states
nu=1; % No. of controls
nz=0; % No. of algebraic states
ny=0; % No. of outputs
nyN=2; % No. of outputs at the terminal point
np=0; % No. of model parameters
nc=0; % No. of general inequality constraints
ncN=0; % No. of general inequality constraints
nbx = 0; % No. of bounds on states
nbu = 1; % No. of bounds on controls
% state and control bounds-+
nbx_idx = []; % indexs of states which are bounded
nbu_idx = 1; % indexs of controls which are bounded
%% create variables
import casadi.*
states = SX.sym('states',nx,1); % differential states
controls = SX.sym('controls',nu,1); % control input
alg = SX.sym('alg',nz,1); % algebraic states
params = SX.sym('paras',np,1); % parameters
refs = SX.sym('refs',ny,1); % references of the first N stages
refN = SX.sym('refs',nyN,1); % reference of the last stage
Q = SX.sym('Q',ny,1); % weighting matrix of the first N stages
QN = SX.sym('QN',nyN,1); % weighting matrix of the last stage
aux = SX.sym('aux',ny,1); % auxilary variable
auxN = SX.sym('auxN',nyN,1); % auxilary variable
%% Dynamics
%Constant
mVal = 2;
p=states(1);
pdot = states(2);
u1=controls(1);% f1
% explicit ODE RHS
x_dot= [pdot;
u1/mVal];
% algebraic function
z_fun = [];
% implicit ODE: impl_f = 0
xdot = SX.sym('xdot',nx,1);
impl_f = xdot - x_dot;
%% Objectives and constraints
% inner objectives
h=[];
hN=[p pdot]';
% outer objectives
obji =0;% 0.5*(h-refs)'*diag(Q)*(h-refs);
objN = 0.5*(hN-refN)'*diag(QN)*(hN-refN);
obji_GGN =0;% 0.5*(aux-refs)'*(aux-refs);
objN_GGN = 0.5*(auxN-refN)'*(auxN-refN);
% general inequality path constraints
general_con = [];
general_con_N = [];
%% NMPC discretizing time length [s]
Ts_st = 0.01; % shooting interval time
In the file initData.m, I set my initial values as follows:
x_ini = zeros(nx,1);
input.x0=x_ini;
input.u0=zeros(nu,1);
input.z0 = zeros(nz,1);
para0 = 0;
q =0;
qN = [1, 1]; % pz pzdot
Q = 0;
QN = qN';
% upper and lower bounds for states (=nbx)
lb_x = [];
ub_x = [];
% upper and lower bounds for controls (=nbu)
lb_u = -1;
ub_u = 1;
% upper and lower bounds for general constraints (=nc)
lb_g = [];
ub_g = [];
lb_gN = [];
ub_gN = [];
And my reference trajectory as:
refss=zeros(1,nx+nu);
refss(1)=0.1;
data.REF=refss;
This is the resulting behaviour (plotting the 1 DoF which should reach 0.1):
And this is the control output. Its is visibly within range:
I tried for several values and I get this behaviour. If I remove all bounds on the control or increase it a lot (ex., 100), I get the expected convergence. But I expect to get the desired convergence within feasible control bounds too. Any explanations or am I doing something wrong?
Thank you
Thank you for your kind sharing. I have tried this code for a fully-actuated multirotor system (modeled as an Euler Lagrange equation). The model and the target should be OK, since I have successfully controlled it using sliding mode control method. The constraints added are only normal boundary conditions. However it finally gets far away from the target. The objective keeps increasing during the whole process and finally goes to very large. I am confused. Do you have any idea about this issue?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.