Error flag for infeasibility in nonlinear mpc.

6 visualizaciones (últimos 30 días)
Tristan
Tristan el 10 de En. de 2025
Editada: Tristan el 10 de En. de 2025
I am getting the error flag -2 for my nonlinear mpc design despite their being no constraints. If there is no constraints, how is there infeasibility? The only way I can get it to be feasible is to make the intial condition the exact same as the reference. If there is deviation the problem is infeasible
clear all
nx = 4;
ny = 2;
nu = 3;
nlobj = nlmpc(nx,ny,nu);
nlobj.Ts = 0.1;
nlobj.PredictionHorizon = 10;
nlobj.ControlHorizon = 10;
nlobj.Model.StateFcn = @mystateFunctionREDUCED;
nlobj.Model.IsContinuousTime = true;
nlobj.Model.NumberOfParameters = 5;
rho = 0.1;
l = 1/2*1*rho^2;
%T = params(3);
g = 9.81;
J = 0.015;
m = 2;
nlobj.Model.OutputFcn = @OutputFcn
nlobj =
nlmpc with properties: Ts: 0.1000 PredictionHorizon: 10 ControlHorizon: 10 Dimensions: [1x1 struct] Model: [1x1 struct] States: [1x4 struct] OutputVariables: [1x2 struct] ManipulatedVariables: [1x3 struct] MeasuredDisturbances: [] Weights: [1x1 struct] Optimization: [1x1 struct] Jacobian: [1x1 struct] Passivity: [1x1 struct]
;
x0 = [1;0;pi/8;0];
mv = [m*g+1; 0; 0];
lastMV = mv;
%validateFcns(nlobj, x0, u0, [], {rho,l,g,J,m});
nloptions = nlmpcmoveopt;
nloptions.Parameters = {rho,l,g,J,m};
Duration = 1;
Ts = 0.01;
xHistory = x0';
yref = [1;pi/9];
%nlobj.Weights.OutputVariables = [3 3];
%nlobj.Weights.ManipulatedVariablesRate = 0.1;
% nlobj.States(1).Min = 0;
% nlobj.States(1).Max = 20;
% nlobj.States(3).Min = 0;
% nlobj.States(3).Max = pi;
%nlobj.Optimization.CustomIneqConFcn = "myIneqConFunctionreduced";
nlobj.Weights.ManipulatedVariablesRate = [0 0 0];
nlobj.Weights.OutputVariables = [1 1];
%nlobj.Weights.ECR = 0;
Tarray = [];
Uarray = [];
for k = 1:(Duration/Ts)
xk = xHistory(k,:);
% Compute optimal control moves
[mv,nloptions,info] = nlmpcmove(nlobj,xk,lastMV,yref',[],nloptions);
info
%disp(mv)
% Implement first optimal control move
ODEFUN = @(t,xk) statefcn(xk,mv);
[TOUT,XOUT] = ode45(ODEFUN,[0 Ts], xHistory(k,:)');
x0 = mystateFunctionREDUCED(x0,mv,rho,l,g,J,m)*Ts+x0;
uHistory(k+1,:) = mv';
lastMV = mv;
%[t,y] = ode15s(@mystateFunction,[0 Ts],[2 0]);
%T = (m*x0(1)*x0(4)^2-m*g*sin(x0(3))+mv(1)*sin(x0(3)+x0(5))-m*rho/l*mv(3))/(1+m*rho^2/l);
%Tarray = [Tarray T];
Uarray = [Uarray mv];
xHistory(k+1,:) = XOUT(end,:);
%opt.Slack0
%T
%par = m*x0(1).*x0(4).^2-m*g*sin(x0(3))
% Save plant states
%xHistory = [xHistory x0];
end
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 4.5082e-04
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0022
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0011
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0016
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0011
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0026
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 9.0921e-04
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0043
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0015
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0016
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0012
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0043
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 376 Cost: 0.0038
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0039
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0038
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0044
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0033
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0058
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 368 Cost: 0.0070
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0078
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0080
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0135
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0106
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0131
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0106
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0147
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0164
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0207
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0126
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0370
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0264
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0391
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0292
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0378
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0405
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0364
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0793
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0909
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0338
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.1120
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0730
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.1066
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 396 Cost: 0.2542
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0513
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 49 Cost: 2.7287
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0394
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 371 Cost: 1.3647
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.0235
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 1.0635
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 3.3331e-15 ExitFlag: -2 Iterations: 127 Cost: 0.3550
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 3.1137e-05 ExitFlag: -2 Iterations: 400 Cost: 0.2180
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 6.4044e-07 ExitFlag: -2 Iterations: 400 Cost: 0.1319
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 1.4371e-06 ExitFlag: -2 Iterations: 400 Cost: 0.2906
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 1.9936e-05 ExitFlag: -2 Iterations: 400 Cost: 0.2929
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.4622
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.4848
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.5704
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 3.0889e-15 ExitFlag: -2 Iterations: 41 Cost: 7.1638
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 1.1860e-04 ExitFlag: -2 Iterations: 400 Cost: 1.3670
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 1.3120e-05 ExitFlag: -2 Iterations: 400 Cost: 1.0134
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 1.0949
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 0.6708
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 365 Cost: 1.6059
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 7.2360
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 24 Cost: 9.9478
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 149 Cost: 22.8306
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 197 Cost: 5.6771
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 33 Cost: 34.2812
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 2.9394
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 5.7473e-21 ExitFlag: -2 Iterations: 172 Cost: 84.2870
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 3.8706e-05 ExitFlag: -2 Iterations: 165 Cost: 10.4991
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 3.8645e-05 ExitFlag: -2 Iterations: 4 Cost: 12.4464
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 1.9083e-05 ExitFlag: -2 Iterations: 48 Cost: 10.5646
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 4.5863e-04 ExitFlag: -2 Iterations: 400 Cost: 24.6209
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 1.2483e-05 ExitFlag: -2 Iterations: 83 Cost: 6.9594
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 3.0035e-05 ExitFlag: -2 Iterations: 400 Cost: 4.8111
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 5.2929e-05 ExitFlag: -2 Iterations: 400 Cost: 11.6251
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 2.4589e-04 ExitFlag: -2 Iterations: 400 Cost: 5.1267
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 1.6663e-04 ExitFlag: -2 Iterations: 367 Cost: 18.6652
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 2.0743
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 16.6244
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 20.4956
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 157 Cost: 9.0522
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 8.0570
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 313 Cost: 7.4180
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 4.9903
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 16.4311
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 3.9882
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 75.0001
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 3.7069
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 135 Cost: 22.3938
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 4.2439
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 3.4832
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 5.3102
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 6.0702
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0 ExitFlag: -2 Iterations: 400 Cost: 8.5846
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 8.2603e-18 ExitFlag: -2 Iterations: 170 Cost: 1.8330
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 3.8335e-04 ExitFlag: -2 Iterations: 400 Cost: 5.1176
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 4.1342e-05 ExitFlag: -2 Iterations: 400 Cost: 27.6394
info = struct with fields:
MVopt: [11x3 double] Xopt: [11x4 double] Yopt: [11x2 double] Topt: [11x1 double] Slack: 0.0223 ExitFlag: -2 Iterations: 252 Cost: 110.2286
function z = mystateFunctionREDUCED(x,u,rho,l,g,J,m)
z = zeros(4,1);
% rho = params(1);
% l = params(2);
% %T = params(3);
% g = params(3);
% J = params(4);
% m = params(5);
z(1) = x(2);
z(2) = (rho/l*u(3)+(rho^2/l)*(m*x(1)*x(4)^2-m*g*sin(x(3)+u(1)*sin(x(3)+u(2)))))/(1+rho^2*m/l);
z(3) = x(4);
z(4) = (-1/x(1))*(2*x(2)*x(4)+g*cos(x(3)))+1/(m*x(1))*u(1)*cos(x(3)+u(2));
end
function y = OutputFcn(x,u,rho,l,g,J,m)
y = zeros(2,1);
y(1) = x(1);
y(2) = x(3);
end
function f = statefcn(in1,in2)
%QuadrotorStateFcn
% F = QuadrotorStateFcn(IN1,IN2)
% This function was generated by the Symbolic Math Toolbox version 24.1.
% 09-Jan-2025 19:28:44
rho = 0.1;
l = 1/2*1*rho^2;
%T = params(3);
g = 9.81;
J = 0.015;
m = 2;
x = in1;
u = in2;
z(1) = x(2);
z(2) = (rho/l*u(3)+(rho^2/l)*(m*x(1)*x(4)^2-m*g*sin(x(3)+u(1)*sin(x(3)+u(2)))))/(1+rho^2*m/l);
z(3) = x(4);
z(4) = (-1/x(1))*(2*x(2)*x(4)+g*cos(x(3)))+1/(m*x(1))*u(1)*cos(x(3)+u(2));
f = [z(1);z(2);z(3);z(4)];
end

Respuestas (0)

Categorías

Más información sobre Model Predictive Control Toolbox en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by