ikpy 4.4.0__tar.gz → 4.4.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ikpy-4.4.0 → ikpy-4.4.2}/PKG-INFO +1 -1
- ikpy-4.4.2/src/ikpy/_version.py +1 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/src/ikpy/mjcf/MJCF.py +81 -77
- {ikpy-4.4.0 → ikpy-4.4.2}/src/ikpy/utils/geometry.py +1 -1
- {ikpy-4.4.0 → ikpy-4.4.2}/src/ikpy/utils/jax_geometry.py +1 -1
- {ikpy-4.4.0 → ikpy-4.4.2}/src/ikpy.egg-info/PKG-INFO +1 -1
- {ikpy-4.4.0 → ikpy-4.4.2}/src/ikpy.egg-info/SOURCES.txt +1 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/tests/test_mjcf.py +102 -0
- ikpy-4.4.2/tests/test_transformation_roundtrip.py +25 -0
- ikpy-4.4.0/src/ikpy/_version.py +0 -1
- {ikpy-4.4.0 → ikpy-4.4.2}/LICENSE +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/README.md +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/pyproject.toml +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/setup.cfg +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/src/ikpy/__init__.py +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/src/ikpy/bvh/BVH.py +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/src/ikpy/bvh/__init__.py +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/src/ikpy/chain.py +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/src/ikpy/inverse_kinematics.py +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/src/ikpy/jax_backend.py +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/src/ikpy/link.py +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/src/ikpy/logs.py +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/src/ikpy/mjcf/__init__.py +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/src/ikpy/mjcf/utils.py +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/src/ikpy/selection.py +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/src/ikpy/urdf/URDF.py +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/src/ikpy/urdf/__init__.py +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/src/ikpy/urdf/utils.py +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/src/ikpy/utils/__init__.py +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/src/ikpy/utils/plot.py +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/src/ikpy.egg-info/dependency_links.txt +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/src/ikpy.egg-info/requires.txt +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/src/ikpy.egg-info/top_level.txt +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/tests/test_bvh.py +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/tests/test_chain.py +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/tests/test_chain_dh.py +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/tests/test_chain_selection.py +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/tests/test_ik_bounds.py +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/tests/test_ik_multistart.py +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/tests/test_ik_trajectory.py +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/tests/test_jax_backend.py +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/tests/test_orientation.py +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/tests/test_orientation_conversions.py +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/tests/test_poppy_robots.py +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/tests/test_urdf.py +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/tests/test_urdf_continuous.py +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/tests/test_urdf_default_axis.py +0 -0
- {ikpy-4.4.0 → ikpy-4.4.2}/tests/test_urdf_kdl.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '4.4.2'
|
|
@@ -49,66 +49,66 @@ def _get_compiler_settings(root):
|
|
|
49
49
|
return settings
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
def
|
|
52
|
+
def _get_joint_defaults(root):
|
|
53
53
|
"""
|
|
54
|
-
|
|
54
|
+
Resolve the joint defaults of every default class, following MJCF's inheritance rules.
|
|
55
|
+
|
|
56
|
+
The top-level ``<default>`` element is the ``main`` class. Each nested ``<default class="...">`` inherits the
|
|
57
|
+
joint attributes of its parent class and overrides only the ones its own ``<joint>`` element sets.
|
|
55
58
|
|
|
56
59
|
Parameters
|
|
57
60
|
----------
|
|
58
61
|
root: xml.etree.ElementTree.Element
|
|
59
62
|
The root element of the MJCF XML
|
|
60
|
-
class_name: str
|
|
61
|
-
The name of the default class to find
|
|
62
63
|
|
|
63
64
|
Returns
|
|
64
65
|
-------
|
|
65
66
|
dict
|
|
66
|
-
|
|
67
|
+
Class name -> joint attributes (raw XML strings) resolved for this class
|
|
67
68
|
"""
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
classes = {"main": {}}
|
|
70
|
+
|
|
71
|
+
def visit(default_elem, inherited, is_top_level):
|
|
72
|
+
attributes = dict(inherited)
|
|
73
|
+
joint_elem = default_elem.find("joint")
|
|
74
|
+
if joint_elem is not None:
|
|
75
|
+
attributes.update({key: value for key, value in joint_elem.attrib.items() if key not in ("name", "class")})
|
|
76
|
+
class_name = default_elem.get("class")
|
|
77
|
+
if is_top_level:
|
|
78
|
+
classes["main"] = attributes
|
|
79
|
+
if class_name is not None:
|
|
80
|
+
classes[class_name] = attributes
|
|
81
|
+
for child in default_elem.findall("default"):
|
|
82
|
+
visit(child, attributes, False)
|
|
83
|
+
|
|
84
|
+
for default_elem in root.findall("default"):
|
|
85
|
+
visit(default_elem, {}, True)
|
|
86
|
+
|
|
87
|
+
return classes
|
|
72
88
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return result
|
|
97
|
-
return None
|
|
98
|
-
|
|
99
|
-
# Try to find the class
|
|
100
|
-
for default_elem in default_section.iter("default"):
|
|
101
|
-
default_class = default_elem.get("class")
|
|
102
|
-
if default_class == class_name:
|
|
103
|
-
joint_elem = default_elem.find("joint")
|
|
104
|
-
if joint_elem is not None:
|
|
105
|
-
if "axis" in joint_elem.attrib:
|
|
106
|
-
defaults["axis"] = [float(x) for x in joint_elem.attrib["axis"].split()]
|
|
107
|
-
if "range" in joint_elem.attrib:
|
|
108
|
-
defaults["range"] = [float(x) for x in joint_elem.attrib["range"].split()]
|
|
109
|
-
break
|
|
110
|
-
|
|
111
|
-
return defaults
|
|
89
|
+
|
|
90
|
+
def _get_body_classes(worldbody):
|
|
91
|
+
"""
|
|
92
|
+
Return the class applied by default to the joints of each body, following ``childclass`` down the body tree.
|
|
93
|
+
|
|
94
|
+
Parameters
|
|
95
|
+
----------
|
|
96
|
+
worldbody: xml.etree.ElementTree.Element
|
|
97
|
+
The worldbody element of the MJCF XML
|
|
98
|
+
|
|
99
|
+
Returns
|
|
100
|
+
-------
|
|
101
|
+
dict
|
|
102
|
+
Body element -> class name
|
|
103
|
+
"""
|
|
104
|
+
body_classes = {}
|
|
105
|
+
stack = [(body, "main") for body in worldbody.findall("body")]
|
|
106
|
+
while stack:
|
|
107
|
+
body, inherited_class = stack.pop()
|
|
108
|
+
body_class = body.get("childclass", inherited_class)
|
|
109
|
+
body_classes[body] = body_class
|
|
110
|
+
stack.extend((child, body_class) for child in body.findall("body"))
|
|
111
|
+
return body_classes
|
|
112
112
|
|
|
113
113
|
|
|
114
114
|
def _parse_body_transform(body_elem, compiler_settings):
|
|
@@ -174,52 +174,55 @@ def _parse_joint(joint_elem, compiler_settings, default_settings):
|
|
|
174
174
|
compiler_settings: dict
|
|
175
175
|
Compiler settings
|
|
176
176
|
default_settings: dict
|
|
177
|
-
|
|
177
|
+
Joint attributes (raw XML strings) of this joint's default class
|
|
178
178
|
|
|
179
179
|
Returns
|
|
180
180
|
-------
|
|
181
181
|
dict
|
|
182
182
|
Joint parameters
|
|
183
183
|
"""
|
|
184
|
+
attributes = dict(default_settings)
|
|
185
|
+
attributes.update(joint_elem.attrib)
|
|
186
|
+
|
|
184
187
|
joint_info = {
|
|
185
|
-
"name":
|
|
186
|
-
"type":
|
|
187
|
-
"axis":
|
|
188
|
-
"range":
|
|
188
|
+
"name": attributes.get("name", "unnamed_joint"),
|
|
189
|
+
"type": attributes.get("type", "hinge"), # Default is hinge (revolute)
|
|
190
|
+
"axis": [0.0, 0.0, 1.0], # Default axis in MJCF
|
|
191
|
+
"range": [-np.inf, np.inf],
|
|
189
192
|
"pos": [0, 0, 0]
|
|
190
193
|
}
|
|
191
194
|
|
|
192
195
|
# Parse joint-specific position (offset within the body)
|
|
193
|
-
if "pos" in
|
|
194
|
-
joint_info["pos"] = [float(x) for x in
|
|
196
|
+
if "pos" in attributes:
|
|
197
|
+
joint_info["pos"] = [float(x) for x in attributes["pos"].split()]
|
|
195
198
|
|
|
196
199
|
# Parse axis
|
|
197
|
-
if "axis" in
|
|
198
|
-
joint_info["axis"] = [float(x) for x in
|
|
200
|
+
if "axis" in attributes:
|
|
201
|
+
joint_info["axis"] = [float(x) for x in attributes["axis"].split()]
|
|
199
202
|
|
|
200
203
|
# Parse range (limits)
|
|
201
|
-
if "range" in
|
|
202
|
-
range_vals = [float(x) for x in
|
|
204
|
+
if "range" in attributes:
|
|
205
|
+
range_vals = [float(x) for x in attributes["range"].split()]
|
|
203
206
|
if compiler_settings["angle"] == "degree" and joint_info["type"] == "hinge":
|
|
204
207
|
range_vals = [np.radians(r) for r in range_vals]
|
|
205
208
|
joint_info["range"] = range_vals
|
|
206
209
|
|
|
207
|
-
# Check limited attribute
|
|
208
|
-
if "limited" in
|
|
209
|
-
|
|
210
|
-
joint_info["range"] = [-np.inf, np.inf]
|
|
210
|
+
# Check limited attribute ("auto", the default, means limited when a range is given)
|
|
211
|
+
if attributes.get("limited", "auto").lower() in ["false", "0"]:
|
|
212
|
+
joint_info["range"] = [-np.inf, np.inf]
|
|
211
213
|
|
|
212
214
|
return joint_info
|
|
213
215
|
|
|
214
216
|
|
|
215
|
-
def _traverse_body_tree(
|
|
217
|
+
def _traverse_body_tree(defaults, body_elem, compiler_settings, chain_path, base_elements, current_depth=0, follow_first_child=True):
|
|
216
218
|
"""
|
|
217
219
|
Recursively traverse the body tree and extract kinematic chain.
|
|
218
220
|
|
|
219
221
|
Parameters
|
|
220
222
|
----------
|
|
221
|
-
|
|
222
|
-
|
|
223
|
+
defaults: dict
|
|
224
|
+
``"joints"``: joint attributes of each default class (see ``_get_joint_defaults``),
|
|
225
|
+
``"bodies"``: class applied by default in each body (see ``_get_body_classes``)
|
|
223
226
|
body_elem: xml.etree.ElementTree.Element
|
|
224
227
|
Current body element
|
|
225
228
|
compiler_settings: dict
|
|
@@ -248,8 +251,8 @@ def _traverse_body_tree(root, body_elem, compiler_settings, chain_path, base_ele
|
|
|
248
251
|
return False
|
|
249
252
|
base_elements = base_elements[1:]
|
|
250
253
|
|
|
251
|
-
#
|
|
252
|
-
childclass =
|
|
254
|
+
# Class applied to the joints of this body that don't name one (childclass, inherited down the body tree)
|
|
255
|
+
childclass = defaults["bodies"][body_elem]
|
|
253
256
|
|
|
254
257
|
# Parse body transform
|
|
255
258
|
body_pos, body_orientation = _parse_body_transform(body_elem, compiler_settings)
|
|
@@ -272,10 +275,9 @@ def _traverse_body_tree(root, body_elem, compiler_settings, chain_path, base_ele
|
|
|
272
275
|
for i, joint_elem in enumerate(joints):
|
|
273
276
|
# Get default class for this joint
|
|
274
277
|
joint_class = joint_elem.get("class", childclass)
|
|
275
|
-
|
|
276
|
-
"
|
|
277
|
-
|
|
278
|
-
}
|
|
278
|
+
if joint_class not in defaults["joints"]:
|
|
279
|
+
raise ValueError(f"Joint '{joint_elem.get('name')}' uses the undefined default class '{joint_class}'")
|
|
280
|
+
default_settings = defaults["joints"][joint_class]
|
|
279
281
|
|
|
280
282
|
joint_info = _parse_joint(joint_elem, compiler_settings, default_settings)
|
|
281
283
|
|
|
@@ -333,12 +335,12 @@ def _traverse_body_tree(root, body_elem, compiler_settings, chain_path, base_ele
|
|
|
333
335
|
# Follow the specified path
|
|
334
336
|
for child in child_bodies:
|
|
335
337
|
if child.get("name") == base_elements[0]:
|
|
336
|
-
_traverse_body_tree(
|
|
338
|
+
_traverse_body_tree(defaults, child, compiler_settings, chain_path, base_elements, current_depth + 1, follow_first_child)
|
|
337
339
|
return True
|
|
338
340
|
# If specified body not found, stop
|
|
339
341
|
return True
|
|
340
342
|
elif follow_first_child:
|
|
341
|
-
_traverse_body_tree(
|
|
343
|
+
_traverse_body_tree(defaults, child_bodies[0], compiler_settings, chain_path, None, current_depth + 1)
|
|
342
344
|
|
|
343
345
|
return True
|
|
344
346
|
|
|
@@ -430,6 +432,8 @@ def get_mjcf_parameters(mjcf_file, base=None, tip=None, tip_offset=None, symboli
|
|
|
430
432
|
if worldbody is None:
|
|
431
433
|
raise ValueError("No 'worldbody' element found in MJCF file")
|
|
432
434
|
|
|
435
|
+
defaults = {"joints": _get_joint_defaults(root), "bodies": _get_body_classes(worldbody)}
|
|
436
|
+
|
|
433
437
|
base, tip, tip_offset, legacy = selection.resolve_selection(base, tip, tip_offset, base_elements, last_link_vector)
|
|
434
438
|
chain_path = []
|
|
435
439
|
|
|
@@ -444,18 +448,18 @@ def get_mjcf_parameters(mjcf_file, base=None, tip=None, tip_offset=None, symboli
|
|
|
444
448
|
break
|
|
445
449
|
if start_body is None:
|
|
446
450
|
raise ValueError(f"Starting body '{base_elements[0]}' not found in MJCF")
|
|
447
|
-
_traverse_body_tree(
|
|
451
|
+
_traverse_body_tree(defaults, start_body, compiler_settings, chain_path, base_elements)
|
|
448
452
|
else:
|
|
449
453
|
first_body = worldbody.find("body")
|
|
450
454
|
if first_body is None:
|
|
451
455
|
raise ValueError("No body found in worldbody")
|
|
452
|
-
_traverse_body_tree(
|
|
456
|
+
_traverse_body_tree(defaults, first_body, compiler_settings, chain_path, None)
|
|
453
457
|
else:
|
|
454
458
|
if worldbody.find("body") is None:
|
|
455
459
|
raise ValueError("No body found in worldbody")
|
|
456
460
|
path = _resolve_mjcf_path(worldbody, base, tip)
|
|
457
461
|
bodies, _, _ = _mjcf_tree(worldbody)
|
|
458
|
-
_traverse_body_tree(
|
|
462
|
+
_traverse_body_tree(defaults, bodies[path[0]], compiler_settings, chain_path, path, follow_first_child=False)
|
|
459
463
|
|
|
460
464
|
# Convert chain_path to URDFLink objects
|
|
461
465
|
parameters = []
|
|
@@ -103,7 +103,7 @@ def homogeneous_translation_matrix(trans_x, trans_y, trans_z):
|
|
|
103
103
|
|
|
104
104
|
def from_transformation_matrix(transformation_matrix):
|
|
105
105
|
"""Convert a transformation matrix to a tuple (translation_vector, rotation_matrix)"""
|
|
106
|
-
return transformation_matrix[
|
|
106
|
+
return transformation_matrix[:-1, -1], transformation_matrix[:-1, :-1]
|
|
107
107
|
|
|
108
108
|
|
|
109
109
|
def to_transformation_matrix(translation, orientation_matrix=np.zeros((3, 3))):
|
|
@@ -118,7 +118,7 @@ def homogeneous_to_cartesian(homogeneous_matrix):
|
|
|
118
118
|
@jit
|
|
119
119
|
def from_transformation_matrix(transformation_matrix):
|
|
120
120
|
"""Convert a transformation matrix to a tuple (translation_vector, rotation_matrix)"""
|
|
121
|
-
return transformation_matrix[
|
|
121
|
+
return transformation_matrix[:3, -1], transformation_matrix[:3, :3]
|
|
122
122
|
|
|
123
123
|
|
|
124
124
|
@jit
|
|
@@ -148,6 +148,72 @@ class TestMJCFParser:
|
|
|
148
148
|
for joint in expected_joints:
|
|
149
149
|
assert joint in joint_names, f"Joint {joint} not found"
|
|
150
150
|
|
|
151
|
+
def test_ur5e_nested_default_classes(self, ur5e_mjcf):
|
|
152
|
+
"""Joints inherit axis and range through nested default classes, as in MuJoCo Menagerie's UR5e."""
|
|
153
|
+
links = {link.name: link for link in MJCF.get_mjcf_parameters(ur5e_mjcf, base="base", tip="wrist_3_link")}
|
|
154
|
+
z, y = [0, 0, 1], [0, 1, 0]
|
|
155
|
+
expected = {
|
|
156
|
+
"shoulder_pan_joint": (z, 6.28319),
|
|
157
|
+
"shoulder_lift_joint": (y, 6.28319),
|
|
158
|
+
"elbow_joint": (y, 3.1415),
|
|
159
|
+
"wrist_1_joint": (y, 6.28319),
|
|
160
|
+
"wrist_2_joint": (z, 6.28319),
|
|
161
|
+
"wrist_3_joint": (y, 6.28319),
|
|
162
|
+
}
|
|
163
|
+
for name, (axis, limit) in expected.items():
|
|
164
|
+
np.testing.assert_array_equal(links[name].rotation, axis, err_msg=name)
|
|
165
|
+
assert links[name].bounds == (-limit, limit), name
|
|
166
|
+
|
|
167
|
+
def test_default_classes(self, tmp_path):
|
|
168
|
+
"""main class, inherited childclass, degree ranges from a class, limited flags, undefined classes."""
|
|
169
|
+
mjcf_file = tmp_path / "default_classes.xml"
|
|
170
|
+
mjcf_file.write_text("""
|
|
171
|
+
<mujoco model="default_classes">
|
|
172
|
+
<default>
|
|
173
|
+
<joint axis="1 0 0" range="-90 90"/>
|
|
174
|
+
<default class="arm">
|
|
175
|
+
<joint axis="0 1 0"/>
|
|
176
|
+
<default class="slider">
|
|
177
|
+
<joint type="slide" range="-0.5 0.5"/>
|
|
178
|
+
</default>
|
|
179
|
+
<default class="free_spin">
|
|
180
|
+
<joint limited="false"/>
|
|
181
|
+
</default>
|
|
182
|
+
</default>
|
|
183
|
+
</default>
|
|
184
|
+
<worldbody>
|
|
185
|
+
<body name="base">
|
|
186
|
+
<joint name="main_joint"/>
|
|
187
|
+
<body name="b1" childclass="arm">
|
|
188
|
+
<body name="b2">
|
|
189
|
+
<joint name="inherited_childclass" limited="auto"/>
|
|
190
|
+
<body name="b3">
|
|
191
|
+
<joint name="slide" class="slider"/>
|
|
192
|
+
<body name="b4">
|
|
193
|
+
<joint name="spin" class="free_spin"/>
|
|
194
|
+
</body>
|
|
195
|
+
</body>
|
|
196
|
+
</body>
|
|
197
|
+
</body>
|
|
198
|
+
</body>
|
|
199
|
+
</worldbody>
|
|
200
|
+
</mujoco>
|
|
201
|
+
""")
|
|
202
|
+
links = {link.name: link for link in MJCF.get_mjcf_parameters(mjcf_file, base="b2", tip="b4")}
|
|
203
|
+
np.testing.assert_array_equal(links["inherited_childclass"].rotation, [0, 1, 0])
|
|
204
|
+
np.testing.assert_allclose(links["inherited_childclass"].bounds, (-np.pi / 2, np.pi / 2))
|
|
205
|
+
assert links["slide"].joint_type == "prismatic"
|
|
206
|
+
np.testing.assert_array_equal(links["slide"].translation, [0, 1, 0])
|
|
207
|
+
assert links["slide"].bounds == (-0.5, 0.5)
|
|
208
|
+
assert links["spin"].bounds == (-np.inf, np.inf)
|
|
209
|
+
|
|
210
|
+
links = {link.name: link for link in MJCF.get_mjcf_parameters(mjcf_file, base="base", tip="b1")}
|
|
211
|
+
np.testing.assert_array_equal(links["main_joint"].rotation, [1, 0, 0])
|
|
212
|
+
|
|
213
|
+
mjcf_file.write_text(mjcf_file.read_text().replace('class="slider"/>', 'class="missing"/>'))
|
|
214
|
+
with pytest.raises(ValueError, match="missing"):
|
|
215
|
+
MJCF.get_mjcf_parameters(mjcf_file, base="b2", tip="b4")
|
|
216
|
+
|
|
151
217
|
def test_prismatic_joint(self, prismatic_mjcf):
|
|
152
218
|
"""Test parsing prismatic joints."""
|
|
153
219
|
links = MJCF.get_mjcf_parameters(prismatic_mjcf, base_elements=["base"])
|
|
@@ -227,6 +293,42 @@ class TestMJCFChain:
|
|
|
227
293
|
fk = my_chain.forward_kinematics(joints)
|
|
228
294
|
assert fk.shape == (4, 4)
|
|
229
295
|
|
|
296
|
+
def test_omitted_joint_axis_uses_mjcf_default(self, tmp_path):
|
|
297
|
+
"""Joints without an axis rotate around MJCF's default Z axis."""
|
|
298
|
+
mjcf_file = tmp_path / "default_joint_axis.xml"
|
|
299
|
+
mjcf_file.write_text("""
|
|
300
|
+
<mujoco model="default_joint_axis">
|
|
301
|
+
<default class="joint_defaults">
|
|
302
|
+
<joint/>
|
|
303
|
+
</default>
|
|
304
|
+
<worldbody>
|
|
305
|
+
<body name="base">
|
|
306
|
+
<body name="upper" pos="0 0 0.5">
|
|
307
|
+
<joint name="shoulder"/>
|
|
308
|
+
<body name="lower" pos="0.5 0 0">
|
|
309
|
+
<joint name="elbow" class="joint_defaults"/>
|
|
310
|
+
<body name="tip" pos="0.5 0 0"/>
|
|
311
|
+
</body>
|
|
312
|
+
</body>
|
|
313
|
+
</body>
|
|
314
|
+
</worldbody>
|
|
315
|
+
</mujoco>
|
|
316
|
+
""")
|
|
317
|
+
my_chain = chain.Chain.from_mjcf_file(
|
|
318
|
+
mjcf_file,
|
|
319
|
+
base="base",
|
|
320
|
+
tip="tip",
|
|
321
|
+
symbolic=False,
|
|
322
|
+
)
|
|
323
|
+
|
|
324
|
+
frame = my_chain.forward_kinematics([0, 0, 0.7, -0.4, 0])
|
|
325
|
+
expected_position = [
|
|
326
|
+
0.5 * np.cos(0.7) + 0.5 * np.cos(0.3),
|
|
327
|
+
0.5 * np.sin(0.7) + 0.5 * np.sin(0.3),
|
|
328
|
+
0.5,
|
|
329
|
+
]
|
|
330
|
+
np.testing.assert_allclose(frame[:3, 3], expected_position, atol=1e-12)
|
|
331
|
+
|
|
230
332
|
def test_chain_from_mjcf_ur5e(self, ur5e_mjcf):
|
|
231
333
|
"""Test creating a chain from UR5e MJCF."""
|
|
232
334
|
my_chain = chain.Chain.from_mjcf_file(
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import pytest
|
|
3
|
+
|
|
4
|
+
from ikpy.utils import geometry
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@pytest.mark.parametrize("translation", [[0, 0, 0], [1.5, -2, 3]])
|
|
8
|
+
@pytest.mark.parametrize("angles", [[0, 0, 0], [0.3, -0.7, 1.2]])
|
|
9
|
+
@pytest.mark.parametrize("backend", ["numpy", "jax"])
|
|
10
|
+
def test_transformation_roundtrip(translation, angles, backend):
|
|
11
|
+
if backend == "jax":
|
|
12
|
+
pytest.importorskip("jax")
|
|
13
|
+
from ikpy.utils import jax_geometry as implementation
|
|
14
|
+
else:
|
|
15
|
+
implementation = geometry
|
|
16
|
+
rotation = geometry.rpy_matrix(*angles)
|
|
17
|
+
frame = implementation.to_transformation_matrix(np.array(translation), rotation)
|
|
18
|
+
position, orientation = implementation.from_transformation_matrix(frame)
|
|
19
|
+
assert position.shape == (3,)
|
|
20
|
+
assert orientation.shape == (3, 3)
|
|
21
|
+
np.testing.assert_allclose(position, translation)
|
|
22
|
+
np.testing.assert_allclose(orientation, rotation, atol=1e-6)
|
|
23
|
+
np.testing.assert_allclose(
|
|
24
|
+
implementation.to_transformation_matrix(position, orientation), frame
|
|
25
|
+
)
|
ikpy-4.4.0/src/ikpy/_version.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '4.4.0'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|