rational-linkages 1.1.1__tar.gz → 1.2.dev2__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.1.1 → rational-linkages-1.2.dev2}/PKG-INFO +17 -5
  2. {rational-linkages-1.1.1 → rational-linkages-1.2.dev2}/README.md +15 -4
  3. {rational-linkages-1.1.1 → rational-linkages-1.2.dev2}/pyproject.toml +4 -3
  4. {rational-linkages-1.1.1 → rational-linkages-1.2.dev2}/python/rational_linkages/DualQuaternion.py +134 -65
  5. {rational-linkages-1.1.1 → rational-linkages-1.2.dev2}/python/rational_linkages/DualQuaternionAction.py +6 -4
  6. rational-linkages-1.2.dev2/python/rational_linkages/ExudynAnalysis.py +123 -0
  7. {rational-linkages-1.1.1 → rational-linkages-1.2.dev2}/python/rational_linkages/FactorizationProvider.py +2 -3
  8. {rational-linkages-1.1.1 → rational-linkages-1.2.dev2}/python/rational_linkages/Linkage.py +1 -1
  9. {rational-linkages-1.1.1 → rational-linkages-1.2.dev2}/python/rational_linkages/MotionFactorization.py +8 -8
  10. {rational-linkages-1.1.1 → rational-linkages-1.2.dev2}/python/rational_linkages/MotionInterpolation.py +18 -13
  11. {rational-linkages-1.1.1 → rational-linkages-1.2.dev2}/python/rational_linkages/NormalizedLine.py +29 -31
  12. {rational-linkages-1.1.1 → rational-linkages-1.2.dev2}/python/rational_linkages/Plotter.py +56 -6
  13. {rational-linkages-1.1.1 → rational-linkages-1.2.dev2}/python/rational_linkages/PointHomogeneous.py +27 -17
  14. {rational-linkages-1.1.1 → rational-linkages-1.2.dev2}/python/rational_linkages/Quaternion.py +3 -2
  15. {rational-linkages-1.1.1 → rational-linkages-1.2.dev2}/python/rational_linkages/RationalBezier.py +5 -3
  16. {rational-linkages-1.1.1 → rational-linkages-1.2.dev2}/python/rational_linkages/RationalCurve.py +6 -4
  17. {rational-linkages-1.1.1 → rational-linkages-1.2.dev2}/python/rational_linkages/RationalDualQuaternion.py +3 -3
  18. {rational-linkages-1.1.1 → rational-linkages-1.2.dev2}/python/rational_linkages/RationalMechanism.py +54 -8
  19. {rational-linkages-1.1.1 → rational-linkages-1.2.dev2}/python/rational_linkages/TransfMatrix.py +3 -0
  20. {rational-linkages-1.1.1 → rational-linkages-1.2.dev2}/python/rational_linkages/__init__.py +1 -0
  21. rational-linkages-1.2.dev2/python/rational_linkages/data/bennett_ark24.pkl +0 -0
  22. {rational-linkages-1.1.1 → rational-linkages-1.2.dev2}/python/rational_linkages.egg-info/PKG-INFO +17 -5
  23. {rational-linkages-1.1.1 → rational-linkages-1.2.dev2}/python/rational_linkages.egg-info/SOURCES.txt +1 -0
  24. {rational-linkages-1.1.1 → rational-linkages-1.2.dev2}/python/rational_linkages.egg-info/requires.txt +2 -1
  25. rational-linkages-1.1.1/python/rational_linkages/data/bennett_ark24.pkl +0 -0
  26. {rational-linkages-1.1.1 → rational-linkages-1.2.dev2}/LICENSE +0 -0
  27. {rational-linkages-1.1.1 → rational-linkages-1.2.dev2}/python/rational_linkages/AffineMatrix.py +0 -0
  28. {rational-linkages-1.1.1 → rational-linkages-1.2.dev2}/python/rational_linkages/AffineMetric.py +0 -0
  29. {rational-linkages-1.1.1 → rational-linkages-1.2.dev2}/python/rational_linkages/ButtonID.py +0 -0
  30. {rational-linkages-1.1.1 → rational-linkages-1.2.dev2}/python/rational_linkages/MiniBall.py +0 -0
  31. {rational-linkages-1.1.1 → rational-linkages-1.2.dev2}/python/rational_linkages/MotionApproximation.py +0 -0
  32. {rational-linkages-1.1.1 → rational-linkages-1.2.dev2}/python/rational_linkages/models.py +0 -0
  33. {rational-linkages-1.1.1 → rational-linkages-1.2.dev2}/python/rational_linkages.egg-info/dependency_links.txt +0 -0
  34. {rational-linkages-1.1.1 → rational-linkages-1.2.dev2}/python/rational_linkages.egg-info/top_level.txt +0 -0
  35. {rational-linkages-1.1.1 → rational-linkages-1.2.dev2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: rational-linkages
3
- Version: 1.1.1
3
+ Version: 1.2.dev2
4
4
  Summary: Rational Linkages Toolbox
5
5
  Author-email: Daniel Huczala <daniel.huczala@uibk.ac.at>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -690,8 +690,9 @@ License-File: LICENSE
690
690
  Requires-Dist: scipy>=1.7.0
691
691
  Requires-Dist: sympy>=1.8.0
692
692
  Requires-Dist: matplotlib>=3.4.0
693
- Requires-Dist: biquaternion-py>=1.1.0
693
+ Requires-Dist: biquaternion-py>=1.2.0
694
694
  Requires-Dist: PyQt5>=5.15.10
695
+ Requires-Dist: exudyn>=1.7.0
695
696
  Provides-Extra: doc
696
697
  Requires-Dist: sphinx; extra == "doc"
697
698
  Requires-Dist: sphinx-rtd-theme; extra == "doc"
@@ -706,8 +707,8 @@ Requires-Dist: twine; extra == "dev"
706
707
 
707
708
  [![build](https://git.uibk.ac.at/geometrie-vermessung/rational-linkages/badges/main/pipeline.svg)](https://git.uibk.ac.at/geometrie-vermessung/rational-linkages/-/jobs)
708
709
  [![coverage](https://git.uibk.ac.at/geometrie-vermessung/rational-linkages/badges/main/coverage.svg?job=run_tests)](https://git.uibk.ac.at/geometrie-vermessung/rational-linkages/-/jobs)
709
- [![Python](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12-blue.svg)]()
710
710
  [![Documentation Status](https://readthedocs.org/projects/rational-linkages/badge/?version=latest)](https://rational-linkages.readthedocs.io/?badge=latest)
711
+ [![Python](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12-blue.svg)]()
711
712
  [![PyPI version](https://badge.fury.io/py/rational-linkages.svg)](https://pypi.org/project/rational-linkages/)
712
713
 
713
714
  # Rational Linkages
@@ -718,8 +719,9 @@ documentation is hosted on Read the Docs, available here:
718
719
 
719
720
  ## Intallation instuctions
720
721
 
721
- Recommended Python version is **3.11** (3.10 or higher are supported), when it provides
722
- the smoothest plotting. It is also the version used for development.
722
+ Recommended Python version is **3.11**, when it provides the smoothest plotting
723
+ (but 3.10 or higher are supported). Python 3.11 is also the version used for
724
+ development.
723
725
 
724
726
  ### Install from PyPI
725
727
 
@@ -744,3 +746,13 @@ Using pip:
744
746
  ## Usage
745
747
 
746
748
  See the [documentation examples](https://rational-linkages.readthedocs.io/) for more details.
749
+
750
+
751
+ ## Acknowledgements
752
+
753
+ Funded by the European Union. Views and opinions expressed are however those of
754
+ the author(s) only and do not necessarily reflect those of the European Union
755
+ or the European Research Executive Agency (REA). Neither the European Union
756
+ nor the granting authority can be held responsible for them.
757
+
758
+ <img src="./docs/source/figures/eu.png" width="250" />
@@ -1,7 +1,7 @@
1
1
  [![build](https://git.uibk.ac.at/geometrie-vermessung/rational-linkages/badges/main/pipeline.svg)](https://git.uibk.ac.at/geometrie-vermessung/rational-linkages/-/jobs)
2
2
  [![coverage](https://git.uibk.ac.at/geometrie-vermessung/rational-linkages/badges/main/coverage.svg?job=run_tests)](https://git.uibk.ac.at/geometrie-vermessung/rational-linkages/-/jobs)
3
- [![Python](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12-blue.svg)]()
4
3
  [![Documentation Status](https://readthedocs.org/projects/rational-linkages/badge/?version=latest)](https://rational-linkages.readthedocs.io/?badge=latest)
4
+ [![Python](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12-blue.svg)]()
5
5
  [![PyPI version](https://badge.fury.io/py/rational-linkages.svg)](https://pypi.org/project/rational-linkages/)
6
6
 
7
7
  # Rational Linkages
@@ -12,8 +12,9 @@ documentation is hosted on Read the Docs, available here:
12
12
 
13
13
  ## Intallation instuctions
14
14
 
15
- Recommended Python version is **3.11** (3.10 or higher are supported), when it provides
16
- the smoothest plotting. It is also the version used for development.
15
+ Recommended Python version is **3.11**, when it provides the smoothest plotting
16
+ (but 3.10 or higher are supported). Python 3.11 is also the version used for
17
+ development.
17
18
 
18
19
  ### Install from PyPI
19
20
 
@@ -37,4 +38,14 @@ Using pip:
37
38
 
38
39
  ## Usage
39
40
 
40
- See the [documentation examples](https://rational-linkages.readthedocs.io/) for more details.
41
+ See the [documentation examples](https://rational-linkages.readthedocs.io/) for more details.
42
+
43
+
44
+ ## Acknowledgements
45
+
46
+ Funded by the European Union. Views and opinions expressed are however those of
47
+ the author(s) only and do not necessarily reflect those of the European Union
48
+ or the European Research Executive Agency (REA). Neither the European Union
49
+ nor the granting authority can be held responsible for them.
50
+
51
+ <img src="./docs/source/figures/eu.png" width="250" />
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "rational-linkages"
7
- version = "1.1.1"
7
+ version = "1.2.dev2"
8
8
  description = "Rational Linkages Toolbox"
9
9
  authors = [
10
10
  {name = "Daniel Huczala", email = "daniel.huczala@uibk.ac.at"},
@@ -22,8 +22,9 @@ dependencies = [
22
22
  "scipy >= 1.7.0",
23
23
  "sympy >= 1.8.0",
24
24
  "matplotlib >= 3.4.0",
25
- "biquaternion-py >= 1.1.0",
26
- "PyQt5 >= 5.15.10"
25
+ "biquaternion-py >= 1.2.0",
26
+ "PyQt5 >= 5.15.10",
27
+ "exudyn >= 1.7.0",
27
28
  ]
28
29
 
29
30
  [project.optional-dependencies]
@@ -1,7 +1,5 @@
1
- from math import isclose
2
1
  from typing import Optional, Sequence, Union
3
- from warnings import warn
4
-
2
+ from sympy import Expr
5
3
  import numpy as np
6
4
  from .Quaternion import Quaternion
7
5
 
@@ -26,24 +24,26 @@ class DualQuaternion:
26
24
  :ivar Quaternion d: dual quaternion - the dual part of the Dual Quaternion,
27
25
  representing translation. See also :class:`~rational_linkages.Quaternion`
28
26
  :ivar np.ndarray dq: 8-vector of study parameters, representing the Dual Quaternion
29
- :ivar bool is_rotation: True if the Dual Quaternion represents a rotation, False
30
27
 
31
28
  :examples:
32
29
 
33
- .. code-block:: python
34
- :caption: General usage
30
+ .. testcode::
31
+
32
+ # General usage
35
33
 
36
34
  from rational_linkages import DualQuaternion
37
35
  dq = DualQuaternion([1, 2, 3, 4, 0.1, 0.2, 0.3, 0.4])
38
36
 
39
- .. code-block:: python
40
- :caption: Identity DualQuaternion with no rotation, no translation
37
+ .. testcode::
38
+
39
+ # Identity dual quaternion with no rotation, no translation
41
40
 
42
41
  from rational_linkages import DualQuaternion
43
42
  dq = DualQuaternion()
44
43
 
45
- .. code-block:: python
46
- :caption: DualQuaternion from two Quaternions
44
+ .. testcode::
45
+
46
+ # Dual quaternion from two quaternions
47
47
 
48
48
  from rational_linkages import DualQuaternion
49
49
  from rational_linkages import Quaternion
@@ -52,8 +52,7 @@ class DualQuaternion:
52
52
  dq = DualQuaternion.from_two_quaternions(q1, q2)
53
53
  """
54
54
 
55
- def __init__(self, study_parameters: Optional[Sequence[float]] = None,
56
- is_rotation: bool = False):
55
+ def __init__(self, study_parameters: Optional[Sequence[float]] = None):
57
56
  """
58
57
  Dual Quaternion object, assembled from 8-vector (list or np.array) as DQ,
59
58
  or two 4-vectors (np.arrays) as two Quaternions (see @classmethod bellow).
@@ -62,7 +61,6 @@ class DualQuaternion:
62
61
  :param Optional[Sequence[float]] study_parameters: array or list
63
62
  of 8 Study's parameters. If None, an identity DualQuaternion is constructed.
64
63
  Defaults to None.
65
- :param bool is_rotation: True if the Dual Quaternion represents a rotation,
66
64
  """
67
65
  if study_parameters is not None:
68
66
  if len(study_parameters) != 8:
@@ -78,46 +76,12 @@ class DualQuaternion:
78
76
  self.d = Quaternion(dual)
79
77
  self.dq = self.array()
80
78
 
81
- self.is_rotation = is_rotation
82
-
83
79
  # check if all entries of the DQ are rational numbers
84
- from sympy import Rational
85
- if all(isinstance(x, Rational) for x in self.array()):
80
+ if all(isinstance(x, Expr) for x in self.array()):
86
81
  self.is_rational = True
87
82
  else:
88
83
  self.is_rational = False
89
84
 
90
- @property
91
- def type(self) -> str:
92
- """
93
- Test if the DualQuaternion is a special case representing line, plane, or point,
94
- and fulfills Study's condition
95
-
96
- :return: type of the DualQuaternion
97
- :rtype: str
98
- """
99
- # TODO: not working correctly
100
- if not isclose(np.dot(self.p.array(), self.d.array()), 0):
101
- warn("DualQuaternion: Study's condition is not fulfilled")
102
- return "affine"
103
- elif isclose(self.p.norm(), 0):
104
- warn("DualQuaternion: This DQ is in an exceptional qenerator!")
105
- return "paul"
106
- elif isclose(self.p[0], 0) and all(isclose(val, 0) for val in self.d[1:4]):
107
- return "plane"
108
- elif isclose(self.dq[0], 1) and all(isclose(val, 0) for val in self.dq[1:5]):
109
- return "point"
110
- elif (
111
- isclose(self.p[0], 0)
112
- and isclose(self.d[0], 0)
113
- and not isclose(self.d.norm(), 0)
114
- ):
115
- return "line"
116
- elif not isclose(self.p.norm(), 0) and isclose(self.d[0], 0):
117
- return "rotation"
118
- else:
119
- return "general"
120
-
121
85
  @classmethod
122
86
  def from_two_quaternions(
123
87
  cls, primal: Quaternion, dual: Quaternion
@@ -134,8 +98,95 @@ class DualQuaternion:
134
98
  return cls(np.concatenate((primal.array(), dual.array())))
135
99
 
136
100
  @classmethod
137
- def as_rational(cls, study_parameters: Union[list, np.ndarray] = None,
138
- is_rotation: bool = False):
101
+ def from_bq_biquaternion(cls, biquaternion):
102
+ """
103
+ Construct DualQuaternion from a biquaternion.
104
+
105
+ :param bq.BiQuaternion biquaternion: biquaternion
106
+
107
+ :return: DualQuaternion
108
+ :rtype: DualQuaternion
109
+
110
+ :raises ValueError: if the input is not a biquaternion_py.BiQuaternion object
111
+
112
+ :examples:
113
+
114
+ .. testcode::
115
+
116
+ # Construct dual quaternion from a BiQuaternion
117
+
118
+ from rational_linkages import DualQuaternion
119
+ from biquaternion_py import II, JJ, KK, EE
120
+ bq = 2*KK + EE * II
121
+ dq = DualQuaternion.from_bq_biquaternion(bq)
122
+
123
+ .. testcode::
124
+
125
+ # Construct dual quaternion from a BiQuaternion
126
+
127
+ from rational_linkages import DualQuaternion
128
+ from biquaternion_py import BiQuaternion
129
+ bq = BiQuaternion(1, 0, 0, 0, 0, 2, 3, 4)
130
+ dq = DualQuaternion.from_bq_biquaternion(bq)
131
+ """
132
+ from biquaternion_py import BiQuaternion
133
+
134
+ if not isinstance(biquaternion, BiQuaternion):
135
+ raise ValueError("The input has to be a biquaternion_py.BiQuaternion object"
136
+ "from biquaternion_py package.")
137
+
138
+ coeffs = biquaternion.coeffs
139
+ return cls(np.array(coeffs, dtype="float64"))
140
+
141
+ @classmethod
142
+ def from_bq_poly(cls, poly, indet):
143
+ """
144
+ Construct DualQuaternion from a biquaternion polynomial.
145
+
146
+ The biquaternion polynomial is given in the form (t - h), where t is the
147
+ indeterminant and h is a biquaternion. To obtain the DualQuaternion, the
148
+ coefficients of the polynomial are negated and then assembled into a numpy
149
+ array.
150
+
151
+ :param bq.Poly poly: biquaternion polynomial
152
+ :param sp.Symbol indet: indeterminant of the polynomial
153
+
154
+ :return: DualQuaternion
155
+ :rtype: DualQuaternion
156
+
157
+ :raises ValueError: if the input is not a biquaternion_py.Poly object
158
+ :raises ValueError: if the polynomial is not of degree 1
159
+
160
+ :examples:
161
+
162
+ .. testcode::
163
+
164
+ # Construct dual quaternion from a BiQuaternion polynomial
165
+
166
+ from rational_linkages import DualQuaternion
167
+ from biquaternion_py import Poly, II, JJ, KK, EE
168
+ from sympy import Symbol
169
+
170
+ t = Symbol('t')
171
+ h = 2*KK + EE * II
172
+ poly_bq = Poly(t - h, t)
173
+
174
+ # poly_bq must be of form (t - h), i.e. degree 1 otherwise ValueError is raised
175
+ dq = DualQuaternion.from_bq_poly(poly_bq, indet=t)
176
+ """
177
+ from biquaternion_py import Poly
178
+
179
+ if not isinstance(poly, Poly):
180
+ raise ValueError("The input has to be a biquaternion_py.Poly object from"
181
+ "biquaternion_py package.")
182
+ elif poly.deg(indet) != 1:
183
+ raise ValueError("The polynomial has to be of degree 1.")
184
+
185
+ poly_coeffs = [-x for x in poly.coeff(indet, 0).coeffs]
186
+ return cls(np.array(poly_coeffs, dtype="float64"))
187
+
188
+ @classmethod
189
+ def as_rational(cls, study_parameters: Union[list, np.ndarray] = None):
139
190
  """
140
191
  Assembly of DualQuaternion from Sympy's rational numbers
141
192
 
@@ -153,7 +204,7 @@ class DualQuaternion:
153
204
  rational_numbers = [Rational(1), Rational(0), Rational(0), Rational(0),
154
205
  Rational(0), Rational(0), Rational(0), Rational(0)]
155
206
 
156
- return cls(rational_numbers, is_rotation)
207
+ return cls(rational_numbers)
157
208
 
158
209
  def __repr__(self):
159
210
  """
@@ -354,22 +405,37 @@ class DualQuaternion:
354
405
  """
355
406
  Dual Quaternion directly to line coordinates
356
407
 
408
+ If the DQ is a sympy Expression, it is not converted to float and do not
409
+ normalized
410
+
357
411
  :return: tuple of 2 numpy arrays, 3-vector coordinates each
358
412
  :rtype: tuple
359
413
  """
360
- direction = self.dq[1:4]
361
- moment = self.dq[5:8]
414
+ # if the DQ is a sympy Expression, do not convert to float and do not normalize
415
+ if any(isinstance(x, Expr) for x in self.array()):
416
+ try:
417
+ dq = np.asarray(self.array(), dtype="float64")
418
+ except Exception:
419
+ dq = self.array()
420
+ else:
421
+ dq = np.asarray(self.array(), dtype="float64")
362
422
 
363
- direction = np.asarray(direction, dtype="float64")
364
- moment = np.asarray(moment, dtype="float64")
423
+ k = dq[0] ** 2 - dq[1] ** 2 - dq[2] ** 2 - dq[3] ** 2 # Different from Study
424
+ f = k - dq[0] ** 2
425
+ g = dq[0] * dq[4]
365
426
 
366
- moment = moment / np.linalg.norm(direction)
367
- direction = direction / np.linalg.norm(direction)
427
+ dir = f * dq[1:4]
428
+ mom = np.array([g * dq[1] - f * dq[5],
429
+ g * dq[2] - f * dq[6],
430
+ g * dq[3] - f * dq[7]])
368
431
 
369
- # if DualQuaternion is representing a rotation, the moment is negative to
370
- # become a line
371
- # TODO: check if it holds also if not a rotation
372
- moment = -1 * moment if self.is_rotation else moment
432
+ # if the DQ is a sympy Expression, do not convert to float and do not normalize
433
+ if any(isinstance(x, Expr) for x in dir) or any(isinstance(x, Expr) for x in mom):
434
+ moment = -1 * mom
435
+ direction = -1 * dir
436
+ else:
437
+ moment = -1 * mom / np.linalg.norm(dir)
438
+ direction = -1 * dir / np.linalg.norm(dir)
373
439
 
374
440
  return direction, moment
375
441
 
@@ -412,13 +478,16 @@ class DualQuaternion:
412
478
 
413
479
  :examples:
414
480
 
415
- .. code-block:: python
416
- :caption: Act on a line with a Dual Quaternion
481
+ .. testcode::
482
+
483
+ # Act on a line with a dual quaternion
484
+
485
+ from rational_linkages import DualQuaternion, NormalizedLine
486
+
417
487
 
418
- from rational_linkages import DualQuaternion
419
- from rational_linkages import NormalizedLine
420
488
  dq = DualQuaternion([1, 0, 0, 1, 0, 3, 2, -1])
421
489
  line = NormalizedLine.from_direction_and_point([0, 0, 1], [0, -2, 0])
490
+
422
491
  line_after_half_turn = dq.act(line)
423
492
  """
424
493
  from .DualQuaternionAction import DualQuaternionAction
@@ -30,13 +30,15 @@ class DualQuaternionAction:
30
30
 
31
31
  :example:
32
32
 
33
- .. code-block:: python
34
- :caption: Act on line with a Dual Quaternion
33
+ .. testcode::
34
+
35
+ # Act on line with a Dual Quaternion
36
+
37
+ from rational_linkages import DualQuaternion, NormalizedLine
35
38
 
36
- from rational_linkages import DualQuaternion
37
- from rational_linkages import NormalizedLine
38
39
  dq = DualQuaternion([1, 2, 3, 4, 0.1, 0.2, 0.3, 0.4])
39
40
  line = NormalizedLine.from_direction_and_point([0, 0, 1], [0, -2, 0])
41
+
40
42
  line_after_half_turn = dq.act(line)
41
43
 
42
44
  """
@@ -0,0 +1,123 @@
1
+ from rational_linkages import RationalMechanism
2
+ import numpy as np
3
+
4
+
5
+ class ExudynAnalysis:
6
+ """
7
+ Class for dynamics analysis using Exudyn package.
8
+ """
9
+ def __init__(self, gravity: np.ndarray = np.array([0, 0, -9.81])):
10
+ """
11
+ Initialize ExudynAnalysis object.
12
+
13
+ :param list gravity: XYZ gravity vector
14
+ """
15
+ self.gravity = gravity
16
+
17
+ def get_exudyn_params(self, mechanism: RationalMechanism):
18
+ """
19
+ Get parameters for Exudyn simulation.
20
+
21
+ This method is used to get parameters for Exudyn -
22
+ """
23
+ # get positions of links connection points
24
+ links_pts = self._links_points(mechanism)
25
+
26
+ # get joint axes
27
+ joint_axes = self._joints_axes(mechanism)
28
+
29
+ # get links lengths
30
+ links_lengths = self._links_lengths(links_pts)
31
+
32
+ # get links center of gravity positions
33
+ links_masses_pts = self._links_center_of_gravity(links_pts)
34
+
35
+ # body dimensions
36
+ body_dim = [[l, 0.06, 0.06] for l in links_lengths] # TODO width
37
+
38
+ # relative link points
39
+ relative_links_pts = self._relative_links_points(links_pts, links_masses_pts)
40
+
41
+ return (links_pts, links_lengths, body_dim, links_masses_pts,
42
+ joint_axes, relative_links_pts)
43
+
44
+ @staticmethod
45
+ def _links_points(mechanism: RationalMechanism) -> list:
46
+ """
47
+ Get links connection points in default configuration.
48
+
49
+ :param mechanism: RationalMechanism object
50
+
51
+ :return: list of points on links
52
+ :rtype: list
53
+ """
54
+ # 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])
58
+
59
+ # rearamge points, so the base link has the first 2 points
60
+ points = points[-1:] + points[:-1]
61
+
62
+ return list(zip(points[::2], points[1::2]))
63
+
64
+ @staticmethod
65
+ def _relative_links_points(links_points: list, centers_of_gravity: list) -> list:
66
+ """
67
+ Get links connection points in default configuration, relative to its center of gravity.
68
+
69
+ :param list links_points: list of point pairs tuples
70
+ :param list centers_of_gravity: list of links' center of gravity positions
71
+
72
+ :return: list of points on links
73
+ :rtype: list
74
+ """
75
+ return [(pts[0] - cog, pts[1] - cog)
76
+ for pts, cog in zip(links_points, centers_of_gravity)]
77
+
78
+ @staticmethod
79
+ def _links_lengths(links_points: list) -> list:
80
+ """
81
+ Get links lengths.
82
+
83
+ :param list links_points: list of point pairs tuples
84
+
85
+ :return: list of links lengths
86
+ :rtype: list
87
+ """
88
+ return [np.linalg.norm(pts[1] - pts[0]) for pts in links_points]
89
+
90
+ @staticmethod
91
+ def _links_center_of_gravity(links_points: list) -> list:
92
+ """
93
+ Get positions of links' center of gravity.
94
+
95
+ :param list links_points: list of point pairs tuples
96
+
97
+ :return: list of links' center of gravity positions
98
+ :rtype: list
99
+ """
100
+ return [(pts[0] + pts[1]) / 2 for pts in links_points]
101
+
102
+ @staticmethod
103
+ def _joints_axes(mechanism: RationalMechanism) -> list:
104
+ """
105
+ Get joints unit axes.
106
+
107
+ :param RationalMechanism mechanism: RationalMechanism object
108
+
109
+ :return: list of joints axes
110
+ :rtype: list
111
+ """
112
+ axes = []
113
+ for axis in mechanism.factorizations[0].dq_axes:
114
+ direction, moment = axis.dq2line()
115
+ axes.append(direction)
116
+
117
+ axes_branch2 = []
118
+ for axis in mechanism.factorizations[1].dq_axes:
119
+ direction, moment = axis.dq2line()
120
+ axes_branch2.append(direction)
121
+
122
+ return axes + axes_branch2[::-1]
123
+
@@ -107,7 +107,6 @@ class FactorizationProvider:
107
107
  norm_poly = poly.norm()
108
108
  norm_poly = bq.Poly(norm_poly.poly.scal, *norm_poly.indets)
109
109
 
110
- print("")
111
110
  print('Factorization is running...')
112
111
 
113
112
  # Calculate the irreducible factors, that determine the different factorizations
@@ -148,11 +147,11 @@ class FactorizationProvider:
148
147
  axis_h = t_dq - factor_dq
149
148
 
150
149
  # TODO: implement return of rational axis
151
- rational_dq = RationalDualQuaternion(axis_h.array(), is_rotation=True)
150
+ rational_dq = RationalDualQuaternion(axis_h.array())
152
151
 
153
152
  # convert to numpy array as float64
154
153
  axis_h = np.asarray(axis_h.array(), dtype='float64')
155
- return DualQuaternion(axis_h, is_rotation=True)
154
+ return DualQuaternion(axis_h)
156
155
 
157
156
 
158
157
 
@@ -30,7 +30,7 @@ class Linkage:
30
30
  :param PointHomogeneous connection_points: The default connection point (
31
31
  common perpendicular)
32
32
  """
33
- self.normalized_axis = NormalizedLine.from_direction_and_moment(*axis.dq2line())
33
+ self.normalized_axis = NormalizedLine(axis.dq2screw())
34
34
 
35
35
  if len(connection_points) == 1:
36
36
  self.default_connection_point = [connection_points[0], connection_points[0]]
@@ -29,16 +29,17 @@ class MotionFactorization(RationalCurve):
29
29
 
30
30
  :example:
31
31
 
32
- .. code-block:: python
33
- :caption: Motion factorization of a 2R mechanism
32
+ .. testcode::
33
+
34
+ # Motion factorization of a 2R mechanism
34
35
 
35
36
  from rational_linkages import DualQuaternion
36
37
  from rational_linkages import MotionFactorization
37
38
 
38
39
 
39
40
  f1 = MotionFactorization(
40
- [DualQuaternion([0, 0, 0, 1, 0, 0, 0, 0], is_rotation=True),
41
- DualQuaternion([0, 0, 0, 2, 0, 0, -1, 0], is_rotation=True)])
41
+ [DualQuaternion([0, 0, 0, 1, 0, 0, 0, 0]),
42
+ DualQuaternion([0, 0, 0, 2, 0, 0, -1, 0])])
42
43
 
43
44
  .. [#frischauf2022] Frischauf, Johanna et al. (2022). A multi-Bennett 8R mechanism obtained from
44
45
  factorization of bivariate motion polynomials. *Mechanisms and Machine Theory*.
@@ -167,9 +168,8 @@ class MotionFactorization(RationalCurve):
167
168
  for i in range(len(linkage_points))]
168
169
  return linkage_points_3d
169
170
 
170
- def direct_kinematics_of_tool(
171
- self, t_numerical: float, end_effector: np.ndarray, inverted_part=False
172
- ) -> np.ndarray:
171
+ def direct_kinematics_of_tool(self, t_numerical: float, end_effector: np.ndarray,
172
+ inverted_part=False) -> np.ndarray:
173
173
  """
174
174
  Direct kinematics of the end effector position
175
175
 
@@ -181,7 +181,7 @@ class MotionFactorization(RationalCurve):
181
181
  :return: list of np.array - point of the tool position
182
182
  :rtype: np.ndarray
183
183
  """
184
- ee_point = PointHomogeneous(end_effector)
184
+ ee_point = PointHomogeneous.from_3d_point(end_effector)
185
185
 
186
186
  if inverted_part:
187
187
  point_after_action = self.act(
@@ -11,10 +11,14 @@ class MotionInterpolation:
11
11
  """
12
12
  Method for interpolation of poses by rational motion curve in SE(3).
13
13
 
14
+ There are two methods for interpolation of poses by rational motion curve, please
15
+ see the following examples for more details.
16
+
14
17
  :examples:
15
18
 
16
- .. code-block:: python
17
- :caption: 4-pose interpolation
19
+ .. testcode::
20
+
21
+ # 4-pose interpolation
18
22
 
19
23
  from rational_linkages import (DualQuaternion, Plotter, FactorizationProvider,
20
24
  MotionInterpolation, RationalMechanism)
@@ -48,24 +52,25 @@ class MotionInterpolation:
48
52
  # show the plot
49
53
  myplt.show()
50
54
 
51
- .. code-block:: python
52
- :caption: 3-pose interpolation
55
+ .. testcode::
56
+
57
+ # 3-pose interpolation
53
58
 
54
59
  from rational_linkages import DualQuaternion, Plotter, MotionInterpolation
55
60
 
56
61
 
57
- if __name__ == "__main__":
58
- p0 = DualQuaternion([0, 17, -33, -89, 0, -6, 5, -3])
59
- p1 = DualQuaternion([0, 84, -21, -287, 0, -30, 3, -9])
60
- p2 = DualQuaternion([0, 10, 37, -84, 0, -3, -6, -3])
62
+ if __name__ == "__main__":
63
+ p0 = DualQuaternion([0, 17, -33, -89, 0, -6, 5, -3])
64
+ p1 = DualQuaternion([0, 84, -21, -287, 0, -30, 3, -9])
65
+ p2 = DualQuaternion([0, 10, 37, -84, 0, -3, -6, -3])
61
66
 
62
- c = MotionInterpolation.interpolate([p0, p1, p2])
67
+ c = MotionInterpolation.interpolate([p0, p1, p2])
63
68
 
64
- plt = Plotter(interactive=False, steps=500, arrows_length=0.05)
65
- plt.plot(c, interval='closed')
69
+ plt = Plotter(interactive=False, steps=500, arrows_length=0.05)
70
+ plt.plot(c, interval='closed')
66
71
 
67
- for i, pose in enumerate([p0, p1, p2]):
68
- plt.plot(pose, label='p{}'.format(i+1))
72
+ for i, pose in enumerate([p0, p1, p2]):
73
+ plt.plot(pose, label='p{}'.format(i+1))
69
74
  """
70
75
  def __init__(self):
71
76
  """