Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
robotics-codes-from-scratch
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
rli
robotics-codes-from-scratch
Commits
815131e2
Commit
815131e2
authored
5 months ago
by
Sylvain CALINON
Browse files
Options
Downloads
Patches
Plain Diff
R2q() fixed in all python examples
parent
03b78b60
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
python/IK_manipulator3D.py
+1
-1
1 addition, 1 deletion
python/IK_manipulator3D.py
python/iLQR_manipulator3D.py
+4
-6
4 additions, 6 deletions
python/iLQR_manipulator3D.py
with
5 additions
and
7 deletions
python/IK_manipulator3D.py
+
1
−
1
View file @
815131e2
...
@@ -125,7 +125,7 @@ def R2q(R):
...
@@ -125,7 +125,7 @@ def R2q(R):
[
R
[
1
,
2
]
-
R
[
2
,
1
],
R
[
2
,
0
]
-
R
[
0
,
2
],
R
[
0
,
1
]
-
R
[
1
,
0
],
R
[
0
,
0
]
+
R
[
1
,
1
]
+
R
[
2
,
2
]],
[
R
[
1
,
2
]
-
R
[
2
,
1
],
R
[
2
,
0
]
-
R
[
0
,
2
],
R
[
0
,
1
]
-
R
[
1
,
0
],
R
[
0
,
0
]
+
R
[
1
,
1
]
+
R
[
2
,
2
]],
])
/
3.0
])
/
3.0
e_val
,
e_vec
=
np
.
linalg
.
eig
(
K
)
e_val
,
e_vec
=
np
.
linalg
.
eig
(
K
)
# unsorted eigenvalues
q
=
np
.
real
([
e_vec
[
3
,
np
.
argmax
(
e_val
)],
*
e_vec
[
0
:
3
,
np
.
argmax
(
e_val
)]])
# for quaternions as [w,x,y,z]
q
=
np
.
real
([
e_vec
[
3
,
np
.
argmax
(
e_val
)],
*
e_vec
[
0
:
3
,
np
.
argmax
(
e_val
)]])
# for quaternions as [w,x,y,z]
return
q
return
q
...
...
This diff is collapsed.
Click to expand it.
python/iLQR_manipulator3D.py
+
4
−
6
View file @
815131e2
...
@@ -120,9 +120,7 @@ def R2q(R):
...
@@ -120,9 +120,7 @@ def R2q(R):
[
R
[
2
,
0
]
+
R
[
0
,
2
],
R
[
2
,
1
]
+
R
[
1
,
2
],
R
[
2
,
2
]
-
R
[
0
,
0
]
-
R
[
1
,
1
],
R
[
0
,
1
]
-
R
[
1
,
0
]],
[
R
[
2
,
0
]
+
R
[
0
,
2
],
R
[
2
,
1
]
+
R
[
1
,
2
],
R
[
2
,
2
]
-
R
[
0
,
0
]
-
R
[
1
,
1
],
R
[
0
,
1
]
-
R
[
1
,
0
]],
[
R
[
1
,
2
]
-
R
[
2
,
1
],
R
[
2
,
0
]
-
R
[
0
,
2
],
R
[
0
,
1
]
-
R
[
1
,
0
],
R
[
0
,
0
]
+
R
[
1
,
1
]
+
R
[
2
,
2
]],
[
R
[
1
,
2
]
-
R
[
2
,
1
],
R
[
2
,
0
]
-
R
[
0
,
2
],
R
[
0
,
1
]
-
R
[
1
,
0
],
R
[
0
,
0
]
+
R
[
1
,
1
]
+
R
[
2
,
2
]],
])
/
3.0
])
/
3.0
e_val
,
e_vec
=
np
.
linalg
.
eig
(
K
)
# unsorted eigenvalues
e_val
,
e_vec
=
np
.
linalg
.
eig
(
K
)
# /!\ With numpy eigenvalues are not sorted!
q
=
np
.
real
([
e_vec
[
3
,
np
.
argmax
(
e_val
)],
*
e_vec
[
0
:
3
,
np
.
argmax
(
e_val
)]])
# for quaternions as [w,x,y,z]
q
=
np
.
real
([
e_vec
[
3
,
np
.
argmax
(
e_val
)],
*
e_vec
[
0
:
3
,
np
.
argmax
(
e_val
)]])
# for quaternions as [w,x,y,z]
return
q
return
q
...
@@ -172,7 +170,7 @@ param.dh.r = [0, 0, 0, 0.0825, -0.0825, 0, 0.088, 0] # Length of the common norm
...
@@ -172,7 +170,7 @@ param.dh.r = [0, 0, 0, 0.0825, -0.0825, 0, 0.088, 0] # Length of the common norm
# Precision matrix
# Precision matrix
# Q = np.identity((param.nbVarF-1) * param.nbPoints) # Full precision matrix
# Q = np.identity((param.nbVarF-1) * param.nbPoints) # Full precision matrix
Qr
=
np
.
diag
(
[
1.0
,
1.0
,
1.0
,
1.0
,
1.0
,
0.0
]
*
param
.
nbPoints
)
# Precision matrix in relative coordinate frame (tool frame) (by removing orientation constraint on 3rd axis)
Qr
=
np
.
diag
([
1.0
,
1.0
,
1.0
,
1.0
,
1.0
,
0.0
]
*
param
.
nbPoints
)
# Precision matrix in relative coordinate frame (tool frame) (by removing orientation constraint on 3rd axis)
# Control weight matrix (at trajectory level)
# Control weight matrix (at trajectory level)
R
=
np
.
eye
((
param
.
nbData
-
1
)
*
param
.
nbVarU
)
*
param
.
r
R
=
np
.
eye
((
param
.
nbData
-
1
)
*
param
.
nbVarU
)
*
param
.
r
...
@@ -218,10 +216,10 @@ for i in range(param.nbIter):
...
@@ -218,10 +216,10 @@ for i in range(param.nbIter):
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.
p
inv(Su.T @ J.T @ Q @ J @ Su + R) @ (-Su.T @ J.T @ Q @ f - u * param.r) # Gauss-Newton update
#du = np.linalg.inv(Su.T @ J.T @ Q @ J @ Su + R) @ (-Su.T @ J.T @ Q @ f - u * param.r) # Gauss-Newton update
du
=
np
.
linalg
.
lstsq
(
du
=
np
.
linalg
.
lstsq
(
Su
.
T
@
J
.
T
@
Q
@
J
@
Su
+
R
,
Su
.
T
@
J
.
T
@
Q
@
J
@
Su
+
R
,
-
Su
.
T
@
J
.
T
@
Q
@
f
-
u
*
param
.
r
,
-
Su
.
T
@
J
.
T
@
Q
@
f
-
u
*
param
.
r
,
rcond
=-
1
rcond
=-
1
)[
0
]
# Gauss-Newton update
)[
0
]
# Gauss-Newton update
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment