chris
August 11, 2020, 12:54pm
1
Hi alltogether,
I am new to acados and trying to set up my first running example. I would like to use a linear least squares term and provide a time varying reference y_ref similar to:
http://acado.sourceforge.net/matlab/doc/html/matlab/acado/packages/+acado/@OCP/minimizeLSQ.html
I checked all the matlab examples, but I could not find an example as all of them use a constant y_ref over the horizon. Also all my tries where not successful.
Do you know how to provide a time varying reference?
Thanks a lot!
FreyJo
August 12, 2020, 10:07am
2
Hi Chris,
welcome to the forum!
You can set the y_ref
value stage wise after creating the solver, as it is done here:
% change number of sqp iterations
ocp.set('nlp_solver_max_iter', 20);
% modify numerical data for a certain stage
some_stages = 1:10:N-1;
for i = some_stages
if (strcmp(cost_type, 'linear_ls'))
ocp.set('cost_Vx', Vx, i); % cost_y_ref, cost_Vu, cost_Vx, cost_W, cost_Z, cost_Zl,...
% cost_Zu, cost_z, cost_zl, cost_zu;
ocp.set('cost_Vu', Vu, i);
ocp.set('cost_y_ref', yr, i);
end
if ng > 0
ocp.set('constr_C', C, i);
ocp.set('constr_D', D, i);
ocp.set('constr_ug', ubu, i);
ocp.set('constr_lg', lbu, i);
end
end
% solve
Cheers,
Jonathan
chris
August 14, 2020, 8:17am
3
Hey Jonathan,
thank you for your quick response! In this example the reference is passed in a loop scalar-wise. Is there a possibility to pass it as a vector in one function call?
Greetings
Christian
FreyJo
August 14, 2020, 9:01am
4
If you want to set the same y_ref value for multiple subsequent stages, say stage s0
to stage se
.
You can do something like this:
ocp.set('cost_y_ref', yr, s0, se);
Otherwise, you will have to use multiple function calls.
Cheers
2 Likes