Skip to content

Commit c100de4

Browse files
fixing adaptive rho code gen
1 parent a9e3d58 commit c100de4

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

examples/quadrotor_hover_code_generation.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
addpath(fullfile(repoRoot, 'build'));
1212

1313
% Enable or disable adaptive rho
14-
ENABLE_ADAPTIVE_RHO = true; % Set true to enable adaptive rho
14+
ENABLE_ADAPTIVE_RHO = false; % Set true to enable adaptive rho
1515

1616
% Quadrotor system matrices (12 states, 4 inputs)
1717
rho_value = 5.0;

src/TinyMPC.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ function setup(obj, A, B, Q, R, N, varargin)
9191

9292
if status == 0
9393
obj.is_setup = true;
94+
95+
% Push settings to C++ layer (including adaptive_rho settings)
96+
tinympc_matlab('update_settings', obj.settings.abs_pri_tol, obj.settings.abs_dua_tol, ...
97+
obj.settings.max_iter, obj.settings.check_termination, obj.settings.en_state_bound, ...
98+
obj.settings.en_input_bound, obj.settings.adaptive_rho, obj.settings.adaptive_rho_min, ...
99+
obj.settings.adaptive_rho_max, obj.settings.adaptive_rho_enable_clipping, false);
100+
94101
if opts.verbose, fprintf('TinyMPC solver setup successful (nx=%d, nu=%d, N=%d)\n', obj.nx, obj.nu, obj.N); end
95102
else
96103
error('TinyMPC:SetupFailed', 'Setup failed with status %d', status);

0 commit comments

Comments
 (0)