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

MATLAB: flat setter example #1420

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 3 commits into from
Jan 15, 2025
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
Expand Up @@ -48,6 +48,12 @@
ocp.constraints.ubu = [u_max];
ocp.constraints.idxbu = [0];

if settings.WITH_X_BOUNDS
ocp.constraints.lbx = [-100, -10];
ocp.constraints.ubx = [100, 10];
ocp.constraints.idxbx = [0, 1];
end

ocp.constraints.x0 = settings.X0;

end
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@
ocp.constraints.ubu = [u_max];
ocp.constraints.idxbu = [0];

if settings.WITH_X_BOUNDS
ocp.constraints.lbx = [-100];
ocp.constraints.ubx = [100];
ocp.constraints.idxbx = [0];

ocp.constraints.lbx_e = [-100];
ocp.constraints.ubx_e = [100];
ocp.constraints.idxbx_e = [0];
end

ocp.constraints.x0 = settings.X0(1);
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@
settings.L2_COST_V = 1e-1;
settings.L2_COST_P = 1e0;
settings.L2_COST_A = 1e-3;
settings.WITH_X_BOUNDS = true;
end
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@


settings = get_example_settings();
settings.WITH_X_BOUNDS = false;

N_list = [10, 1, 15];
n_phases = length(N_list);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,18 @@

ocp_solver = AcadosOcpSolver(ocp);


% initialize x trajectory using flattened format
x0 = ocp.constraints{1}.x0;
x_init = [repmat(x0, 1, N_list(1)+N_list(2)) repmat(x0(1), 1, N_list(3)+1)];

ocp_solver.set('x', x_init);

% update state bounds using flattened format
lbx = [repmat([-10, -5], 1, N_list(1)) repmat([-10], 1, N_list(3)+1)];
ocp_solver.set('constr_lbx', lbx);

% need to set initial state after updating the bounds on x as this again overwrites lbx_0
ocp_solver.set('constr_x0', x0);

ocp_solver.solve();
ocp_solver.print();

Expand Down
Loading
0