ikpy 4.4.2__tar.gz → 4.4.4__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.2 → ikpy-4.4.4}/PKG-INFO +1 -1
- ikpy-4.4.4/src/ikpy/_version.py +1 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/src/ikpy/chain.py +6 -5
- {ikpy-4.4.2 → ikpy-4.4.4}/src/ikpy/utils/geometry.py +4 -2
- {ikpy-4.4.2 → ikpy-4.4.4}/src/ikpy.egg-info/PKG-INFO +1 -1
- {ikpy-4.4.2 → ikpy-4.4.4}/src/ikpy.egg-info/SOURCES.txt +3 -0
- ikpy-4.4.4/tests/test_chain_concat_masks.py +50 -0
- ikpy-4.4.4/tests/test_chain_last_link_mask.py +54 -0
- ikpy-4.4.4/tests/test_translation_default.py +22 -0
- ikpy-4.4.2/src/ikpy/_version.py +0 -1
- {ikpy-4.4.2 → ikpy-4.4.4}/LICENSE +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/README.md +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/pyproject.toml +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/setup.cfg +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/src/ikpy/__init__.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/src/ikpy/bvh/BVH.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/src/ikpy/bvh/__init__.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/src/ikpy/inverse_kinematics.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/src/ikpy/jax_backend.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/src/ikpy/link.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/src/ikpy/logs.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/src/ikpy/mjcf/MJCF.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/src/ikpy/mjcf/__init__.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/src/ikpy/mjcf/utils.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/src/ikpy/selection.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/src/ikpy/urdf/URDF.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/src/ikpy/urdf/__init__.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/src/ikpy/urdf/utils.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/src/ikpy/utils/__init__.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/src/ikpy/utils/jax_geometry.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/src/ikpy/utils/plot.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/src/ikpy.egg-info/dependency_links.txt +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/src/ikpy.egg-info/requires.txt +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/src/ikpy.egg-info/top_level.txt +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/tests/test_bvh.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/tests/test_chain.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/tests/test_chain_dh.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/tests/test_chain_selection.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/tests/test_ik_bounds.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/tests/test_ik_multistart.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/tests/test_ik_trajectory.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/tests/test_jax_backend.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/tests/test_mjcf.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/tests/test_orientation.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/tests/test_orientation_conversions.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/tests/test_poppy_robots.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/tests/test_transformation_roundtrip.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/tests/test_urdf.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/tests/test_urdf_continuous.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/tests/test_urdf_default_axis.py +0 -0
- {ikpy-4.4.2 → ikpy-4.4.4}/tests/test_urdf_kdl.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '4.4.4'
|
|
@@ -66,10 +66,11 @@ class Chain:
|
|
|
66
66
|
else:
|
|
67
67
|
self.active_links_mask = np.array([True] * len(links))
|
|
68
68
|
|
|
69
|
-
#
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
# The last link is usually the end effector, which is not meant to be an optimization variable. Only warn,
|
|
70
|
+
# without overriding: it can also be a genuine joint, e.g. in a chain without a tip link. As for mimic
|
|
71
|
+
# joints below, the default mask stays silent, and a fixed last link is already reported by the next check.
|
|
72
|
+
if active_links_mask is not None and self.active_links_mask[-1] and self.links[-1].joint_type != "fixed":
|
|
73
|
+
warnings.warn("The last link {} (index: {}) is set as active in the active_links_mask. The last link is usually the end effector, which is not meant to be active: check that this is intended".format(self.links[-1].name, len(self.links) - 1))
|
|
73
74
|
|
|
74
75
|
# Check that none of the active links are fixed
|
|
75
76
|
for link_index, (link_active, link) in enumerate(zip(self.active_links_mask, self.links)):
|
|
@@ -943,4 +944,4 @@ class Chain:
|
|
|
943
944
|
@classmethod
|
|
944
945
|
def concat(cls, chain1, chain2):
|
|
945
946
|
"""Concatenate two chains"""
|
|
946
|
-
return cls(links=chain1.links + chain2.links, active_links_mask=chain1.active_links_mask
|
|
947
|
+
return cls(links=chain1.links + chain2.links, active_links_mask=np.concatenate((chain1.active_links_mask, chain2.active_links_mask)))
|
|
@@ -106,7 +106,7 @@ def from_transformation_matrix(transformation_matrix):
|
|
|
106
106
|
return transformation_matrix[:-1, -1], transformation_matrix[:-1, :-1]
|
|
107
107
|
|
|
108
108
|
|
|
109
|
-
def to_transformation_matrix(translation, orientation_matrix=
|
|
109
|
+
def to_transformation_matrix(translation, orientation_matrix=None):
|
|
110
110
|
"""Convert a tuple (translation_vector, orientation_matrix) to a transformation matrix
|
|
111
111
|
|
|
112
112
|
Parameters
|
|
@@ -115,10 +115,12 @@ def to_transformation_matrix(translation, orientation_matrix=np.zeros((3, 3))):
|
|
|
115
115
|
The translation of your frame presented as a 3D vector.
|
|
116
116
|
orientation_matrix: numpy.array
|
|
117
117
|
Optional : The orientation of your frame, presented as a 3x3 matrix.
|
|
118
|
+
Defaults to the identity rotation.
|
|
118
119
|
"""
|
|
119
120
|
matrix = np.eye(4)
|
|
120
121
|
|
|
121
|
-
|
|
122
|
+
if orientation_matrix is not None:
|
|
123
|
+
matrix[:-1, :-1] = orientation_matrix
|
|
122
124
|
matrix[:-1, -1] = translation
|
|
123
125
|
return matrix
|
|
124
126
|
|
|
@@ -29,7 +29,9 @@ src/ikpy/utils/jax_geometry.py
|
|
|
29
29
|
src/ikpy/utils/plot.py
|
|
30
30
|
tests/test_bvh.py
|
|
31
31
|
tests/test_chain.py
|
|
32
|
+
tests/test_chain_concat_masks.py
|
|
32
33
|
tests/test_chain_dh.py
|
|
34
|
+
tests/test_chain_last_link_mask.py
|
|
33
35
|
tests/test_chain_selection.py
|
|
34
36
|
tests/test_ik_bounds.py
|
|
35
37
|
tests/test_ik_multistart.py
|
|
@@ -40,6 +42,7 @@ tests/test_orientation.py
|
|
|
40
42
|
tests/test_orientation_conversions.py
|
|
41
43
|
tests/test_poppy_robots.py
|
|
42
44
|
tests/test_transformation_roundtrip.py
|
|
45
|
+
tests/test_translation_default.py
|
|
43
46
|
tests/test_urdf.py
|
|
44
47
|
tests/test_urdf_continuous.py
|
|
45
48
|
tests/test_urdf_default_axis.py
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import pytest
|
|
3
|
+
from ikpy.chain import Chain
|
|
4
|
+
from ikpy.link import URDFLink
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def make_chain(prefix, mask):
|
|
8
|
+
links = [
|
|
9
|
+
URDFLink(
|
|
10
|
+
name=prefix + str(i),
|
|
11
|
+
origin_translation=[0, 0, 1],
|
|
12
|
+
origin_orientation=[0, 0, 0],
|
|
13
|
+
rotation=[0, 0, 1],
|
|
14
|
+
use_symbolic_matrix=False,
|
|
15
|
+
)
|
|
16
|
+
for i in range(len(mask))
|
|
17
|
+
]
|
|
18
|
+
return Chain(links, active_links_mask=mask)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@pytest.mark.parametrize(
|
|
22
|
+
"left,right",
|
|
23
|
+
[
|
|
24
|
+
([True, False], [False, True]),
|
|
25
|
+
([True, False], [True, False, False]),
|
|
26
|
+
([False], [True, False]),
|
|
27
|
+
],
|
|
28
|
+
)
|
|
29
|
+
def test_concat_preserves_masks_and_forward_kinematics(left, right):
|
|
30
|
+
first, second = make_chain("a", left), make_chain("b", right)
|
|
31
|
+
first_mask, second_mask = (
|
|
32
|
+
first.active_links_mask.copy(),
|
|
33
|
+
second.active_links_mask.copy(),
|
|
34
|
+
)
|
|
35
|
+
combined = Chain.concat(first, second)
|
|
36
|
+
expected = np.array(left + right, dtype=bool)
|
|
37
|
+
np.testing.assert_array_equal(combined.active_links_mask, expected)
|
|
38
|
+
assert combined.active_links_mask.dtype == np.dtype(bool)
|
|
39
|
+
np.testing.assert_array_equal(
|
|
40
|
+
combined.active_from_full(np.arange(len(expected))), np.flatnonzero(expected)
|
|
41
|
+
)
|
|
42
|
+
angles = np.linspace(0.1, 0.5, len(expected))
|
|
43
|
+
np.testing.assert_allclose(
|
|
44
|
+
combined.forward_kinematics(angles),
|
|
45
|
+
first.forward_kinematics(angles[: len(left)])
|
|
46
|
+
@ second.forward_kinematics(angles[len(left) :]),
|
|
47
|
+
)
|
|
48
|
+
combined.active_links_mask[0] = not combined.active_links_mask[0]
|
|
49
|
+
np.testing.assert_array_equal(first.active_links_mask, first_mask)
|
|
50
|
+
np.testing.assert_array_equal(second.active_links_mask, second_mask)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import warnings
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
import pytest
|
|
5
|
+
|
|
6
|
+
from ikpy.chain import Chain
|
|
7
|
+
from ikpy.link import OriginLink, URDFLink
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def make_links(last_joint_type="revolute"):
|
|
11
|
+
links = [OriginLink()]
|
|
12
|
+
for index, joint_type in enumerate(["revolute", last_joint_type]):
|
|
13
|
+
links.append(URDFLink(
|
|
14
|
+
name="joint_{}".format(index),
|
|
15
|
+
origin_translation=[0, 0, 1],
|
|
16
|
+
origin_orientation=[0, 0, 0],
|
|
17
|
+
rotation=[0, 0, 1] if joint_type != "fixed" else None,
|
|
18
|
+
joint_type=joint_type,
|
|
19
|
+
use_symbolic_matrix=False,
|
|
20
|
+
))
|
|
21
|
+
return links
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def last_link_warnings(caught):
|
|
25
|
+
return [w for w in caught if "The last link" in str(w.message)]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def test_explicit_active_last_link_warns_without_override():
|
|
29
|
+
with pytest.warns(UserWarning, match="The last link joint_1"):
|
|
30
|
+
chain = Chain(make_links(), active_links_mask=[False, True, True])
|
|
31
|
+
np.testing.assert_array_equal(chain.active_links_mask, [False, True, True])
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_default_mask_is_silent_and_keeps_last_link_active():
|
|
35
|
+
with warnings.catch_warnings(record=True) as caught:
|
|
36
|
+
warnings.simplefilter("always")
|
|
37
|
+
chain = Chain(make_links())
|
|
38
|
+
assert last_link_warnings(caught) == []
|
|
39
|
+
np.testing.assert_array_equal(chain.active_links_mask, [True, True, True])
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def test_inactive_last_link_is_silent():
|
|
43
|
+
with warnings.catch_warnings(record=True) as caught:
|
|
44
|
+
warnings.simplefilter("always")
|
|
45
|
+
Chain(make_links(), active_links_mask=[False, True, False])
|
|
46
|
+
assert last_link_warnings(caught) == []
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def test_fixed_last_link_only_gets_the_fixed_warning():
|
|
50
|
+
with warnings.catch_warnings(record=True) as caught:
|
|
51
|
+
warnings.simplefilter("always")
|
|
52
|
+
Chain(make_links("fixed"), active_links_mask=[False, True, True])
|
|
53
|
+
assert last_link_warnings(caught) == []
|
|
54
|
+
assert any("is of type 'fixed'" in str(w.message) for w in caught)
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import pytest
|
|
3
|
+
from ikpy.utils.geometry import to_transformation_matrix
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@pytest.mark.parametrize(
|
|
7
|
+
"translation", [[0, 0, 0], [1, -2, 3], np.array([0.25, 4.0, -8.0])]
|
|
8
|
+
)
|
|
9
|
+
def test_translation_only_preserves_points_and_axes(translation):
|
|
10
|
+
frame = to_transformation_matrix(translation)
|
|
11
|
+
points = np.array([[0.0, 0.0, 0.0], [1.0, 2.0, 3.0], [-3.0, 1.0, 2.0]])
|
|
12
|
+
mapped = (frame @ np.column_stack((points, np.ones(3))).T).T
|
|
13
|
+
np.testing.assert_allclose(mapped[:, :3], points + translation)
|
|
14
|
+
np.testing.assert_allclose(mapped[:, 3], 1)
|
|
15
|
+
assert np.linalg.det(frame) == pytest.approx(1)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def test_explicit_orientation_is_preserved():
|
|
19
|
+
rotation = np.array([[0.0, -1.0, 0.0], [1.0, 0.0, 0.0], [0.0, 0.0, 1.0]])
|
|
20
|
+
frame = to_transformation_matrix([1, 2, 3], rotation)
|
|
21
|
+
np.testing.assert_array_equal(frame[:3, :3], rotation)
|
|
22
|
+
np.testing.assert_array_equal(frame[:3, 3], [1, 2, 3])
|
ikpy-4.4.2/src/ikpy/_version.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '4.4.2'
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|