rational-linkages 1.2.dev2__tar.gz → 1.2.dev4__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.

Potentially problematic release.


This version of rational-linkages might be problematic. Click here for more details.

Files changed (35) hide show
  1. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/PKG-INFO +5 -2
  2. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/pyproject.toml +10 -7
  3. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/python/rational_linkages/AffineMetric.py +2 -2
  4. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/python/rational_linkages/DualQuaternion.py +133 -6
  5. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/python/rational_linkages/ExudynAnalysis.py +26 -6
  6. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/python/rational_linkages/FactorizationProvider.py +5 -5
  7. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/python/rational_linkages/Linkage.py +3 -2
  8. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/python/rational_linkages/MotionFactorization.py +10 -10
  9. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/python/rational_linkages/MotionInterpolation.py +3 -2
  10. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/python/rational_linkages/NormalizedLine.py +1 -1
  11. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/python/rational_linkages/Plotter.py +7 -6
  12. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/python/rational_linkages/PointHomogeneous.py +1 -0
  13. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/python/rational_linkages/Quaternion.py +60 -30
  14. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/python/rational_linkages/RationalBezier.py +1 -0
  15. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/python/rational_linkages/RationalCurve.py +1 -1
  16. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/python/rational_linkages/RationalMechanism.py +13 -15
  17. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/python/rational_linkages/TransfMatrix.py +3 -2
  18. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/python/rational_linkages/__init__.py +3 -3
  19. rational-linkages-1.2.dev4/python/rational_linkages/data/collisions_free_6r.pkl +0 -0
  20. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/python/rational_linkages/models.py +14 -0
  21. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/python/rational_linkages.egg-info/PKG-INFO +5 -2
  22. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/python/rational_linkages.egg-info/SOURCES.txt +2 -1
  23. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/python/rational_linkages.egg-info/requires.txt +4 -1
  24. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/LICENSE +0 -0
  25. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/README.md +0 -0
  26. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/python/rational_linkages/AffineMatrix.py +0 -0
  27. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/python/rational_linkages/ButtonID.py +0 -0
  28. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/python/rational_linkages/DualQuaternionAction.py +0 -0
  29. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/python/rational_linkages/MiniBall.py +0 -0
  30. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/python/rational_linkages/MotionApproximation.py +0 -0
  31. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/python/rational_linkages/RationalDualQuaternion.py +0 -0
  32. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/python/rational_linkages/data/bennett_ark24.pkl +0 -0
  33. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/python/rational_linkages.egg-info/dependency_links.txt +0 -0
  34. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/python/rational_linkages.egg-info/top_level.txt +0 -0
  35. {rational-linkages-1.2.dev2 → rational-linkages-1.2.dev4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: rational-linkages
3
- Version: 1.2.dev2
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: doc
697
696
  Requires-Dist: sphinx; extra == "doc"
698
697
  Requires-Dist: sphinx-rtd-theme; extra == "doc"
699
698
  Requires-Dist: nbsphinx; extra == "doc"
699
+ Requires-Dist: sphinxcontrib-bibtex; extra == "doc"
700
700
  Requires-Dist: toml; extra == "doc"
701
701
  Provides-Extra: dev
702
+ Requires-Dist: build; extra == "dev"
702
703
  Requires-Dist: coverage; extra == "dev"
703
704
  Requires-Dist: pytest; extra == "dev"
704
705
  Requires-Dist: flake8; extra == "dev"
706
+ Requires-Dist: flake8-pyproject; extra == "dev"
705
707
  Requires-Dist: black; extra == "dev"
708
+ Requires-Dist: isort; extra == "dev"
706
709
  Requires-Dist: twine; extra == "dev"
707
710
 
708
711
  [![build](https://git.uibk.ac.at/geometrie-vermessung/rational-linkages/badges/main/pipeline.svg)](https://git.uibk.ac.at/geometrie-vermessung/rational-linkages/-/jobs)
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "rational-linkages"
7
- version = "1.2.dev2"
7
+ version = "1.2.dev4"
8
8
  description = "Rational Linkages Toolbox"
9
9
  authors = [
10
10
  {name = "Daniel Huczala", email = "daniel.huczala@uibk.ac.at"},
@@ -24,7 +24,6 @@ dependencies = [
24
24
  "matplotlib >= 3.4.0",
25
25
  "biquaternion-py >= 1.2.0",
26
26
  "PyQt5 >= 5.15.10",
27
- "exudyn >= 1.7.0",
28
27
  ]
29
28
 
30
29
  [project.optional-dependencies]
@@ -32,13 +31,17 @@ doc = [
32
31
  "sphinx",
33
32
  "sphinx-rtd-theme",
34
33
  "nbsphinx",
34
+ "sphinxcontrib-bibtex",
35
35
  "toml",
36
36
  ]
37
37
  dev = [
38
+ "build",
38
39
  "coverage",
39
40
  "pytest",
40
41
  "flake8",
42
+ "flake8-pyproject",
41
43
  "black",
44
+ "isort",
42
45
  "twine"
43
46
  ]
44
47
 
@@ -57,19 +60,19 @@ Issues = "https://git.uibk.ac.at/geometrie-vermessung/rational-linkages/-/issues
57
60
  [tool.black]
58
61
  line-length = 88
59
62
  target-version = ["py311"]
60
- exclude = "(.git|.idea|docs)/.*"
63
+ exclude = "(.git|.idea|docs|dist|rational_linkages.egg-info)/.*"
61
64
 
62
65
  [tool.isort]
63
66
  profile = "black"
64
67
  line_length = 88
65
- skip = [".git", ".idea", "docs"]
66
- known_first_party = ["linkages"]
67
- force_to_top = ["linkages"]
68
+ skip = [".git", ".idea", "docs", "dist", "rational_linkages.egg-info"]
69
+ known_first_party = ["rational_linkages"]
70
+ force_to_top = ["rational_linkages"]
68
71
 
69
72
  [tool.flake8]
70
73
  max-line-length = '88'
71
74
  ignore = ["E501"]
72
- exclude = ".git, .idea, docs"
75
+ exclude = ".git, .idea, docs, dist, rational_linkages.egg-info"
73
76
 
74
77
  [tool.coverage.run]
75
78
  command_line = "-m pytest python/tests"
@@ -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
- from sympy import Expr
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
- p = self.p * other.p
279
- d = (self.d * other.p) + (self.p * other.d)
280
- return DualQuaternion.from_two_quaternions(p, d)
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
- t = .0000000000000000000000001
56
- points = (mechanism.factorizations[0].direct_kinematics(t, inverted_part=True)
57
- + mechanism.factorizations[1].direct_kinematics(t, inverted_part=True)[::-1])
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:
@@ -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 Frischauf et
18
- al. [#frischauf2022]_.
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
- .. [#frischauf2022] Frischauf, Johanna et al. (2022). A multi-Bennett 8R mechanism obtained from
45
- factorization of bivariate motion polynomials. *Mechanisms and Machine Theory*.
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 = 0.000000000000000001
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 = 0.000000000000000001
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:
@@ -1,5 +1,5 @@
1
+ from typing import Optional, Sequence, Union
1
2
  from warnings import warn
2
- from typing import Union, Optional, Sequence
3
3
 
4
4
  import numpy as np
5
5
  from sympy import Expr
@@ -1,18 +1,19 @@
1
- import numpy as np
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 .MotionFactorization import MotionFactorization
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:
@@ -1,4 +1,5 @@
1
1
  from math import isclose
2
+
2
3
  import numpy as np
3
4
 
4
5
  from .TransfMatrix import TransfMatrix
@@ -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
- q0 = (
81
- self.q[0] * other.q[0]
82
- - self.q[1] * other.q[1]
83
- - self.q[2] * other.q[2]
84
- - self.q[3] * other.q[3]
85
- )
86
- q1 = (
87
- self.q[0] * other.q[1]
88
- + self.q[1] * other.q[0]
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
- return Quaternion(np.array([q0, q1, q2, q3]))
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
- _n = q0**2 + q1**2 + q2**2 + q3**2
146
- return _n
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
- _inv = self.conjugate().array() / self.norm()
154
- return Quaternion(_inv)
184
+ return Quaternion(self.conjugate().array() / self.norm())
@@ -1,4 +1,5 @@
1
1
  from copy import deepcopy
2
+
2
3
  import sympy as sp
3
4
 
4
5
  from .MiniBall import MiniBall
@@ -1,11 +1,11 @@
1
1
  from copy import deepcopy
2
2
  from typing import Union
3
+
3
4
  import numpy as np
4
5
  import sympy as sp
5
6
 
6
7
  from .PointHomogeneous import PointHomogeneous
7
8
 
8
-
9
9
  MotionFactorization = "MotionFactorization"
10
10
 
11
11
 
@@ -1,14 +1,15 @@
1
- import numpy as np
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
- from .RationalCurve import RationalCurve
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
- p0 = self.factorizations[0].direct_kinematics(0.0000000000000000001, inverted_part=True)[-1]
130
- p1 = self.factorizations[1].direct_kinematics(0.0000000000000000001, inverted_part=True)[-1]
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(0.0000000000000000001, inverted_part=True)[-2:]
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 Huczala et al. [#huczala2022icma]_.
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
- .. [#huczala2022icma] D. Huczala, T. Kot, J. Mlotek, J. Suder and M. Pfurner,
239
- "An Automated Conversion Between Selected Robot Kinematic Representations,"
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
 
@@ -1,6 +1,7 @@
1
- import numpy as np
2
- from warnings import warn
3
1
  from typing import Union
2
+ from warnings import warn
3
+
4
+ import numpy as np
4
5
 
5
6
 
6
7
  class TransfMatrix:
@@ -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, LineSegment
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
@@ -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.dev2
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: doc
697
696
  Requires-Dist: sphinx; extra == "doc"
698
697
  Requires-Dist: sphinx-rtd-theme; extra == "doc"
699
698
  Requires-Dist: nbsphinx; extra == "doc"
699
+ Requires-Dist: sphinxcontrib-bibtex; extra == "doc"
700
700
  Requires-Dist: toml; extra == "doc"
701
701
  Provides-Extra: dev
702
+ Requires-Dist: build; extra == "dev"
702
703
  Requires-Dist: coverage; extra == "dev"
703
704
  Requires-Dist: pytest; extra == "dev"
704
705
  Requires-Dist: flake8; extra == "dev"
706
+ Requires-Dist: flake8-pyproject; extra == "dev"
705
707
  Requires-Dist: black; extra == "dev"
708
+ Requires-Dist: isort; extra == "dev"
706
709
  Requires-Dist: twine; extra == "dev"
707
710
 
708
711
  [![build](https://git.uibk.ac.at/geometrie-vermessung/rational-linkages/badges/main/pipeline.svg)](https://git.uibk.ac.at/geometrie-vermessung/rational-linkages/-/jobs)
@@ -29,4 +29,5 @@ python/rational_linkages.egg-info/SOURCES.txt
29
29
  python/rational_linkages.egg-info/dependency_links.txt
30
30
  python/rational_linkages.egg-info/requires.txt
31
31
  python/rational_linkages.egg-info/top_level.txt
32
- python/rational_linkages/data/bennett_ark24.pkl
32
+ python/rational_linkages/data/bennett_ark24.pkl
33
+ python/rational_linkages/data/collisions_free_6r.pkl
@@ -3,17 +3,20 @@ sympy>=1.8.0
3
3
  matplotlib>=3.4.0
4
4
  biquaternion-py>=1.2.0
5
5
  PyQt5>=5.15.10
6
- exudyn>=1.7.0
7
6
 
8
7
  [dev]
8
+ build
9
9
  coverage
10
10
  pytest
11
11
  flake8
12
+ flake8-pyproject
12
13
  black
14
+ isort
13
15
  twine
14
16
 
15
17
  [doc]
16
18
  sphinx
17
19
  sphinx-rtd-theme
18
20
  nbsphinx
21
+ sphinxcontrib-bibtex
19
22
  toml