Skip to content

Commit 9cc0ee9

Browse files
committed
up
1 parent 77f1fd5 commit 9cc0ee9

10 files changed

Lines changed: 89 additions & 190 deletions

File tree

mdh/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
try:
2+
# 3.8
23
from importlib.metadata import version # type: ignore
34
except ImportError:
5+
# <= 3.7
46
from importlib_metadata import version # type: ignore
57

68
# will this work?

mdh/arm.py

Whitespace-only changes.

mdh/kinematic_chain.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ class KinematicChain(Sized, Iterable):
2020
_links = attr.ib(type=Sequence[Any])
2121

2222
def __len__(self):
23+
"""Enables the length function, returns number links"""
2324
return len(self._links)
2425

2526
def __iter__(self):
27+
"""Enables iteration of joints: for j in chain: print(j)"""
2628
for l in self._links:
2729
yield l
2830

29-
def transform(self, joints: Sequence[float]):
31+
def transform(self, joints):
3032
"""Calculates the transformation and returns a 4x4 matrix"""
3133
if len(joints) != len(self._links):
3234
raise Exception("inputs don't equal number of links")
@@ -39,7 +41,7 @@ def transform(self, joints: Sequence[float]):
3941
# t = np.dot(m, t)
4042
return t
4143

42-
def forward(self, joints: Sequence[float]):
44+
def forward(self, joints):
4345
"""value?
4446
Solve the forward kinematics and returns a 4x4 matrix
4547
"""

mdh/leg.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

mdh/link.py

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66
JointType = IntFlag('JointType', 'revolute prismatic revolute_theda revolute_alpha')
77
mdh_params = namedtuple("mdh_params", "alpha a theta d type")
88

9-
@attr.s
10-
class Link:
11-
"""
12-
why? what is the value of this?
13-
prismatic/revolute have parameters that never chance ... need to freeze them!
14-
"""
15-
# alpha = attr.ib(type=float)
16-
# a = attr.ib(type=float)
17-
# theta = attr.ib(type=float)
18-
# d = attr.ib(type=float)
9+
# @attr.s
10+
# class Link:
11+
# """
12+
# why? what is the value of this?
13+
# prismatic/revolute have parameters that never chance ... need to freeze them!
14+
# """
15+
# # alpha = attr.ib(type=float)
16+
# # a = attr.ib(type=float)
17+
# # theta = attr.ib(type=float)
18+
# # d = attr.ib(type=float)
1919

20-
@attr.s
21-
class RevoluteLink(Link):
20+
@attr.s(slots=True)
21+
class RevoluteLink:
2222
"""
2323
RevoluteLink about theta. All other parameters (alpha, a, d) are fixed and
2424
cannot be changed once the link is created.
@@ -27,6 +27,8 @@ class RevoluteLink(Link):
2727
_a = attr.ib(type=float)
2828
theta = attr.ib(type=float)
2929
_d = attr.ib(type=float)
30+
min = attr.ib(-np.pi, type=float)
31+
max = attr.ib(np.pi, type=float)
3032

3133
@property
3234
def alpha(self) -> float:
@@ -40,9 +42,9 @@ def a(self) -> float:
4042
def d(self) -> float:
4143
return self._d
4244

43-
# max/min limits of link for optimzation
44-
min = attr.ib(-np.pi, type=float)
45-
max = attr.ib(np.pi, type=float)
45+
@property
46+
def type(self):
47+
return JointType.revolute
4648

4749
"""Some of these params are immutable, how do I do that?"""
4850
def transform(self, angle: float):
@@ -69,7 +71,11 @@ def transform(self, angle: float):
6971

7072
return transform
7173

72-
@attr.s
73-
class Prismatic(Link):
74-
min = attr.ib(type=float)
75-
max = attr.ib(type=float)
74+
# @attr.s
75+
# class Prismatic:
76+
# min = attr.ib(type=float)
77+
# max = attr.ib(type=float)
78+
#
79+
# @property
80+
# def type(self):
81+
# return JointType.revolute

poetry.lock

Lines changed: 48 additions & 139 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ classifiers = [
1616
'Operating System :: OS Independent',
1717
'Programming Language :: Python :: 3.6',
1818
'Programming Language :: Python :: 3.7',
19+
'Programming Language :: Python :: 3.8',
1920
'Topic :: Software Development :: Libraries',
2021
'Topic :: Software Development :: Libraries :: Python Modules',
2122
'Topic :: Software Development :: Libraries :: Application Frameworks'
@@ -28,11 +29,12 @@ classifiers = [
2829
python = ">=3.6"
2930
numpy = ">=1.9"
3031
scipy = ">=1.0"
31-
attrs = ">=19.0"
32+
importlib-metadata = {version="*", python="<3.8"}
33+
# attrs = ">=19.0"
3234

3335
[tool.poetry.dev-dependencies]
3436
pytest = "^5.2"
35-
mypy = "*"
37+
# mypy = "*"
3638

3739
[build-system]
3840
requires = ["poetry>=0.12"]

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ You should probably use one of these, they inspired me to write a simpler
2323
module for my needs:
2424

2525
- [pybotics](https://github.com/nnadeau/pybotics)
26-
- [pytransform3d](https://github.com/rock-learning/pytransform3d)
27-
- [robopy](https://github.com/MultipedRobotics/robopy)
26+
- [pytransform3d](https://github.com/rock-learning/pytransform3d), some matplotlib 3d examples
27+
- [robopy](https://github.com/adityadua24/robopy), has some good matplotlib 3d examples, but seems rather brittle and difficult to work with
2828
- [tinyik](https://github.com/lanius/tinyik), uses `open3d` to visualize the mechanism
2929

3030
## Example

tests/__init__.py

Whitespace-only changes.

tests/test_mdh.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import pytest
2+
import mdh
3+
from mdh.models import puma500
24

3-
def test_dummy():
4-
assert True
5+
# def test_dummy():
6+
# assert True
57

68
# @pytest.mark.xfail
79
# def test_dummy_2():

0 commit comments

Comments
 (0)