You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to write to code a simple Control Lyapunov Function based controller in MATLAB, and came across an error message saying I needed to allow "free_variables".
Initialization failed since variables [delta] are free. These
symbols occur in the output expressions but you forgot to declare
these as inputs. Set option 'allow_free' to allow free variables.
Error in untitled5 (line 44)
solver = qpsol('solver', 'mosek', qp_prob, opts);
And when I tried to parse this option to qpsol, nothing seems to change and I still get the same error.
% ---- Decision variables ----
X = SX.sym('X', nx); %multiple state variables
U = SX.sym('U', nu); %multiple control variables
delta = SX.sym('delta');
% ---- CLF variables ----
rho = 1; % Relative importance of u cost and x cost
gamma = 1; % How fast to converge
w = 1; % How agressive the controller is
% ---- Compute solution symbolically, objective and constraints ----
obj = U^2 + rho*delta^2;
g = (2*(X(1)-ref)*X(2) + 0.5*w*X(2)^2) + (0.5*w*(X(1)-ref) + 2*w*X(2))*U + delta + gamma * ((X(1)-ref)^2 + 0.5*w*(X(1)-ref)*X(2) + w*X(2)^2);
% ---- Set solver options ----
OPT_variables = [X', U];
opts = struct;
opts.allow_free = true;
qp_prob = struct('f', obj, 'x', OPT_variables, 'g', g);
solver = qpsol('solver', 'mosek', qp_prob, opts);
Am I doing something wrong? Do I need to declare this option somewhere else in a different way?
Any help is greatly appreciated.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello everyone.
I was trying to write to code a simple Control Lyapunov Function based controller in MATLAB, and came across an error message saying I needed to allow "free_variables".
And when I tried to parse this option to qpsol, nothing seems to change and I still get the same error.
Am I doing something wrong? Do I need to declare this option somewhere else in a different way?
Any help is greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions