Skip to content

Commit cd93075

Browse files
committed
Fix types
1 parent 4e40dfd commit cd93075

File tree

1 file changed

+39
-15
lines changed

1 file changed

+39
-15
lines changed

roboticstoolbox/robot/Robot.py

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -704,8 +704,10 @@ def manipulability(
704704
J: None = None,
705705
end: Union[str, Link, Gripper, None] = None,
706706
start: Union[str, Link, Gripper, None] = None,
707-
method: L["yoshikawa", "asada", "minsingular", "invcondition"] = "yoshikawa",
708-
axes: Union[L["all", "trans", "rot"], List[bool]] = "all",
707+
method: L[
708+
"yoshikawa", "asada", "minsingular", "invcondition" # noqa
709+
] = "yoshikawa",
710+
axes: Union[L["all", "trans", "rot"], List[bool]] = "all", # noqa
709711
**kwargs,
710712
) -> Union[float, NDArray]: # pragma nocover
711713
...
@@ -717,8 +719,10 @@ def manipulability(
717719
J: NDArray = ...,
718720
end: Union[str, Link, Gripper, None] = None,
719721
start: Union[str, Link, Gripper, None] = None,
720-
method: L["yoshikawa", "asada", "minsingular", "invcondition"] = "yoshikawa",
721-
axes: Union[L["all", "trans", "rot"], List[bool]] = "all",
722+
method: L[
723+
"yoshikawa", "asada", "minsingular", "invcondition" # noqa
724+
] = "yoshikawa",
725+
axes: Union[L["all", "trans", "rot"], List[bool]] = "all", # noqa
722726
**kwargs,
723727
) -> Union[float, NDArray]: # pragma nocover
724728
...
@@ -729,8 +733,10 @@ def manipulability(
729733
J=None,
730734
end: Union[str, Link, Gripper, None] = None,
731735
start: Union[str, Link, Gripper, None] = None,
732-
method: L["yoshikawa", "asada", "minsingular", "invcondition"] = "yoshikawa",
733-
axes: Union[L["all", "trans", "rot"], List[bool]] = "all",
736+
method: L[
737+
"yoshikawa", "asada", "minsingular", "invcondition" # noqa
738+
] = "yoshikawa",
739+
axes: Union[L["all", "trans", "rot"], List[bool]] = "all", # noqa
734740
**kwargs,
735741
):
736742
"""
@@ -893,6 +899,10 @@ def asada(robot, J, q, axes_list):
893899

894900
# Otherwise use the q vector/matrix
895901
else:
902+
if q is None:
903+
raise ValueError("Either J or q must be supplied")
904+
905+
q = getmatrix(q, (None, self.n))
896906
q = np.array(getmatrix(q, (None, self.n)))
897907
w = np.zeros(q.shape[0])
898908

@@ -957,7 +967,9 @@ def jacob0_dot(
957967
q: ArrayLike,
958968
qd: ArrayLike,
959969
J0: None = None,
960-
representation: Union[L["rpy/xyz", "rpy/zyx", "eul", "exp"], None] = None,
970+
representation: Union[
971+
L["rpy/xyz", "rpy/zyx", "eul", "exp"], None # noqa
972+
] = None,
961973
) -> NDArray: # pragma no cover
962974
...
963975

@@ -967,7 +979,9 @@ def jacob0_dot(
967979
q: None,
968980
qd: ArrayLike,
969981
J0: NDArray = ...,
970-
representation: Union[L["rpy/xyz", "rpy/zyx", "eul", "exp"], None] = None,
982+
representation: Union[
983+
L["rpy/xyz", "rpy/zyx", "eul", "exp"], None # noqa
984+
] = None,
971985
) -> NDArray: # pragma no cover
972986
...
973987

@@ -976,7 +990,9 @@ def jacob0_dot(
976990
q,
977991
qd: ArrayLike,
978992
J0=None,
979-
representation: Union[L["rpy/xyz", "rpy/zyx", "eul", "exp"], None] = None,
993+
representation: Union[
994+
L["rpy/xyz", "rpy/zyx", "eul", "exp"], None # noqa
995+
] = None,
980996
):
981997
r"""
982998
Derivative of Jacobian
@@ -1083,7 +1099,7 @@ def jacobm(
10831099
H: None = None,
10841100
end: Union[str, Link, Gripper, None] = None,
10851101
start: Union[str, Link, Gripper, None] = None,
1086-
axes: Union[L["all", "trans", "rot"], List[bool]] = "all",
1102+
axes: Union[L["all", "trans", "rot"], List[bool]] = "all", # noqa
10871103
) -> NDArray: # pragma no cover
10881104
...
10891105

@@ -1095,7 +1111,7 @@ def jacobm(
10951111
H: NDArray = ...,
10961112
end: Union[str, Link, Gripper, None] = None,
10971113
start: Union[str, Link, Gripper, None] = None,
1098-
axes: Union[L["all", "trans", "rot"], List[bool]] = "all",
1114+
axes: Union[L["all", "trans", "rot"], List[bool]] = "all", # noqa
10991115
) -> NDArray: # pragma no cover
11001116
...
11011117

@@ -1106,7 +1122,7 @@ def jacobm(
11061122
H=None,
11071123
end: Union[str, Link, Gripper, None] = None,
11081124
start: Union[str, Link, Gripper, None] = None,
1109-
axes: Union[L["all", "trans", "rot"], List[bool]] = "all",
1125+
axes: Union[L["all", "trans", "rot"], List[bool]] = "all", # noqa
11101126
) -> NDArray:
11111127
r"""
11121128
The manipulability Jacobian
@@ -1184,8 +1200,12 @@ def jacobm(
11841200

11851201
if H is None:
11861202
H = self.hessian0(J0=J, start=start, end=end)
1187-
else:
1188-
verifymatrix(H, (6, self.n, self.n))
1203+
# else:
1204+
# verifymatrix(H, (6, self.n, self.n))
1205+
elif not isinstance(H, np.ndarray):
1206+
raise TypeError("Hessian must be numpy array of shape 6xnxn")
1207+
elif H.shape != (6, self.n, self.n):
1208+
raise ValueError("Hessian must be numpy array of shape 6xnxn")
11891209

11901210
manipulability = self.manipulability(
11911211
q, J=J, start=start, end=end, axes=axes # type: ignore
@@ -1209,7 +1229,11 @@ def jacobm(
12091229

12101230
def closest_point(
12111231
self, q: ArrayLike, shape: Shape, inf_dist: float = 1.0, skip: bool = False
1212-
) -> Tuple[Union[int, None], Union[NDArray, None], Union[NDArray, None],]:
1232+
) -> Tuple[
1233+
Union[int, None],
1234+
Union[NDArray, None],
1235+
Union[NDArray, None],
1236+
]:
12131237
"""
12141238
Find the closest point between robot and shape
12151239

0 commit comments

Comments
 (0)