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
2e79ded6
Verified
Commit
2e79ded6
authored
Apr 09, 2021
by
Nicolas Torres
Committed by
Justin Carpentier
Apr 10, 2021
Browse files
RobotWrapper reduceModel -> buildReducedRobot
parent
46c948a9
Changes
2
Hide whitespace changes
Inline
Side-by-side
bindings/python/pinocchio/robot_wrapper.py
View file @
2e79ded6
...
...
@@ -175,18 +175,18 @@ class RobotWrapper(object):
def
framesForwardKinematics
(
self
,
q
):
pin
.
framesForwardKinematics
(
self
.
model
,
self
.
data
,
q
)
def
reduceModel
(
self
,
list_of_joints_to_lock
,
reference_configuration
=
None
):
def
buildReducedRobot
(
self
,
list_of_joints_to_lock
,
reference_configuration
=
None
):
"""
R
educed
the
robot model given a list of joints to lock.
Build a r
educed robot model given a list of joints to lock.
Parameters:
\t
list_of_joints_to_lock: list of joint indexes/names to lock.
\t
reference_configuration: reference configuration to compute the
placement of the lock joints. If not provided, reference_configuration
defaults to the robot's neutral configuration.
defaults to the robot's neutral configuration.
NOTE: This operation is not reversible, the original model is lost
.
Returns: a new robot model
.
"""
# if joint to lock is a string, try to find its index
...
...
@@ -205,9 +205,9 @@ class RobotWrapper(object):
list_of_geom_models
=
[
self
.
visual_model
,
self
.
collision_model
],
list_of_joints_to_lock
=
lockjoints_idx
,
reference_configuration
=
reference_configuration
)
self
.
model
,
self
.
visual_model
,
self
.
collision_model
=
model
,
geom_models
[
0
],
geom_models
[
1
]
self
.
rebuildData
(
)
return
RobotWrapper
(
model
=
model
,
visual_model
=
geom_models
[
0
],
collision_model
=
geom_models
[
1
]
)
def
getFrameJacobian
(
self
,
frame_id
,
rf_frame
=
pin
.
ReferenceFrame
.
LOCAL
):
"""
...
...
examples/build-reduced-model.py
View file @
2e79ded6
...
...
@@ -59,16 +59,16 @@ print('joints to lock (only ids):', jointsToLockIDs)
print
(
'reduced model: dim='
+
str
(
len
(
model_reduced
.
joints
)))
print
(
'-'
*
30
)
# Option 4: Build a
RobotWrapper and
reduce
the
model
using the w
rapper
# Option 4: Build a reduce
d
model
of a robot using RobotW
rapper
# reference_configuration is optional: if not provided, neutral configuration used
# you can even mix joint names and joint ids
mixed_jointsToLockIDs
=
[
jointsToLockIDs
[
0
],
'wrist_2_joint'
,
'wrist_3_joint'
]
robot
=
pin
.
RobotWrapper
.
BuildFromURDF
(
urdf_filename
,
mesh_dir
)
r
obot
.
reduceModel
(
list_of_joints_to_lock
=
mixed_jointsToLockIDs
,
reference_configuration
=
initialJointConfig
)
r
educed_robot
=
robot
.
buildReducedRobot
(
list_of_joints_to_lock
=
mixed_jointsToLockIDs
,
reference_configuration
=
initialJointConfig
)
# Check dimensions of the reduced model and joint info
print
(
'mixed joints to lock (names and ids):'
,
mixed_jointsToLockIDs
)
print
(
'RobotWrapper reduced model: dim='
+
str
(
len
(
robot
.
model
.
joints
)))
print
(
'RobotWrapper reduced model: dim='
+
str
(
len
(
reduced_
robot
.
model
.
joints
)))
for
jn
in
robot
.
model
.
joints
:
print
(
jn
)
Write
Preview
Supports
Markdown
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