Parameters Free error while using parameters in constraints

Hi :wave:

I have formulated some constraints with parameters, something like the following:

% xg, yg are SX variables, p is SX parameter
constr_expr_h = [xg-p(1)-L1(1);...
                -(xg- p(1))-L1(1);...
                yg - p(2)-L1(2);...
                -(yg - p(2))-L1(2)];

However i get the following error message stating that I have free variables. The goal is to assign these variables a value at each time step, which I have yet to figure out how.

Error using casadi.Function
Error in Function::Function for 'constr_fun' [SXFunction] at
.../casadi/core/function_internal.cpp:146: Error calling SXFunction::init for
.../casadi/core/sx_function.cpp:476: constr_fun::init: Initialization failed since
variables [p_0p_1] are free. These symbols occur in the output expressions but you
forgot to declare these as inputs. Set option 'allow_free' to allow free

Error in detect_constr (line 86)
    constr_fun = Function('constr_fun', {x, u, z}, {expr_constr});

Error in acados_ocp (line 121)
                obj.model_struct = detect_constr(obj.model_struct, 0);

Error in RT_obs_acados_R1 (line 158)
ocp = acados_ocp(ocp_model,ocp_opts);


you should define those p variables in the acados parameters.


I did define them as parameters in the model function, ocp_model.set(‘sym_p’,p). Is this correct?