Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Stack Of Tasks
pinocchio
Commits
87de6d23
Verified
Commit
87de6d23
authored
Apr 21, 2020
by
Justin Carpentier
Browse files
examples/python: all the examples are now using np.array
parent
a8ca900e
Changes
13
Hide whitespace changes
Inline
Side-by-side
examples/capsule-approximation.py
View file @
87de6d23
...
...
@@ -8,7 +8,6 @@ import numpy as np
import
scipy.optimize
as
optimize
import
hppfcl
hppfcl
.
switchToNumpyArray
()
"""
Capsule definition
...
...
examples/collisions.py
View file @
87de6d23
from
__future__
import
print_function
import
pinocchio
as
pin
,
hppfcl
pin
.
switchToNumpyMatrix
()
import
os
from
os.path
import
dirname
,
join
,
abspath
...
...
examples/display-shapes.py
View file @
87de6d23
...
...
@@ -8,8 +8,6 @@ except ImportError:
sys
.
exit
(
0
)
from
pinocchio.visualize
import
GepettoVisualizer
pin
.
switchToNumpyArray
()
model
=
pin
.
Model
()
geom_model
=
pin
.
GeometryModel
()
...
...
examples/forward-dynamics-derivatives.py
View file @
87de6d23
import
pinocchio
as
pin
pin
.
switchToNumpyMatrix
()
import
numpy
as
np
##
...
...
@@ -16,8 +15,8 @@ data = model.createData()
# Set bounds (by default they are undefinded for a the Simple Humanoid model)
model
.
lowerPositionLimit
=
-
np
.
matrix
(
np
.
ones
((
model
.
nq
,
1
))
)
model
.
upperPositionLimit
=
np
.
matrix
(
np
.
ones
((
model
.
nq
,
1
))
)
model
.
lowerPositionLimit
=
-
np
.
ones
((
model
.
nq
,
1
))
model
.
upperPositionLimit
=
np
.
ones
((
model
.
nq
,
1
))
q
=
pin
.
randomConfiguration
(
model
)
# joint configuration
v
=
np
.
matrix
(
np
.
random
.
rand
(
model
.
nv
,
1
))
# joint velocity
...
...
examples/geometry-models.py
View file @
87de6d23
import
pinocchio
pinocchio
.
switchToNumpyMatrix
()
from
sys
import
argv
from
os.path
import
dirname
,
join
,
abspath
...
...
@@ -44,4 +43,4 @@ for k, oMg in enumerate(collision_data.oMg):
print
(
"
\n
Visual object placements:"
)
for
k
,
oMg
in
enumerate
(
visual_data
.
oMg
):
print
((
"{:d} : {: .2f} {: .2f} {: .2f}"
.
format
(
k
,
*
oMg
.
translation
.
T
.
flat
)))
\ No newline at end of file
.
format
(
k
,
*
oMg
.
translation
.
T
.
flat
)))
examples/gepetto-viewer.py
View file @
87de6d23
...
...
@@ -2,7 +2,6 @@
# usage: launch gepetto-gui and then run this test
import
pinocchio
as
pin
pin
.
switchToNumpyMatrix
()
import
numpy
as
np
import
sys
import
os
...
...
examples/inverse-dynamics-derivatives.py
View file @
87de6d23
import
pinocchio
as
pin
pin
.
switchToNumpyMatrix
()
import
numpy
as
np
##
...
...
@@ -16,12 +15,12 @@ data = model.createData()
# Set bounds (by default they are undefinded for a the Simple Humanoid model)
model
.
lowerPositionLimit
=
-
np
.
matrix
(
np
.
ones
((
model
.
nq
,
1
))
)
model
.
upperPositionLimit
=
np
.
matrix
(
np
.
ones
((
model
.
nq
,
1
))
)
model
.
lowerPositionLimit
=
-
np
.
ones
((
model
.
nq
,
1
))
model
.
upperPositionLimit
=
np
.
ones
((
model
.
nq
,
1
))
q
=
pin
.
randomConfiguration
(
model
)
# joint configuration
v
=
np
.
matrix
(
np
.
random
.
rand
(
model
.
nv
,
1
)
)
# joint velocity
a
=
np
.
matrix
(
np
.
random
.
rand
(
model
.
nv
,
1
)
)
# joint acceleration
v
=
np
.
random
.
rand
(
model
.
nv
,
1
)
# joint velocity
a
=
np
.
random
.
rand
(
model
.
nv
,
1
)
# joint acceleration
# Evaluate the derivatives
...
...
examples/inverse-kinematics.py
View file @
87de6d23
...
...
@@ -4,13 +4,12 @@ import numpy as np
from
numpy.linalg
import
norm
,
solve
import
pinocchio
pinocchio
.
switchToNumpyMatrix
()
model
=
pinocchio
.
buildSampleModelManipulator
()
data
=
model
.
createData
()
JOINT_ID
=
6
oMdes
=
pinocchio
.
SE3
(
p
inocchio
.
utils
.
eye
(
3
),
np
.
matrix
([
1.
,
0.
,
1.
])
.
T
)
oMdes
=
pinocchio
.
SE3
(
n
p
.
eye
(
3
),
np
.
array
([
1.
,
0.
,
1.
]))
q
=
pinocchio
.
neutral
(
model
)
eps
=
1e-4
...
...
examples/kinematics-derivatives.py
View file @
87de6d23
import
pinocchio
as
pin
pin
.
switchToNumpyMatrix
()
import
numpy
as
np
# Create model and data
...
...
@@ -9,12 +8,12 @@ data = model.createData()
# Set bounds (by default they are undefinded)
model
.
lowerPositionLimit
=
-
np
.
matrix
(
np
.
ones
((
model
.
nq
,
1
))
)
model
.
upperPositionLimit
=
np
.
matrix
(
np
.
ones
((
model
.
nq
,
1
))
)
model
.
lowerPositionLimit
=
-
np
.
ones
((
model
.
nq
,
1
))
model
.
upperPositionLimit
=
np
.
ones
((
model
.
nq
,
1
))
q
=
pin
.
randomConfiguration
(
model
)
# joint configuration
v
=
np
.
matrix
(
np
.
random
.
rand
(
model
.
nv
,
1
)
)
# joint velocity
a
=
np
.
matrix
(
np
.
random
.
rand
(
model
.
nv
,
1
)
)
# joint acceleration
v
=
np
.
random
.
rand
(
model
.
nv
,
1
)
# joint velocity
a
=
np
.
random
.
rand
(
model
.
nv
,
1
)
# joint acceleration
# Evaluate all the terms required by the kinematics derivatives
...
...
examples/meshcat-viewer-dae.py
View file @
87de6d23
...
...
@@ -3,7 +3,6 @@
# pip install --user meshcat
import
pinocchio
as
pin
pin
.
switchToNumpyMatrix
()
import
numpy
as
np
import
sys
import
os
...
...
@@ -49,7 +48,7 @@ except ImportError as err:
viz
.
loadViewerModel
(
color
=
[
0.0
,
0.0
,
0.0
,
1.0
])
# Display a robot configuration.
q0
=
np
.
matrix
([
q0
=
np
.
array
([
0
,
0
,
0.840252
,
0
,
0
,
0
,
1
,
# Free flyer
0
,
0
,
-
0.3490658
,
0.6981317
,
-
0.3490658
,
0
,
# left leg
0
,
0
,
-
0.3490658
,
0.6981317
,
-
0.3490658
,
0
,
# right leg
...
...
examples/meshcat-viewer.py
View file @
87de6d23
...
...
@@ -3,7 +3,6 @@
# pip install --user meshcat
import
pinocchio
as
pin
pin
.
switchToNumpyMatrix
()
import
numpy
as
np
import
sys
import
os
...
...
examples/robot-wrapper-viewer.py
View file @
87de6d23
...
...
@@ -4,7 +4,6 @@
#
import
pinocchio
as
pin
pin
.
switchToNumpyMatrix
()
from
pinocchio.robot_wrapper
import
RobotWrapper
from
pinocchio.visualize
import
(
GepettoVisualizer
,
MeshcatVisualizer
)
from
sys
import
argv
...
...
examples/sample-model-viewer.py
View file @
87de6d23
import
pinocchio
as
pin
pin
.
switchToNumpyMatrix
()
from
pinocchio.visualize
import
MeshcatVisualizer
,
GepettoVisualizer
from
sys
import
argv
from
numpy
import
pi
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment