From b0e211b3a6f43446c24cbee3d57028211a150340 Mon Sep 17 00:00:00 2001 From: Nitish Gupta Date: Sun, 12 Sep 2021 16:12:05 -0400 Subject: [PATCH 1/2] replaced coded indices with ModelParams indices --- Matlab/SimTimeStep.m | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Matlab/SimTimeStep.m b/Matlab/SimTimeStep.m index cd8dc66..7da392e 100755 --- a/Matlab/SimTimeStep.m +++ b/Matlab/SimTimeStep.m @@ -44,12 +44,12 @@ l_r = ModelParams.lr; - phi =x(3); - v_x =x(4); - v_y =x(5); - omega =x(6); - D =u(1); - delta =u(2); + phi = x(ModelParams.stateindex_phi); + v_x = x(ModelParams.stateindex_vx); + v_y = x(ModelParams.stateindex_vy); + omega = x(ModelParams.stateindex_omega); + D = u(ModelParams.inputindex_D); + delta = u(ModelParams.inputindex_delta); alpha_f = -atan2(l_f*omega + v_y,abs(v_x))+delta; @@ -69,4 +69,4 @@ u(3)]; -return \ No newline at end of file +return From 8a18b0fc8ed49fb0f602ae602111890bd91f3ebe Mon Sep 17 00:00:00 2001 From: Nitish Gupta Date: Sun, 12 Sep 2021 16:16:45 -0400 Subject: [PATCH 2/2] replaced coded indices with ModelParams indices replaced Xk(1) with Xk(ModelParams.stateindex_x) replaced Xk(1) with Xk(ModelParams.stateindex_y) --- Matlab/getMPCmatrices.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Matlab/getMPCmatrices.m b/Matlab/getMPCmatrices.m index 26b9898..2b56f18 100755 --- a/Matlab/getMPCmatrices.m +++ b/Matlab/getMPCmatrices.m @@ -114,7 +114,7 @@ end theta_virt=mod(Xk(end),pathinfo.ppx.breaks(end)); - [grad_eC, grad_eL] = getErrorGradient(pathinfo, theta_virt, ModelParams,Xk(1), Xk(2)); + [grad_eC, grad_eL] = getErrorGradient(pathinfo, theta_virt, ModelParams, Xk(ModelParams.stateindex_x), Xk(ModelParams.stateindex_y)); errorgrad = [grad_eC; grad_eL]; Qtilde = errorgrad'*Q*errorgrad; end