Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
sot-dynamic-pinocchio
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
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
Stack Of Tasks
sot-dynamic-pinocchio
Commits
9ec03e46
Commit
9ec03e46
authored
14 years ago
by
Florent Lamiraux
Browse files
Options
Downloads
Patches
Plain Diff
Set right hand parameters by symmetry in global reference frame.
* src/dynamic_graph/sot/dynamics/parser.py.
parent
49ec58ae
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!1
[major][cpp] starting point to integrate pinocchio
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/dynamic_graph/sot/dynamics/parser.py
+59
-7
59 additions, 7 deletions
src/dynamic_graph/sot/dynamics/parser.py
with
59 additions
and
7 deletions
src/dynamic_graph/sot/dynamics/parser.py
+
59
−
7
View file @
9ec03e46
...
...
@@ -95,6 +95,11 @@ class Parser (object):
self
.
entity
.
setHandParameters
(
False
,
handCenter
,
thumbAxis
,
forefingerAxis
,
palmNormal
)
# Compute values for right hand
handCenter
=
self
.
handSymmetry
(
handCenter
)
thumbAxis
=
self
.
handSymmetry
(
thumbAxis
)
forefingerAxis
=
self
.
handSymmetry
(
forefingerAxis
)
palmNormal
=
self
.
handSymmetry
(
palmNormal
)
self
.
entity
.
setHandParameters
(
True
,
handCenter
,
thumbAxis
,
forefingerAxis
,
palmNormal
)
...
...
@@ -104,10 +109,10 @@ class Parser (object):
anklePosition
=
(
self
.
ANKLEPOSINLEFTFOOTFRAMEX
,
self
.
ANKLEPOSINLEFTFOOTFRAMEY
,
self
.
ANKLEPOSINLEFTFOOTFRAMEZ
)
self
.
entity
.
setFootParameters
(
False
,
soleLength
,
soleWidth
,
anklePosition
)
# Gaze parameters.
gazeOrigin
=
(
self
.
GAZEORIGINX
,
self
.
GAZEORIGINY
,
self
.
GAZEORIGINZ
)
gazeDirection
=
(
self
.
GAZEDIRECTIONX
,
self
.
GAZEDIRECTIONY
,
...
...
@@ -120,7 +125,6 @@ class Parser (object):
def
createJoint
(
self
,
node
,
parentName
):
sotJointType
=
self
.
jointType
[
node
.
nodeName
]
jointName
=
self
.
findStringProperty
(
node
,
'
NAME
'
)
print
(
'
jointName = %s
'
%
repr
(
jointName
))
properties
=
{}
for
p
in
self
.
jointFloatProperties
:
try
:
...
...
@@ -131,6 +135,12 @@ class Parser (object):
properties
[
p
]
=
0.
position
=
self
.
findJointPosition
(
node
)
# Remember position of wrists.
if
jointName
==
self
.
LEFTWRIST
:
self
.
leftWristPosition
=
position
[:]
if
jointName
==
self
.
RIGHTWRIST
:
self
.
rightWristPosition
=
position
[:]
# Find dof bounds.
bounds
=
self
.
findJointBounds
(
node
,
jointName
)
self
.
entity
.
createJoint
(
jointName
,
sotJointType
,
position
)
...
...
@@ -211,8 +221,6 @@ class Parser (object):
properties
=
filter
(
lambda
n
:
n
.
nodeName
==
'
PROPERTY
'
,
node
.
childNodes
)
theProperty
=
filter
(
lambda
p
:
p
.
_attrs
[
'
stringId
'
].
nodeValue
==
prop
,
properties
)
#print ('THE PROPERTY: %s' % prop)
#print (theProperty)
if
len
(
theProperty
)
!=
1
:
raise
RuntimeError
(
prop
+
'
should be specified once and only once.
'
)
...
...
@@ -223,8 +231,6 @@ class Parser (object):
raise
RuntimeError
(
'
One and only one name should be specified for
'
+
prop
)
value
=
value
[
0
]
#print ('VALUE: %s' % value.data)
#print ('cast(VALUE): %s' % cast(value.data))
return
cast
(
value
.
data
)
def
findJointPosition
(
self
,
node
):
...
...
@@ -256,3 +262,49 @@ class Parser (object):
# transform list into tuple
return
tuple
(
map
(
tuple
,
matrix
))
def
handSymmetry
(
self
,
vector
):
"""
Conversion of local coordinates from left hand to right hand
Input:
- a vector: locally expressed in the local frame of left wrist,
Return:
- a vector: locally expressed in the local frame of the right wrist.
The conversion is done in such a way that input and output are
symmetric with respect to plane (xz) in global frame.
"""
# input vector expressed in global frame
vector
=
vector
+
(
1.
,)
globalLeftVector
=
mv_mul
(
self
.
leftWristPosition
,
vector
)
globalRightVector
=
list
(
globalLeftVector
[:])
globalRightVector
[
1
]
*=
-
1.
output
=
mv_mul
(
inverseHomogeneous
(
self
.
rightWristPosition
),
globalRightVector
)
return
output
[:
3
]
def
mv_mul
(
matrix
,
vector
):
"""
Matrix vector multiplication
"""
return
tuple
(
map
(
lambda
l
:
inner_prod
(
l
,
vector
),
matrix
))
def
inner_prod
(
v1
,
v2
):
"""
Compute the inner product of two vectors
"""
return
reduce
(
lambda
x
,
y
:
x
+
y
[
0
]
*
y
[
1
],
zip
(
v1
,
v2
),
0
)
def
inverseHomogeneous
(
matrix
):
"""
Compute the inverse of an homogeneous matrix
"""
rotation
=
map
(
lambda
l
:
l
[:
3
],
matrix
[:
3
])
# transpose
invRot
=
tuple
(
zip
(
*
rotation
))
# translation part
t
=
map
(
lambda
l
:
l
[
3
],
matrix
[:
3
])
invRot_by_t
=
mv_mul
(
invRot
,
t
)
inverse
=
map
(
lambda
x
:
list
(
x
[
0
])
+
[
-
x
[
1
]],
zip
(
invRot
,
invRot_by_t
))
inverse
.
append
((
0.
,
0.
,
0.
,
1.
))
return
tuple
(
map
(
tuple
,
inverse
))
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