rational-linkages 1.2.dev2__py3-none-any.whl → 1.2.dev4__py3-none-any.whl
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.
Potentially problematic release.
This version of rational-linkages might be problematic. Click here for more details.
- rational_linkages/AffineMetric.py +2 -2
- rational_linkages/DualQuaternion.py +133 -6
- rational_linkages/ExudynAnalysis.py +26 -6
- rational_linkages/FactorizationProvider.py +5 -5
- rational_linkages/Linkage.py +3 -2
- rational_linkages/MotionFactorization.py +10 -10
- rational_linkages/MotionInterpolation.py +3 -2
- rational_linkages/NormalizedLine.py +1 -1
- rational_linkages/Plotter.py +7 -6
- rational_linkages/PointHomogeneous.py +1 -0
- rational_linkages/Quaternion.py +60 -30
- rational_linkages/RationalBezier.py +1 -0
- rational_linkages/RationalCurve.py +1 -1
- rational_linkages/RationalMechanism.py +13 -15
- rational_linkages/TransfMatrix.py +3 -2
- rational_linkages/__init__.py +3 -3
- rational_linkages/data/collisions_free_6r.pkl +0 -0
- rational_linkages/models.py +14 -0
- {rational_linkages-1.2.dev2.dist-info → rational_linkages-1.2.dev4.dist-info}/METADATA +5 -2
- rational_linkages-1.2.dev4.dist-info/RECORD +30 -0
- rational_linkages-1.2.dev2.dist-info/RECORD +0 -29
- {rational_linkages-1.2.dev2.dist-info → rational_linkages-1.2.dev4.dist-info}/LICENSE +0 -0
- {rational_linkages-1.2.dev2.dist-info → rational_linkages-1.2.dev4.dist-info}/WHEEL +0 -0
- {rational_linkages-1.2.dev2.dist-info → rational_linkages-1.2.dev4.dist-info}/top_level.txt +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
|
|
3
|
-
from .RationalCurve import RationalCurve
|
|
4
|
-
from .PointHomogeneous import PointHomogeneous
|
|
5
3
|
from .DualQuaternion import DualQuaternion
|
|
4
|
+
from .PointHomogeneous import PointHomogeneous
|
|
5
|
+
from .RationalCurve import RationalCurve
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
class AffineMetric:
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
from typing import Optional, Sequence, Union
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
import numpy as np
|
|
4
|
+
from sympy import Expr
|
|
5
|
+
|
|
4
6
|
from .Quaternion import Quaternion
|
|
5
7
|
|
|
6
8
|
# Forward declarations for class names
|
|
@@ -191,7 +193,6 @@ class DualQuaternion:
|
|
|
191
193
|
Assembly of DualQuaternion from Sympy's rational numbers
|
|
192
194
|
|
|
193
195
|
:param Union[list, np.ndarray] study_parameters: list of 8 numbers
|
|
194
|
-
:param bool is_rotation: True if the Dual Quaternion represents a rotation,
|
|
195
196
|
|
|
196
197
|
:return: DualQuaternion with rational elements
|
|
197
198
|
:rtype: DualQuaternion
|
|
@@ -206,6 +207,34 @@ class DualQuaternion:
|
|
|
206
207
|
|
|
207
208
|
return cls(rational_numbers)
|
|
208
209
|
|
|
210
|
+
@classmethod
|
|
211
|
+
def random(cls, interval: float = 1):
|
|
212
|
+
"""
|
|
213
|
+
Construct a random DualQuaternion with in the interval (-interval, interval)
|
|
214
|
+
|
|
215
|
+
:param float interval: interval of random numbers
|
|
216
|
+
|
|
217
|
+
:return: DualQuaternion with random numbers
|
|
218
|
+
:rtype: DualQuaternion
|
|
219
|
+
"""
|
|
220
|
+
study_parameters = np.random.uniform(-interval, interval, 8)
|
|
221
|
+
return cls(study_parameters)
|
|
222
|
+
|
|
223
|
+
@classmethod
|
|
224
|
+
def random_on_study_quadric(cls, interval: float = 1):
|
|
225
|
+
"""
|
|
226
|
+
Construct a random DualQuaternion on the Study quadric
|
|
227
|
+
|
|
228
|
+
The interval (-interval, interval) is used to generate random numbers.
|
|
229
|
+
|
|
230
|
+
:param float interval: interval of random numbers
|
|
231
|
+
|
|
232
|
+
:return: DualQuaternion with random numbers lying on the Study quadric
|
|
233
|
+
:rtype: DualQuaternion
|
|
234
|
+
"""
|
|
235
|
+
dq = cls.random(interval)
|
|
236
|
+
return dq.back_projection()
|
|
237
|
+
|
|
209
238
|
def __repr__(self):
|
|
210
239
|
"""
|
|
211
240
|
Printing method override
|
|
@@ -270,14 +299,90 @@ class DualQuaternion:
|
|
|
270
299
|
"""
|
|
271
300
|
Multiplication of two DualQuaternions
|
|
272
301
|
|
|
273
|
-
:param DualQuaternion other: other DualQuaternion
|
|
302
|
+
:param DualQuaternion, int, float other: other DualQuaternion
|
|
274
303
|
|
|
275
304
|
:return: multiplied DualQuaternion
|
|
276
305
|
:rtype: DualQuaternion
|
|
277
306
|
"""
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
307
|
+
if isinstance(other, (int, float)):
|
|
308
|
+
return DualQuaternion(self.array() * other)
|
|
309
|
+
else:
|
|
310
|
+
p = self.p * other.p
|
|
311
|
+
d = (self.d * other.p) + (self.p * other.d)
|
|
312
|
+
return DualQuaternion.from_two_quaternions(p, d)
|
|
313
|
+
|
|
314
|
+
def __rmul__(self, other) -> "DualQuaternion":
|
|
315
|
+
"""Handle when the dual quaternion is on the right side of the multiplication"""
|
|
316
|
+
return self.__mul__(other)
|
|
317
|
+
|
|
318
|
+
def __truediv__(self, other) -> "DualQuaternion":
|
|
319
|
+
"""
|
|
320
|
+
Division of two DualQuaternions
|
|
321
|
+
|
|
322
|
+
:param DualQuaternion, int, float other: other DualQuaternion
|
|
323
|
+
|
|
324
|
+
:return: divided DualQuaternion
|
|
325
|
+
:rtype: DualQuaternion
|
|
326
|
+
"""
|
|
327
|
+
if isinstance(other, (int, float)):
|
|
328
|
+
return DualQuaternion(self.array() / other)
|
|
329
|
+
else:
|
|
330
|
+
return self * other.inv()
|
|
331
|
+
|
|
332
|
+
def __neg__(self) -> "DualQuaternion":
|
|
333
|
+
"""
|
|
334
|
+
Negation of the DualQuaternion
|
|
335
|
+
|
|
336
|
+
:return: negated DualQuaternion
|
|
337
|
+
:rtype: DualQuaternion
|
|
338
|
+
"""
|
|
339
|
+
return DualQuaternion(-1 * self.array())
|
|
340
|
+
|
|
341
|
+
def real(self) -> np.ndarray:
|
|
342
|
+
"""
|
|
343
|
+
Real part of the DualQuaternion, list of first and fifth element
|
|
344
|
+
|
|
345
|
+
:return: real part of the DualQuaternion
|
|
346
|
+
:rtype: np.ndarray
|
|
347
|
+
"""
|
|
348
|
+
return np.array([self.array()[0], self.array()[4]])
|
|
349
|
+
|
|
350
|
+
def imag(self) -> np.ndarray:
|
|
351
|
+
"""
|
|
352
|
+
Imaginary part of the DualQuaternion
|
|
353
|
+
|
|
354
|
+
List of 6 elements - ijk elements of the primal and dual part. In case of a
|
|
355
|
+
line, these might be Plucker coordinates.
|
|
356
|
+
|
|
357
|
+
:return: imaginary part of the DualQuaternion
|
|
358
|
+
:rtype: np.ndarray
|
|
359
|
+
"""
|
|
360
|
+
return np.array([self.array()[1], self.array()[2], self.array()[3],
|
|
361
|
+
self.array()[5], self.array()[6], self.array()[7]])
|
|
362
|
+
|
|
363
|
+
def back_projection(self) -> "DualQuaternion":
|
|
364
|
+
"""
|
|
365
|
+
Returns the projection of dual quaternion onto Study quadric.
|
|
366
|
+
|
|
367
|
+
The back projection, or also known as fiber projection, is a method to project
|
|
368
|
+
a dual quaternion onto the Study quadric, i.e. to obtain a proper rigid body
|
|
369
|
+
displacement that it represents.
|
|
370
|
+
|
|
371
|
+
:return: DualQuaternion
|
|
372
|
+
:rtype: DualQuaternion
|
|
373
|
+
"""
|
|
374
|
+
primal = self.p
|
|
375
|
+
dual = self.d
|
|
376
|
+
|
|
377
|
+
primal_2norm = 2 * primal.norm()
|
|
378
|
+
new_primal = Quaternion(np.array([primal_2norm, 0, 0, 0]))
|
|
379
|
+
new_dual = -1 * (primal * dual.conjugate() - dual * primal.conjugate())
|
|
380
|
+
|
|
381
|
+
dq = (DualQuaternion.from_two_quaternions(new_primal, new_dual)
|
|
382
|
+
* DualQuaternion.from_two_quaternions(primal, Quaternion(np.zeros(4)))
|
|
383
|
+
) / 2
|
|
384
|
+
|
|
385
|
+
return dq
|
|
281
386
|
|
|
282
387
|
def array(self) -> np.ndarray:
|
|
283
388
|
"""
|
|
@@ -325,6 +430,28 @@ class DualQuaternion:
|
|
|
325
430
|
)
|
|
326
431
|
return DualQuaternion(np.array([n, 0, 0, 0, eps_n, 0, 0, 0]))
|
|
327
432
|
|
|
433
|
+
def inv(self):
|
|
434
|
+
"""
|
|
435
|
+
Inverse of the DualQuaternion
|
|
436
|
+
|
|
437
|
+
:return: inverse of the DualQuaternion
|
|
438
|
+
:rtype: DualQuaternion
|
|
439
|
+
"""
|
|
440
|
+
p = self.p.inv()
|
|
441
|
+
d = -1 * p * self.d * p
|
|
442
|
+
return DualQuaternion.from_two_quaternions(p, d)
|
|
443
|
+
|
|
444
|
+
def is_on_study_quadric(self) -> bool:
|
|
445
|
+
"""
|
|
446
|
+
Check if the DualQuaternion is on the study quadric
|
|
447
|
+
|
|
448
|
+
:return: True if the DualQuaternion is on the study quadric, False otherwise
|
|
449
|
+
:rtype: bool
|
|
450
|
+
"""
|
|
451
|
+
study_condition = (self.p[0] * self.d[0] + self.p[1] * self.d[1]
|
|
452
|
+
+ self.p[2] * self.d[2] + self.p[3] * self.d[3])
|
|
453
|
+
return np.isclose(study_condition, 0)
|
|
454
|
+
|
|
328
455
|
def dq2matrix(self):
|
|
329
456
|
"""
|
|
330
457
|
Dual Quaternion to SE(3) transformation matrix
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
from rational_linkages import RationalMechanism
|
|
2
1
|
import numpy as np
|
|
3
2
|
|
|
3
|
+
from .RationalMechanism import RationalMechanism
|
|
4
|
+
|
|
4
5
|
|
|
5
6
|
class ExudynAnalysis:
|
|
6
7
|
"""
|
|
7
8
|
Class for dynamics analysis using Exudyn package.
|
|
9
|
+
|
|
10
|
+
The Exudyn packages is not listed in this project's requirements, please install
|
|
11
|
+
it manually. More information can be found in :ref:`documentation <exudyn_info>`
|
|
12
|
+
or the Exudyn homepage: https://github.com/jgerstmayr/EXUDYN
|
|
8
13
|
"""
|
|
9
14
|
def __init__(self, gravity: np.ndarray = np.array([0, 0, -9.81])):
|
|
10
15
|
"""
|
|
@@ -14,11 +19,24 @@ class ExudynAnalysis:
|
|
|
14
19
|
"""
|
|
15
20
|
self.gravity = gravity
|
|
16
21
|
|
|
17
|
-
def get_exudyn_params(self, mechanism: RationalMechanism):
|
|
22
|
+
def get_exudyn_params(self, mechanism: RationalMechanism) -> tuple:
|
|
18
23
|
"""
|
|
19
24
|
Get parameters for Exudyn simulation.
|
|
20
25
|
|
|
21
|
-
This method is used to get parameters for Exudyn -
|
|
26
|
+
This method is used to get parameters for Exudyn - a multibody dynamics
|
|
27
|
+
simulation package. The parameters are used to create a multibody system
|
|
28
|
+
and simulate the mechanism's dynamics.
|
|
29
|
+
|
|
30
|
+
The parameters are: links_pts (positions of links connection points),
|
|
31
|
+
links_lengths, body_dim (dimensions of rigid bodies), links_masses_pts
|
|
32
|
+
(positions of links' center of gravity), joint_axes (joints unit axes),
|
|
33
|
+
relative_links_pts (links connection points relative to its center of gravity).
|
|
34
|
+
|
|
35
|
+
:param RationalMechanism mechanism: RationalMechanism object
|
|
36
|
+
|
|
37
|
+
:return: links_pts, links_lengths, body_dim, links_masses_pts, joint_axes,
|
|
38
|
+
relative_links_pts
|
|
39
|
+
:rtype: tuple
|
|
22
40
|
"""
|
|
23
41
|
# get positions of links connection points
|
|
24
42
|
links_pts = self._links_points(mechanism)
|
|
@@ -52,9 +70,11 @@ class ExudynAnalysis:
|
|
|
52
70
|
:rtype: list
|
|
53
71
|
"""
|
|
54
72
|
# get points sequence
|
|
55
|
-
|
|
56
|
-
points = (mechanism.factorizations[0].direct_kinematics(
|
|
57
|
-
|
|
73
|
+
nearly_zero = np.finfo(float).eps
|
|
74
|
+
points = (mechanism.factorizations[0].direct_kinematics(
|
|
75
|
+
nearly_zero, inverted_part=True)
|
|
76
|
+
+ mechanism.factorizations[1].direct_kinematics(
|
|
77
|
+
nearly_zero, inverted_part=True)[::-1])
|
|
58
78
|
|
|
59
79
|
# rearamge points, so the base link has the first 2 points
|
|
60
80
|
points = points[-1:] + points[:-1]
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
from typing import Union
|
|
2
|
+
from warnings import warn
|
|
3
|
+
|
|
1
4
|
import biquaternion_py as bq
|
|
2
5
|
import numpy as np
|
|
3
6
|
import sympy as sp
|
|
4
7
|
|
|
5
|
-
from typing import Union
|
|
6
|
-
from warnings import warn
|
|
7
|
-
|
|
8
|
-
from .RationalCurve import RationalCurve
|
|
9
|
-
from .MotionFactorization import MotionFactorization
|
|
10
8
|
from .DualQuaternion import DualQuaternion
|
|
9
|
+
from .MotionFactorization import MotionFactorization
|
|
10
|
+
from .RationalCurve import RationalCurve
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class FactorizationProvider:
|
rational_linkages/Linkage.py
CHANGED
|
@@ -4,12 +4,13 @@ Classes in the Module:
|
|
|
4
4
|
- PointsConnection: Operates the connection points for a given joint.
|
|
5
5
|
- LineSegment: Represents the physical realization of a linkage.
|
|
6
6
|
"""
|
|
7
|
-
import numpy as np
|
|
8
7
|
from typing import Union
|
|
9
8
|
|
|
9
|
+
import numpy as np
|
|
10
|
+
|
|
10
11
|
from .DualQuaternion import DualQuaternion
|
|
11
|
-
from .PointHomogeneous import PointHomogeneous
|
|
12
12
|
from .NormalizedLine import NormalizedLine
|
|
13
|
+
from .PointHomogeneous import PointHomogeneous
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
class Linkage:
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
from typing import Union
|
|
2
|
+
|
|
1
3
|
import numpy as np
|
|
2
4
|
import sympy as sp
|
|
3
|
-
from typing import Union
|
|
4
5
|
|
|
5
6
|
from .DualQuaternion import DualQuaternion
|
|
6
|
-
from .PointHomogeneous import PointHomogeneous
|
|
7
|
-
from .RationalCurve import RationalCurve
|
|
8
7
|
from .Linkage import Linkage
|
|
9
8
|
from .NormalizedLine import NormalizedLine
|
|
9
|
+
from .PointHomogeneous import PointHomogeneous
|
|
10
|
+
from .RationalCurve import RationalCurve
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
class MotionFactorization(RationalCurve):
|
|
@@ -14,8 +15,8 @@ class MotionFactorization(RationalCurve):
|
|
|
14
15
|
Class representing Motion Factorization sequence
|
|
15
16
|
|
|
16
17
|
Inherits from :class:`rational_linkages.RationalCurve` class. Given as set of polynomials in
|
|
17
|
-
dual quaternion space. You can find more information in the paper by
|
|
18
|
-
|
|
18
|
+
dual quaternion space. You can find more information in the paper by
|
|
19
|
+
:footcite:t:`Frischauf2023`.
|
|
19
20
|
|
|
20
21
|
:param list[DualQuaternion] sequence_of_factored_dqs: list of DualQuaternions
|
|
21
22
|
representing the revolute axes of the rational motion factorization
|
|
@@ -41,9 +42,8 @@ class MotionFactorization(RationalCurve):
|
|
|
41
42
|
[DualQuaternion([0, 0, 0, 1, 0, 0, 0, 0]),
|
|
42
43
|
DualQuaternion([0, 0, 0, 2, 0, 0, -1, 0])])
|
|
43
44
|
|
|
44
|
-
..
|
|
45
|
-
|
|
46
|
-
DOI: 10.1016/j.mechmachtheory.2022.105143 (https://doi.org/10.1016/j.mechmachtheory.2022.105143).
|
|
45
|
+
.. footbibliography::
|
|
46
|
+
|
|
47
47
|
"""
|
|
48
48
|
|
|
49
49
|
def __init__(self, sequence_of_factored_dqs: list[DualQuaternion]):
|
|
@@ -245,7 +245,7 @@ class MotionFactorization(RationalCurve):
|
|
|
245
245
|
|
|
246
246
|
# avoid division by zero
|
|
247
247
|
if normalized_angle == 0.0:
|
|
248
|
-
normalized_angle =
|
|
248
|
+
normalized_angle = np.finfo(float).eps
|
|
249
249
|
|
|
250
250
|
sqrt_p_norm = np.sqrt(self.dq_axes[0].p.norm())
|
|
251
251
|
t = sqrt_p_norm / np.tan(normalized_angle/2) + self.dq_axes[0].p[0]
|
|
@@ -268,7 +268,7 @@ class MotionFactorization(RationalCurve):
|
|
|
268
268
|
t_param_joint0 = t_param - self.dq_axes[0].p[0]
|
|
269
269
|
|
|
270
270
|
if t_param_joint0 == 0.0:
|
|
271
|
-
t_param_joint0 =
|
|
271
|
+
t_param_joint0 = np.finfo(float).eps
|
|
272
272
|
|
|
273
273
|
angle = 2 * np.arctan(np.sqrt(self.dq_axes[0].p.norm()) / t_param_joint0)
|
|
274
274
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import sympy as sp
|
|
2
1
|
from typing import Union
|
|
3
2
|
|
|
3
|
+
import sympy as sp
|
|
4
|
+
|
|
4
5
|
from .DualQuaternion import DualQuaternion
|
|
5
|
-
from .TransfMatrix import TransfMatrix
|
|
6
6
|
from .RationalCurve import RationalCurve
|
|
7
7
|
from .RationalDualQuaternion import RationalDualQuaternion
|
|
8
|
+
from .TransfMatrix import TransfMatrix
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
class MotionInterpolation:
|
rational_linkages/Plotter.py
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
from functools import wraps
|
|
2
|
+
from itertools import cycle
|
|
3
|
+
|
|
2
4
|
import matplotlib
|
|
3
5
|
import matplotlib.pyplot as plt
|
|
6
|
+
import numpy as np
|
|
4
7
|
from matplotlib.widgets import Slider, TextBox
|
|
5
|
-
from functools import wraps
|
|
6
|
-
from itertools import cycle
|
|
7
8
|
|
|
8
9
|
from .DualQuaternion import DualQuaternion
|
|
10
|
+
from .MotionFactorization import MotionFactorization
|
|
9
11
|
from .NormalizedLine import NormalizedLine
|
|
10
12
|
from .PointHomogeneous import PointHomogeneous
|
|
11
|
-
from .
|
|
13
|
+
from .RationalBezier import RationalBezier
|
|
14
|
+
from .RationalCurve import RationalCurve
|
|
12
15
|
from .RationalMechanism import RationalMechanism
|
|
13
16
|
from .TransfMatrix import TransfMatrix
|
|
14
|
-
from .RationalCurve import RationalCurve
|
|
15
|
-
from .RationalBezier import RationalBezier
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
class Plotter:
|
rational_linkages/Quaternion.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from typing import Optional, Sequence
|
|
2
|
+
|
|
2
3
|
import numpy as np
|
|
3
4
|
|
|
4
5
|
|
|
@@ -33,6 +34,9 @@ class Quaternion:
|
|
|
33
34
|
else:
|
|
34
35
|
self.q = np.array([1, 0, 0, 0])
|
|
35
36
|
|
|
37
|
+
self.real = self.q[0]
|
|
38
|
+
self.imag = self.q[1:]
|
|
39
|
+
|
|
36
40
|
def __getitem__(self, idx):
|
|
37
41
|
"""
|
|
38
42
|
Get an element of Quaternion
|
|
@@ -49,6 +53,7 @@ class Quaternion:
|
|
|
49
53
|
Printing method override
|
|
50
54
|
|
|
51
55
|
:return: Quaterion in readable form
|
|
56
|
+
:rtype: str
|
|
52
57
|
"""
|
|
53
58
|
return f"{self.__class__.__qualname__}({self.q})"
|
|
54
59
|
|
|
@@ -77,32 +82,42 @@ class Quaternion:
|
|
|
77
82
|
:param other: Quaternion
|
|
78
83
|
:return: Quaternion
|
|
79
84
|
"""
|
|
80
|
-
|
|
81
|
-
self.q
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
+ self.q[2] * other.q[3]
|
|
90
|
-
- self.q[3] * other.q[2]
|
|
91
|
-
)
|
|
92
|
-
q2 = (
|
|
93
|
-
self.q[0] * other.q[2]
|
|
94
|
-
- self.q[1] * other.q[3]
|
|
95
|
-
+ self.q[2] * other.q[0]
|
|
96
|
-
+ self.q[3] * other.q[1]
|
|
97
|
-
)
|
|
98
|
-
q3 = (
|
|
99
|
-
self.q[0] * other.q[3]
|
|
100
|
-
+ self.q[1] * other.q[2]
|
|
101
|
-
- self.q[2] * other.q[1]
|
|
102
|
-
+ self.q[3] * other.q[0]
|
|
103
|
-
)
|
|
85
|
+
if isinstance(other, (int, float)):
|
|
86
|
+
return Quaternion(self.q * other)
|
|
87
|
+
else:
|
|
88
|
+
w, x, y, z = self.q
|
|
89
|
+
ow, ox, oy, oz = other.q
|
|
90
|
+
return Quaternion(np.array([w * ow - x * ox - y * oy - z * oz,
|
|
91
|
+
w * ox + x * ow + y * oz - z * oy,
|
|
92
|
+
w * oy - x * oz + y * ow + z * ox,
|
|
93
|
+
w * oz + x * oy - y * ox + z * ow]))
|
|
104
94
|
|
|
105
|
-
|
|
95
|
+
def __rmul__(self, other):
|
|
96
|
+
"""Handle when the quaternion is on the right side of the multiplication"""
|
|
97
|
+
return self.__mul__(other)
|
|
98
|
+
|
|
99
|
+
def __truediv__(self, other):
|
|
100
|
+
"""
|
|
101
|
+
Quaternion division
|
|
102
|
+
|
|
103
|
+
:param Quaternion, int, float other: Quaternion
|
|
104
|
+
|
|
105
|
+
:return: Quaternion
|
|
106
|
+
:rtype: Quaternion
|
|
107
|
+
"""
|
|
108
|
+
if isinstance(other, (int, float)):
|
|
109
|
+
return Quaternion(self.q / other)
|
|
110
|
+
else:
|
|
111
|
+
return self * other.inv()
|
|
112
|
+
|
|
113
|
+
def __neg__(self):
|
|
114
|
+
"""
|
|
115
|
+
Quaternion negation
|
|
116
|
+
|
|
117
|
+
:return: Quaternion
|
|
118
|
+
:rtype: Quaternion
|
|
119
|
+
"""
|
|
120
|
+
return Quaternion(-1 * self.q)
|
|
106
121
|
|
|
107
122
|
def __eq__(self, other):
|
|
108
123
|
"""
|
|
@@ -116,14 +131,18 @@ class Quaternion:
|
|
|
116
131
|
def array(self):
|
|
117
132
|
"""
|
|
118
133
|
Quaternion to numpy array
|
|
134
|
+
|
|
119
135
|
:return: numpy array of quaternion 4-vector parameters
|
|
136
|
+
:rtype: np.ndarray
|
|
120
137
|
"""
|
|
121
138
|
return np.array([self.q[0], self.q[1], self.q[2], self.q[3]])
|
|
122
139
|
|
|
123
140
|
def conjugate(self):
|
|
124
141
|
"""
|
|
125
142
|
Quaternion conjugate
|
|
143
|
+
|
|
126
144
|
:return: Quaternion
|
|
145
|
+
:rtype: Quaternion
|
|
127
146
|
"""
|
|
128
147
|
q0 = self.q[0]
|
|
129
148
|
q1 = -1 * self.q[1]
|
|
@@ -134,21 +153,32 @@ class Quaternion:
|
|
|
134
153
|
|
|
135
154
|
def norm(self):
|
|
136
155
|
"""
|
|
137
|
-
Quaternion norm
|
|
156
|
+
Quaternion norm, aslo called the Quadrance
|
|
157
|
+
|
|
138
158
|
:return: Quaternion
|
|
159
|
+
:rtype: float
|
|
139
160
|
"""
|
|
140
161
|
q0 = self.q[0]
|
|
141
162
|
q1 = self.q[1]
|
|
142
163
|
q2 = self.q[2]
|
|
143
164
|
q3 = self.q[3]
|
|
144
165
|
|
|
145
|
-
|
|
146
|
-
|
|
166
|
+
return q0**2 + q1**2 + q2**2 + q3**2
|
|
167
|
+
|
|
168
|
+
def length(self):
|
|
169
|
+
"""
|
|
170
|
+
Quaternion length
|
|
171
|
+
|
|
172
|
+
:return: Quaternion
|
|
173
|
+
:rtype: float
|
|
174
|
+
"""
|
|
175
|
+
return np.sqrt(self.norm())
|
|
147
176
|
|
|
148
177
|
def inv(self):
|
|
149
178
|
"""
|
|
150
179
|
Quaternion inverse
|
|
180
|
+
|
|
151
181
|
:return: Quaternion
|
|
182
|
+
:rtype: Quaternion
|
|
152
183
|
"""
|
|
153
|
-
|
|
154
|
-
return Quaternion(_inv)
|
|
184
|
+
return Quaternion(self.conjugate().array() / self.norm())
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import sympy as sp
|
|
1
|
+
import pickle
|
|
3
2
|
from copy import deepcopy
|
|
4
3
|
from time import time
|
|
5
4
|
from typing import Union
|
|
6
|
-
import pickle
|
|
7
5
|
|
|
8
|
-
|
|
6
|
+
import numpy as np
|
|
7
|
+
import sympy as sp
|
|
8
|
+
|
|
9
9
|
from .DualQuaternion import DualQuaternion
|
|
10
|
-
from .NormalizedLine import NormalizedLine
|
|
11
10
|
from .MotionFactorization import MotionFactorization
|
|
11
|
+
from .NormalizedLine import NormalizedLine
|
|
12
|
+
from .RationalCurve import RationalCurve
|
|
12
13
|
from .TransfMatrix import TransfMatrix
|
|
13
14
|
|
|
14
15
|
PointHomogeneous = 'PointHomogeneous'
|
|
@@ -126,14 +127,15 @@ class RationalMechanism(RationalCurve):
|
|
|
126
127
|
return tool
|
|
127
128
|
elif tool == 'mid_of_last_link':
|
|
128
129
|
# calculate the midpoint of the last link
|
|
129
|
-
|
|
130
|
-
|
|
130
|
+
nearly_zero = np.finfo(float).eps
|
|
131
|
+
p0 = self.factorizations[0].direct_kinematics(nearly_zero, inverted_part=True)[-1]
|
|
132
|
+
p1 = self.factorizations[1].direct_kinematics(nearly_zero, inverted_part=True)[-1]
|
|
131
133
|
|
|
132
134
|
# define the x axis vector - along the last link
|
|
133
135
|
vec_x = (p1 - p0) / np.linalg.norm(p1 - p0)
|
|
134
136
|
|
|
135
137
|
# get some random vector from the last joint points
|
|
136
|
-
vec_y_pts = self.factorizations[0].direct_kinematics(
|
|
138
|
+
vec_y_pts = self.factorizations[0].direct_kinematics(nearly_zero, inverted_part=True)[-2:]
|
|
137
139
|
vec_y = vec_y_pts[1] - vec_y_pts[0]
|
|
138
140
|
|
|
139
141
|
# define the z axis vector - perpendicular to the x and y vectors
|
|
@@ -227,7 +229,7 @@ class RationalMechanism(RationalCurve):
|
|
|
227
229
|
The parameters are in the order: theta, d, a, alpha. It follows the standard
|
|
228
230
|
convention. The first row is are the parameters of the base frame.
|
|
229
231
|
|
|
230
|
-
See more in the paper by
|
|
232
|
+
See more in the paper by :footcite:t:`Huczala2022iccma`.
|
|
231
233
|
|
|
232
234
|
:param str unit: desired unit of the angle parameters, can be 'deg' or 'rad'
|
|
233
235
|
:param float scale: scale of the length parameters of the linkage
|
|
@@ -235,12 +237,8 @@ class RationalMechanism(RationalCurve):
|
|
|
235
237
|
:return: theta, d, a, alpha array of Denavit-Hartenberg parameters
|
|
236
238
|
:rtype: np.ndarray
|
|
237
239
|
|
|
238
|
-
..
|
|
239
|
-
|
|
240
|
-
2022 *10th International Conference on Control, Mechatronics and Automation
|
|
241
|
-
(ICCMA)*, Belval, Luxembourg, 2022, pp. 47-52,
|
|
242
|
-
DOI: 10.1109/ICCMA56665.2022.10011595
|
|
243
|
-
(https://doi.org/10.1109/ICCMA56665.2022.10011595).
|
|
240
|
+
.. footbibliography::
|
|
241
|
+
|
|
244
242
|
"""
|
|
245
243
|
frames = self.get_frames()
|
|
246
244
|
|
rational_linkages/__init__.py
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
from .DualQuaternion import DualQuaternion
|
|
2
2
|
from .DualQuaternionAction import DualQuaternionAction
|
|
3
|
-
from .RationalCurve import RationalCurve
|
|
4
3
|
from .ExudynAnalysis import ExudynAnalysis
|
|
5
4
|
from .FactorizationProvider import FactorizationProvider
|
|
6
|
-
from .Linkage import Linkage, PointsConnection
|
|
5
|
+
from .Linkage import LineSegment, Linkage, PointsConnection
|
|
7
6
|
from .MiniBall import MiniBall
|
|
8
|
-
from .MotionInterpolation import MotionInterpolation
|
|
9
7
|
from .MotionFactorization import MotionFactorization
|
|
8
|
+
from .MotionInterpolation import MotionInterpolation
|
|
10
9
|
from .NormalizedLine import NormalizedLine
|
|
11
10
|
from .Plotter import Plotter
|
|
12
11
|
from .PointHomogeneous import PointHomogeneous
|
|
13
12
|
from .Quaternion import Quaternion
|
|
14
13
|
from .RationalBezier import RationalBezier
|
|
14
|
+
from .RationalCurve import RationalCurve
|
|
15
15
|
from .RationalDualQuaternion import RationalDualQuaternion
|
|
16
16
|
from .RationalMechanism import RationalMechanism
|
|
17
17
|
from .TransfMatrix import TransfMatrix
|
|
Binary file
|
rational_linkages/models.py
CHANGED
|
@@ -20,3 +20,17 @@ def bennett_ark24() -> RationalMechanism:
|
|
|
20
20
|
with importlib.resources.path(resource_package, resource_path) as file_path:
|
|
21
21
|
with open(file_path, 'rb') as f:
|
|
22
22
|
return pickle.load(f)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def collisions_free_6r() -> RationalMechanism:
|
|
26
|
+
"""
|
|
27
|
+
Returns a RationalMechanism object of a 6R collision-free realization.
|
|
28
|
+
|
|
29
|
+
:return: RationalMechanism object for the 6R linkage.
|
|
30
|
+
:rtype: RationalMechanism
|
|
31
|
+
"""
|
|
32
|
+
resource_package = "rational_linkages.data"
|
|
33
|
+
resource_path = 'collisions_free_6r.pkl'
|
|
34
|
+
with importlib.resources.path(resource_package, resource_path) as file_path:
|
|
35
|
+
with open(file_path, 'rb') as f:
|
|
36
|
+
return pickle.load(f)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: rational-linkages
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.dev4
|
|
4
4
|
Summary: Rational Linkages Toolbox
|
|
5
5
|
Author-email: Daniel Huczala <daniel.huczala@uibk.ac.at>
|
|
6
6
|
License: GNU GENERAL PUBLIC LICENSE
|
|
@@ -692,17 +692,20 @@ Requires-Dist: sympy >=1.8.0
|
|
|
692
692
|
Requires-Dist: matplotlib >=3.4.0
|
|
693
693
|
Requires-Dist: biquaternion-py >=1.2.0
|
|
694
694
|
Requires-Dist: PyQt5 >=5.15.10
|
|
695
|
-
Requires-Dist: exudyn >=1.7.0
|
|
696
695
|
Provides-Extra: dev
|
|
696
|
+
Requires-Dist: build ; extra == 'dev'
|
|
697
697
|
Requires-Dist: coverage ; extra == 'dev'
|
|
698
698
|
Requires-Dist: pytest ; extra == 'dev'
|
|
699
699
|
Requires-Dist: flake8 ; extra == 'dev'
|
|
700
|
+
Requires-Dist: flake8-pyproject ; extra == 'dev'
|
|
700
701
|
Requires-Dist: black ; extra == 'dev'
|
|
702
|
+
Requires-Dist: isort ; extra == 'dev'
|
|
701
703
|
Requires-Dist: twine ; extra == 'dev'
|
|
702
704
|
Provides-Extra: doc
|
|
703
705
|
Requires-Dist: sphinx ; extra == 'doc'
|
|
704
706
|
Requires-Dist: sphinx-rtd-theme ; extra == 'doc'
|
|
705
707
|
Requires-Dist: nbsphinx ; extra == 'doc'
|
|
708
|
+
Requires-Dist: sphinxcontrib-bibtex ; extra == 'doc'
|
|
706
709
|
Requires-Dist: toml ; extra == 'doc'
|
|
707
710
|
|
|
708
711
|
[](https://git.uibk.ac.at/geometrie-vermessung/rational-linkages/-/jobs)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
rational_linkages/AffineMatrix.py,sha256=TjbKzwEIcw0S8cqlNT3rOXIkaUWPJQdD1ILzLHdXchE,1348
|
|
2
|
+
rational_linkages/AffineMetric.py,sha256=XfARQoHnfV8Hv8jaFNnI-Bmserh8E03VPdWC3T8KP9A,4328
|
|
3
|
+
rational_linkages/ButtonID.py,sha256=wOmSGNFHkLrt8Hh5Pl8j1eqpNsYnH8GWcXLDz4g-WEY,1128
|
|
4
|
+
rational_linkages/DualQuaternion.py,sha256=pJKfv3TaQ66CBEbL7mmS8T1oW0F4KEuY3Ttmh8dE288,20706
|
|
5
|
+
rational_linkages/DualQuaternionAction.py,sha256=93kPn3Buuj7Wno6Cl312cGOqiMW5-oHzUvfvzMMptxw,4133
|
|
6
|
+
rational_linkages/ExudynAnalysis.py,sha256=8tyTOQHvWhYRV6s30OK4zLuCaNv0DOtmZCeDKArtvKs,4987
|
|
7
|
+
rational_linkages/FactorizationProvider.py,sha256=JbD_9xmmg-pe5YyeW10DRRSI4JNPJgYha9ihzFY19_E,5931
|
|
8
|
+
rational_linkages/Linkage.py,sha256=8ZuvNTYGn-ybSqRDgYg0BqqsERHRBH8LHzoQflUEETk,8490
|
|
9
|
+
rational_linkages/MiniBall.py,sha256=UZlSxiSEzj-JXb4p1aq7mlDUv_o70NfGhj6HQ50Ca3E,4171
|
|
10
|
+
rational_linkages/MotionApproximation.py,sha256=A4lJ5n4UNhHb0_B5ph-Sr_E16PoVe6Ua3e_XCHA68ek,2772
|
|
11
|
+
rational_linkages/MotionFactorization.py,sha256=dh3OJziK4SXo21FHumAtzSsvlWDagG4YvkSLKQXnv84,14422
|
|
12
|
+
rational_linkages/MotionInterpolation.py,sha256=bu4jKVVPl6rkBerdkfuxSwe_-e3PDM2bUEZJzP_hTJY,12118
|
|
13
|
+
rational_linkages/NormalizedLine.py,sha256=tx7JISThQrLcK2LOqEo5WGwP96eudQSNhzjfdxdIjjk,13671
|
|
14
|
+
rational_linkages/Plotter.py,sha256=j9DhzbB43mVmFwreTEJBo7QVGGNAzuF9pRIi0wW5fcg,23789
|
|
15
|
+
rational_linkages/PointHomogeneous.py,sha256=7Soo1NyCg2Wf2pdNhK7JZM5iYKtJkF8r9nzLMh-kqiA,7737
|
|
16
|
+
rational_linkages/Quaternion.py,sha256=I4vszcf2LuXwp9yksNekydyqHeCsqilTdvoSTA__Hgg,4674
|
|
17
|
+
rational_linkages/RationalBezier.py,sha256=Vl8aLtrx0nin9ntrDzeNyK7JY6O4P0bk55O9q2Q9Km0,5190
|
|
18
|
+
rational_linkages/RationalCurve.py,sha256=X4xTG_lCEnN2srB_P600u5Q_2bCLNOOiuyQ6BGaNzt4,13790
|
|
19
|
+
rational_linkages/RationalDualQuaternion.py,sha256=_g87ZCk6Z4mN1_IKBqbR-N0-GWQ7xSrnPXZb7dxkj1M,1487
|
|
20
|
+
rational_linkages/RationalMechanism.py,sha256=zfZ0-x_77OcFT57Gk0v87QPZHi-R7h6MRluQ12sjgxY,26858
|
|
21
|
+
rational_linkages/TransfMatrix.py,sha256=n5t9jYxFjvbYe7kuOgPiDrsdi_EbQ1i5xwvNWv9Iw-o,13800
|
|
22
|
+
rational_linkages/__init__.py,sha256=DgGUHCaMI2eL6AOXwwx-7uFFhO6PqZXEd5sIRsqfz9o,797
|
|
23
|
+
rational_linkages/models.py,sha256=qjT2gcW20DUr3vJHbgbH5qtDXsipcWYR_xFxvKEQ9pY,1266
|
|
24
|
+
rational_linkages/data/bennett_ark24.pkl,sha256=uH0oHezZeleNvXW5JeSEc3cAhi15EWFdhvyEDtjwnz4,40058
|
|
25
|
+
rational_linkages/data/collisions_free_6r.pkl,sha256=-0eq0c9ykNbAo2PObs3C5emmUHsn3v4ka9EksWNnmXg,73944
|
|
26
|
+
rational_linkages-1.2.dev4.dist-info/LICENSE,sha256=SrpxAZ1vJi81S4VF9EBjgxz9qrVj9acCyQPSAk3JgOo,35784
|
|
27
|
+
rational_linkages-1.2.dev4.dist-info/METADATA,sha256=1jodk7C-Oj3BSc9hxH-x12q3aqp-JECWAXjTnx8oRd0,44816
|
|
28
|
+
rational_linkages-1.2.dev4.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
29
|
+
rational_linkages-1.2.dev4.dist-info/top_level.txt,sha256=IxRIuCa6RJFZKK15jamktxgS0abg1PV2WqXo1Z-MalI,18
|
|
30
|
+
rational_linkages-1.2.dev4.dist-info/RECORD,,
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
rational_linkages/AffineMatrix.py,sha256=TjbKzwEIcw0S8cqlNT3rOXIkaUWPJQdD1ILzLHdXchE,1348
|
|
2
|
-
rational_linkages/AffineMetric.py,sha256=6Z1KP1W6uXwlRToofcu-nXlygn_EJ_zmLoT_0nE8Zyo,4328
|
|
3
|
-
rational_linkages/ButtonID.py,sha256=wOmSGNFHkLrt8Hh5Pl8j1eqpNsYnH8GWcXLDz4g-WEY,1128
|
|
4
|
-
rational_linkages/DualQuaternion.py,sha256=949za5fuBok0soJpWMDBKz4MYj4CLUnDJXzbc-ftvcU,16499
|
|
5
|
-
rational_linkages/DualQuaternionAction.py,sha256=93kPn3Buuj7Wno6Cl312cGOqiMW5-oHzUvfvzMMptxw,4133
|
|
6
|
-
rational_linkages/ExudynAnalysis.py,sha256=mhTXzumFwsxp65VdeSXh-6wxTi5ubX6znJgfX554PYI,3975
|
|
7
|
-
rational_linkages/FactorizationProvider.py,sha256=umQUrv3YQS8gzDlj3y93X5PtKSLR6kn3C4FQDsRFli8,5931
|
|
8
|
-
rational_linkages/Linkage.py,sha256=-GpnnAhiQ3EbysaTtRwrKXpuM_DuxSEsKQAB8gfy0IY,8488
|
|
9
|
-
rational_linkages/MiniBall.py,sha256=UZlSxiSEzj-JXb4p1aq7mlDUv_o70NfGhj6HQ50Ca3E,4171
|
|
10
|
-
rational_linkages/MotionApproximation.py,sha256=A4lJ5n4UNhHb0_B5ph-Sr_E16PoVe6Ua3e_XCHA68ek,2772
|
|
11
|
-
rational_linkages/MotionFactorization.py,sha256=p8OOZ5tiaDXSDzzh6nOCyqWeWMIsAjW2FR2C2pyGFiw,14698
|
|
12
|
-
rational_linkages/MotionInterpolation.py,sha256=jeu8zjkXDLJp1oASjlF_Hg5PsgM_spyFlVHBgOWBHw8,12116
|
|
13
|
-
rational_linkages/NormalizedLine.py,sha256=krIKi_ocQn7cyIDKYIhbNNqg_ZSrpiXyEtSokDPQlbw,13671
|
|
14
|
-
rational_linkages/Plotter.py,sha256=lm7AkYjtCH7tenbFtZGptWhGKOeM81BNRfxM7K1nKlA,23787
|
|
15
|
-
rational_linkages/PointHomogeneous.py,sha256=rQgt1DHITSWx3OP2rI5MdmDKoDlTLDEOEaiWu0DkuBU,7735
|
|
16
|
-
rational_linkages/Quaternion.py,sha256=pH85fUZ9IlJUmIQjltsBBCxD4bR1bLE1EdeUCM1LS9s,3903
|
|
17
|
-
rational_linkages/RationalBezier.py,sha256=5Nyu0WfH4FKv8gZbt7V2VeXgmhT-qIUKo6OQLKFs-YA,5188
|
|
18
|
-
rational_linkages/RationalCurve.py,sha256=mp6BN8fB181zPGFM1lqrvDrWlHiNoH6kORBzCCVzJCY,13790
|
|
19
|
-
rational_linkages/RationalDualQuaternion.py,sha256=_g87ZCk6Z4mN1_IKBqbR-N0-GWQ7xSrnPXZb7dxkj1M,1487
|
|
20
|
-
rational_linkages/RationalMechanism.py,sha256=_lvHIqY97c5LBdmBVxdrylqWtfNqxl_aLBzrnqA06B8,27251
|
|
21
|
-
rational_linkages/TransfMatrix.py,sha256=MOggM2qqDWS6MM40cRnz6dHT6f06WUsKIKsEpa-K7kE,13798
|
|
22
|
-
rational_linkages/__init__.py,sha256=QMIjaftOVbz4s4KRUl8zUheiPAYIxCGciGCZFx9kPS0,797
|
|
23
|
-
rational_linkages/models.py,sha256=N3Pk6Nz2BhI4M90FwcLiFL5gGueaKGWHeMZNyywaia4,774
|
|
24
|
-
rational_linkages/data/bennett_ark24.pkl,sha256=uH0oHezZeleNvXW5JeSEc3cAhi15EWFdhvyEDtjwnz4,40058
|
|
25
|
-
rational_linkages-1.2.dev2.dist-info/LICENSE,sha256=SrpxAZ1vJi81S4VF9EBjgxz9qrVj9acCyQPSAk3JgOo,35784
|
|
26
|
-
rational_linkages-1.2.dev2.dist-info/METADATA,sha256=YReQUerHfHtZd7aS7vovfUBIIuOz2-k6mZx2EKiMtO0,44665
|
|
27
|
-
rational_linkages-1.2.dev2.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
28
|
-
rational_linkages-1.2.dev2.dist-info/top_level.txt,sha256=IxRIuCa6RJFZKK15jamktxgS0abg1PV2WqXo1Z-MalI,18
|
|
29
|
-
rational_linkages-1.2.dev2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|