Skip to content
Snippets Groups Projects
Commit e0aa22d7 authored by Jérémy MACEIRAS's avatar Jérémy MACEIRAS
Browse files

fix: fixed least square computation in iLQR_manipulator3d.py

parent 279a5431
No related branches found
No related tags found
No related merge requests found
...@@ -215,7 +215,13 @@ for i in range(param.nbIter): ...@@ -215,7 +215,13 @@ for i in range(param.nbIter):
Ra[j*nbVarQ:(j+1)*nbVarQ,j*nbVarQ:(j+1)*nbVarQ] = Rkp Ra[j*nbVarQ:(j+1)*nbVarQ,j*nbVarQ:(j+1)*nbVarQ] = Rkp
Q = Ra @ Qr @ Ra.T # Precision matrix in absolute coordinate frame (base frame) Q = Ra @ Qr @ Ra.T # Precision matrix in absolute coordinate frame (base frame)
du = np.linalg.pinv(Su.T @ J.T @ Q @ J @ Su + R) @ (-Su.T @ J.T @ Q @ f - u * param.r) # Gauss-Newton update
#du = np.linalg.pinv(Su.T @ J.T @ Q @ J @ Su + R) @ (-Su.T @ J.T @ Q @ f - u * param.r) # Gauss-Newton update
du = np.linalg.lstsq(
Su.T @ J.T @ Q @ J @ Su + R,
-Su.T @ J.T @ Q @ f - u * param.r ,
rcond=-1
)[0] # Gauss-Newton update
# Estimate step size with backtracking line search method # Estimate step size with backtracking line search method
alpha = 1 alpha = 1
...@@ -234,7 +240,7 @@ for i in range(param.nbIter): ...@@ -234,7 +240,7 @@ for i in range(param.nbIter):
u = u + du * alpha u = u + du * alpha
if np.linalg.norm(du * alpha) < 1E-2: if np.linalg.norm(du * alpha) < 1E-2 or cost < 1.5e-3:
break # Stop iLQR iterations when solution is reached break # Stop iLQR iterations when solution is reached
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment