I am working on a quadrotor 3dof ,and I have a problem with block nmpc can you help me?

9 Ansichten (letzte 30 Tage)
Zero weights are applied to one or more OVs because there are fewer MVs than OVs.
Slack variable unused or zero-weighted in your custom cost function.
All constraints will be hard.
Model.StateFcn is OK.
Jacobian.StateFcn is OK.
Warning: Jacobian matrix with respect to "x" has maximum error = 3.9315 occurring at "(4,4)".
> In ctrlMsgUtils.warning (line 25)
In nlmpc/validateFcns>compareJac (line 378)
In nlmpc/validateFcns (line 175)
In Quadrotor6dof (line 60)
Warning: Jacobian matrix with respect to "umv" has maximum error = 0.45637 occurring at "(4,1)".
> In ctrlMsgUtils.warning (line 25)
In nlmpc/validateFcns>compareJac (line 378)
In nlmpc/validateFcns (line 176)
In Quadrotor6dof (line 60)
No output function specified. Assuming "y = x" in the prediction model.
Optimization.CustomCostFcn is OK.
Analysis of user-provided model, cost, and constraint functions complete.
Error using Quadrotor6dof (line 67)
Expected "ref" to be an array with number of columns equal to 6.
Error in nmpcblock_interface.m (line 165)
throw(ME)
Error in Quadrotor6dof.m (line 67)
Error in 's_hover_nmpc/Nonlinear MPC Controller/MPC/NLMPC' (line 24)
  1 Kommentar
Ibrahim
Ibrahim am 1 Apr. 2024
Bearbeitet: Sam Chak am 1 Apr. 2024
nx = 6;
ny = 6;
nu = 4;
nlobj = nlmpc(nx, ny, nu);
%nlobj = nlmpc(6,6,'MV',4,'MD',1,'UD',4)
nlobj.Model.StateFcn = "QuadrotorStateFcn";
nlobj.Jacobian.StateFcn = @QuadrotorStateJacobianFcn;
% nlobj.Model.OutputFcn = 'QuadrotorOutputFcn';
% nlobj.Model.OutputFcn = @(x,u,Ts) [x(1); x(3);x(5)];
rng(0)
% u=[1 1 1 1];
% validateFcns(nlobj,rand(nx,1),rand(nu,1));
Ts = 25;
p = 18;
m = 18;
% nlobj.Ts = Ts;
% nlobj.PredictionHorizon = p;
% nlobj.ControlHorizon = m;
% nlobj.MV = struct('Min',{0;0;0;0},'Max',{6;6;6;6});
% nlobj.MV = struct( ...
% Min={0;0;0;0}, ...
% Max={6;6;6;6}, ...
% RateMin={-2;-2;-2;-2}, ...
% RateMax={2;2;2;2} ...
% );
% nlobj.Model.NumberOfParameters = 1;
% nlobj.Weights.OutputVariables = [1 1 1 0 0 0];
% nlobj.Weights.ManipulatedVariables = [0.1 0.1 0.1 0.1];
% nlobj.Weights.ManipulatedVariablesRate = [0.1 0.1 0.1 0.1];
%%%%%%%%%%
nlobj.Ts = Ts;
nlobj.PredictionHorizon = p;
nlobj.ControlHorizon = m;
nlobj.MV = struct('Min', {0; 0; 0; 0}, 'Max', {6; 6; 6; 6});
nlobj.MV = struct( ...
Min = { 0; 0; 0; 0}, ...
Max = { 6; 6; 6; 6}, ...
RateMin = {-2; -2; -2; -2}, ...
RateMax = { 2; 2; 2; 2} ...
);
%nlobj.Model.NumberOfParameters = 1;
nlobj.Weights.OutputVariables = [0.1 0.1 0.1 0 0 0];
nlobj.Weights.ManipulatedVariables = [0.1 0.1 0.1 0.1];
nlobj.Weights.ManipulatedVariablesRate = [0.1 0.1 0.1 0.1];
% Specify the initial conditions
x = [0;0;0;0;0;0];
nlobj.Optimization.CustomCostFcn = @(X, U, e, data) Ts*sum(sum(U(1:p, :)));
nlobj.Optimization.ReplaceStandardCost = true;
% Nominal control target (average to keep quadrotor floating)
nloptions = nlmpcmoveopt;
nloptions.MVTarget = [4.9 4.9 4.9 4.9];
mv = nloptions.MVTarget;
% mv = nlmpcmove(nlobj,x,lastmv,ref);
lastmv = mv;
md = 0;
% ref=[1 0 0; 0 1 0; 0 0 1; 0 0 0; 0 0 0; 0 0 0];
% nlmpcmoveopt.options.Parameters={Ts x};
ref = zeros(1, nlobj.ny);
[mv, ~, Info] = nlmpcmove(nlobj, x, lastmv,ref);
validateFcns(nlobj, rand(nx, 1), rand(nu, 1));

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Earth and Planetary Science finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by