Skip to content

Commit bbd68f2

Browse files
committed
Fix str test
1 parent 118f552 commit bbd68f2

File tree

2 files changed

+113
-109
lines changed

2 files changed

+113
-109
lines changed

roboticstoolbox/robot/DHLink.py

Lines changed: 100 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
_eps = np.finfo(np.float64).eps
1313

1414
from functools import wraps
15+
16+
1517
def _check_rne(func):
1618
"""
1719
@_check_rne decorator
@@ -30,15 +32,18 @@ def dyn_param_setter(self, value):
3032
3133
:seealso: :func:`Link._listen_dyn`
3234
"""
35+
3336
@wraps(func)
3437
def wrapper_check_rne(*args, **kwargs):
3538
if args[0]._rne_ob is None or args[0]._dynchanged:
3639
args[0].delete_rne()
3740
args[0]._init_rne()
3841
args[0]._rne_changed = False
3942
return func(*args, **kwargs)
43+
4044
return wrapper_check_rne
4145

46+
4247
# --------------------------------------------------------------#
4348

4449
try: # pragma: no cover
@@ -47,7 +52,10 @@ def wrapper_check_rne(*args, **kwargs):
4752

4853
def _issymbol(x):
4954
return isinstance(x, sym.Expr)
55+
56+
5057
except ImportError:
58+
5159
def _issymbol(x): # pylint: disable=unused-argument
5260
return False
5361

@@ -65,6 +73,7 @@ def _sin(theta):
6573
else:
6674
return np.sin(theta)
6775

76+
6877
# --------------------------------------------------------------#
6978

7079

@@ -116,15 +125,8 @@ class DHLink(Link):
116125
"""
117126

118127
def __init__(
119-
self,
120-
d=0.0,
121-
alpha=0.0,
122-
theta=0.0,
123-
a=0.0,
124-
sigma=0,
125-
mdh=False,
126-
offset=0,
127-
**kwargs):
128+
self, d=0.0, alpha=0.0, theta=0.0, a=0.0, sigma=0, mdh=False, offset=0, **kwargs
129+
):
128130

129131
# TODO
130132
# probably should make DHLink(link) return a copy
@@ -166,7 +168,8 @@ def __add__(self, L):
166168
manufacturer=L.manufacturer,
167169
base=L.base,
168170
tool=L.tool,
169-
gravity=L.gravity)
171+
gravity=L.gravity,
172+
)
170173

171174
else:
172175
raise TypeError("Cannot add a Link with a non Link object")
@@ -183,12 +186,16 @@ def __str__(self):
183186
qvar = f"q{self.id}"
184187
cls = self.__class__.__name__
185188
if self.isrevolute:
186-
s = f"{cls}: θ={qvar}{offset}, d={self.d}, " \
187-
f"a={self.a}, ⍺={self.alpha}"
189+
s = (
190+
f"{cls}: θ={qvar}{offset}, d={self.d}, "
191+
f" a={self.a}, ⍺={self.alpha}"
192+
)
188193
elif self.isprismatic:
189-
s = f"{cls}: theta={self.theta}, d={qvar}{offset}, " \
190-
f" a={self.a}, " \
194+
s = (
195+
f"{cls}: θ={self.theta}, d={qvar}{offset}, "
196+
f" a={self.a}, "
191197
f"⍺={self.alpha}"
198+
)
192199
return s
193200

194201
def __repr__(self):
@@ -203,7 +210,7 @@ def __repr__(self):
203210
args.extend(super()._params())
204211
return name + "(" + ", ".join(args) + ")"
205212

206-
# -------------------------------------------------------------------------- #
213+
# -------------------------------------------------------------------------- #
207214

208215
@property
209216
def theta(self):
@@ -226,7 +233,7 @@ def theta(self, theta_new):
226233
else:
227234
self._theta = theta_new
228235

229-
# -------------------------------------------------------------------------- #
236+
# -------------------------------------------------------------------------- #
230237

231238
@property
232239
def d(self):
@@ -249,7 +256,7 @@ def d(self, d_new):
249256
else:
250257
self._d = d_new
251258

252-
# -------------------------------------------------------------------------- #
259+
# -------------------------------------------------------------------------- #
253260

254261
@property
255262
def a(self):
@@ -268,7 +275,8 @@ def a(self):
268275
@_listen_dyn
269276
def a(self, a_new):
270277
self._a = a_new
271-
# -------------------------------------------------------------------------- #
278+
279+
# -------------------------------------------------------------------------- #
272280

273281
@property
274282
def alpha(self):
@@ -288,7 +296,7 @@ def alpha(self):
288296
def alpha(self, alpha_new):
289297
self._alpha = alpha_new
290298

291-
# -------------------------------------------------------------------------- #
299+
# -------------------------------------------------------------------------- #
292300

293301
@property
294302
def sigma(self):
@@ -310,7 +318,8 @@ def sigma(self):
310318
@_listen_dyn
311319
def sigma(self, sigma_new):
312320
self._sigma = sigma_new
313-
# -------------------------------------------------------------------------- #
321+
322+
# -------------------------------------------------------------------------- #
314323

315324
@property
316325
def mdh(self):
@@ -333,7 +342,7 @@ def mdh(self):
333342
def mdh(self, mdh_new):
334343
self._mdh = int(mdh_new)
335344

336-
# -------------------------------------------------------------------------- #
345+
# -------------------------------------------------------------------------- #
337346

338347
@property
339348
def offset(self):
@@ -358,7 +367,7 @@ def offset(self):
358367
def offset(self, offset_new):
359368
self._offset = offset_new
360369

361-
# -------------------------------------------------------------------------- #
370+
# -------------------------------------------------------------------------- #
362371

363372
def A(self, q):
364373
r"""
@@ -422,20 +431,24 @@ def A(self, q):
422431

423432
if self.mdh == 0:
424433
# standard DH
425-
T = np.array([
426-
[ct, -st * ca, st * sa, self.a * ct],
427-
[st, ct * ca, -ct * sa, self.a * st],
428-
[0, sa, ca, d],
429-
[0, 0, 0, 1]
430-
])
434+
T = np.array(
435+
[
436+
[ct, -st * ca, st * sa, self.a * ct],
437+
[st, ct * ca, -ct * sa, self.a * st],
438+
[0, sa, ca, d],
439+
[0, 0, 0, 1],
440+
]
441+
)
431442
else:
432443
# modified DH
433-
T = np.array([
434-
[ct, -st, 0, self.a],
435-
[st * ca, ct * ca, -sa, -sa * d],
436-
[st * sa, ct * sa, ca, ca * d],
437-
[0, 0, 0, 1]
438-
])
444+
T = np.array(
445+
[
446+
[ct, -st, 0, self.a],
447+
[st * ca, ct * ca, -sa, -sa * d],
448+
[st * sa, ct * sa, ca, ca * d],
449+
[0, 0, 0, 1],
450+
]
451+
)
439452

440453
return SE3(T, check=False)
441454

@@ -523,6 +536,7 @@ def ets(self):
523536

524537
# -------------------------------------------------------------------------- #
525538

539+
526540
class RevoluteDH(DHLink):
527541
r"""
528542
Class for revolute links using standard DH convention
@@ -573,23 +587,25 @@ class RevoluteDH(DHLink):
573587
""" # noqa
574588

575589
def __init__(
576-
self,
577-
d=0.0,
578-
a=0.0,
579-
alpha=0.0,
580-
offset=0.0,
581-
qlim=None,
582-
flip=False,
583-
**kwargs
584-
):
590+
self, d=0.0, a=0.0, alpha=0.0, offset=0.0, qlim=None, flip=False, **kwargs
591+
):
585592

586593
theta = 0.0
587594
sigma = 0
588595
mdh = False
589596

590597
super().__init__(
591-
d=d, alpha=alpha, theta=theta, a=a, sigma=sigma, mdh=mdh,
592-
offset=offset, qlim=qlim, flip=flip, **kwargs)
598+
d=d,
599+
alpha=alpha,
600+
theta=theta,
601+
a=a,
602+
sigma=sigma,
603+
mdh=mdh,
604+
offset=offset,
605+
qlim=qlim,
606+
flip=flip,
607+
**kwargs,
608+
)
593609

594610

595611
class PrismaticDH(DHLink):
@@ -644,23 +660,25 @@ class PrismaticDH(DHLink):
644660
""" # noqa
645661

646662
def __init__(
647-
self,
648-
theta=0.0,
649-
a=0.0,
650-
alpha=0.0,
651-
offset=0.0,
652-
qlim=None,
653-
flip=False,
654-
**kwargs
655-
):
663+
self, theta=0.0, a=0.0, alpha=0.0, offset=0.0, qlim=None, flip=False, **kwargs
664+
):
656665

657666
d = 0.0
658667
sigma = 1
659668
mdh = False
660669

661670
super().__init__(
662-
theta=theta, d=d, a=a, alpha=alpha, sigma=sigma, mdh=mdh,
663-
offset=offset, qlim=qlim, flip=flip, **kwargs)
671+
theta=theta,
672+
d=d,
673+
a=a,
674+
alpha=alpha,
675+
sigma=sigma,
676+
mdh=mdh,
677+
offset=offset,
678+
qlim=qlim,
679+
flip=flip,
680+
**kwargs,
681+
)
664682

665683

666684
class RevoluteMDH(DHLink):
@@ -713,23 +731,25 @@ class RevoluteMDH(DHLink):
713731
""" # noqa
714732

715733
def __init__(
716-
self,
717-
d=0.0,
718-
a=0.0,
719-
alpha=0.0,
720-
offset=0.0,
721-
qlim=None,
722-
flip=False,
723-
**kwargs
724-
):
734+
self, d=0.0, a=0.0, alpha=0.0, offset=0.0, qlim=None, flip=False, **kwargs
735+
):
725736

726737
theta = 0.0
727738
sigma = 0
728739
mdh = True
729740

730741
super().__init__(
731-
d=d, alpha=alpha, theta=theta, a=a, sigma=sigma, mdh=mdh,
732-
offset=offset, qlim=qlim, flip=flip, **kwargs)
742+
d=d,
743+
alpha=alpha,
744+
theta=theta,
745+
a=a,
746+
sigma=sigma,
747+
mdh=mdh,
748+
offset=offset,
749+
qlim=qlim,
750+
flip=flip,
751+
**kwargs,
752+
)
733753

734754

735755
class PrismaticMDH(DHLink):
@@ -784,20 +804,22 @@ class PrismaticMDH(DHLink):
784804
""" # noqa
785805

786806
def __init__(
787-
self,
788-
theta=0.0,
789-
a=0.0,
790-
alpha=0.0,
791-
offset=0.0,
792-
qlim=None,
793-
flip=False,
794-
**kwargs
795-
):
807+
self, theta=0.0, a=0.0, alpha=0.0, offset=0.0, qlim=None, flip=False, **kwargs
808+
):
796809

797810
d = 0.0
798811
sigma = 1
799812
mdh = True
800813

801814
super().__init__(
802-
theta=theta, d=d, a=a, alpha=alpha, sigma=sigma, mdh=mdh,
803-
offset=offset, qlim=qlim, flip=flip, **kwargs)
815+
theta=theta,
816+
d=d,
817+
a=a,
818+
alpha=alpha,
819+
sigma=sigma,
820+
mdh=mdh,
821+
offset=offset,
822+
qlim=qlim,
823+
flip=flip,
824+
**kwargs,
825+
)

0 commit comments

Comments
 (0)