8000 MATLAB: Blazing MOCP example by FreyJo · Pull Request #1270 · acados/acados · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

MATLAB: Blazing MOCP example #1270

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

function ocp = create_ocp_formulation(p_global, m, l, C, lut, use_p_global, p_global_values)
function ocp = create_ocp_formulation_without_opts(p_global, m, l, C, lut, use_p_global, p_global_values)
ocp = AcadosOcp();

% Set model
Expand Down Expand Up @@ -43,21 +43,6 @@

ocp.constraints.x0 = [0.0; pi; 0.0; 0.0];

% Set options
Tf = 1.0;
N_horizon = 20;

ocp.solver_options.qp_solver = 'PARTIAL_CONDENSING_HPIPM';
ocp.solver_options.hessian_approx = 'GAUSS_NEWTON';
ocp.solver_options.integrator_type = 'ERK';
ocp.solver_options.print_level = 0;
ocp.solver_options.nlp_solver_type = 'SQP_RTI';

ocp.solver_options.tf = Tf;
ocp.solver_options.N_horizon = N_horizon;
% NOTE: these additional flags are required for code generation of CasADi functions using casadi.blazing_spline
ocp.solver_options.ext_fun_compile_flags = ['-I' casadi.GlobalOptions.getCasadiIncludePath ' -ffast-math -march=native '];

% Parameters
ocp.parameter_values = 9.81;

Expand Down
50 changes: 35 additions & 15 deletions examples/acados_matlab_octave/p_global_example/main.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ function main()
[p_global, m, l, C, p_global_values] = create_p_global(lut);

% OCP formulation
ocp = create_ocp_formulation(p_global, m, l, C, lut, use_p_global, p_global_values);
ocp = create_ocp_formulation_without_opts(p_global, m, l, C, lut, use_p_global, p_global_values);
ocp = set_solver_options(ocp);

% OCP solver
ocp_solver = AcadosOcpSolver(ocp);
Expand Down Expand Up @@ -141,30 +142,49 @@ function main()
end


function mocp = create_mocp_formulation(p_global, m, l, C, lut, use_p_global, p_global_values)
function ocp = set_solver_options(ocp)
% set options
ocp.solver_options.qp_solver = 'PARTIAL_CONDENSING_HPIPM';
ocp.solver_options.hessian_approx = 'GAUSS_NEWTON';
ocp.solver_options.integrator_type = 'ERK';
ocp.solver_options.print_level = 0;
ocp.solver_options.nlp_solver_type = 'SQP_RTI';

% set prediction horizon
Tf = 1.0;
N_horizon = 20;
ocp.solver_options.tf = Tf;
ocp.solver_options.N_horizon = N_horizon;

% Set options
ocp.solver_options.qp_solver = 'PARTIAL_CONDENSING_HPIPM';
ocp.solver_options.hessian_approx = 'GAUSS_NEWTON';
ocp.solver_options.integrator_type = 'ERK';
ocp.solver_options.print_level = 0;
ocp.solver_options.nlp_solver_type = 'SQP_RTI';

% partial condensing
ocp.solver_options.qp_solver_cond_N = 5;
ocp.solver_options.qp_solver_cond_block_size = [3, 3, 3, 3, 7, 1];

% NOTE: these additional flags are required for code generation of CasADi functions using casadi.blazing_spline
ocp.solver_options.ext_fun_compile_flags = ['-I' casadi.GlobalOptions.getCasadiIncludePath ' -ffast-math -march=native '];
end

function mocp = create_mocp_formulation(p_global, m, l, C, lut, use_p_global, p_global_values)

N_horizon_1 = 10;
N_horizon_2 = 10;
N_horizon = N_horizon_1 + N_horizon_2;
mocp = AcadosMultiphaseOcp([N_horizon_1, N_horizon_2]);
ocp_phase_1 = create_ocp_formulation(p_global, m, l, C, lut, use_p_global, p_global_values);
ocp_phase_2 = create_ocp_formulation(p_global, m, l, C, lut, use_p_global, p_global_values);
ocp_phase_1 = create_ocp_formulation_without_opts(p_global, m, l, C, lut, use_p_global, p_global_values);
ocp_phase_2 = create_ocp_formulation_without_opts(p_global, m, l, C, lut, use_p_global, p_global_values);

mocp = set_solver_options(mocp);

mocp.set_phase(ocp_phase_1, 1);
mocp.set_phase(ocp_phase_2, 2);

% set options
mocp.solver_options.qp_solver = 'PARTIAL_CONDENSING_HPIPM';
mocp.solver_options.hessian_approx = 'GAUSS_NEWTON';
mocp.solver_options.integrator_type = 'ERK';
mocp.solver_options.print_level = 0;
mocp.solver_options.nlp_solver_type = 'SQP_RTI';

% set prediction horizon
mocp.solver_options.tf = Tf;
mocp.solver_options.N_horizon = N_horizon;

end


Expand Down
Loading
0