Skip to content

Commit a1fbbcf

Browse files
committed
Rework qlim property
Sets default for revolute joints
1 parent 7239236 commit a1fbbcf

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

roboticstoolbox/robot/Robot.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,13 @@ def qlim(self):
10551055
10561056
:return: Array of joint limit values
10571057
:rtype: ndarray(2,n)
1058+
:exception ValueError: unset limits for a prismatic joint
1059+
1060+
Limits are extracted from the link objects. If joints limits are
1061+
not set for:
1062+
1063+
- a revolute joint [-𝜋. 𝜋] is returned
1064+
- a prismatic joint an exception is raised
10581065
10591066
Example:
10601067
@@ -1066,15 +1073,24 @@ def qlim(self):
10661073
"""
10671074
# TODO tidy up
10681075
limits = np.zeros((2, self.n))
1069-
for j, link in enumerate(self):
1070-
if link.qlim is None:
1071-
if link.isrevolute:
1076+
j = 0
1077+
for link in self:
1078+
if link.isrevolute:
1079+
if link.qlim is None:
10721080
v = np.r_[-np.pi, np.pi]
10731081
else:
1082+
v = link.qlim
1083+
elif link.isprismatic:
1084+
if link.qlim is None:
10741085
raise ValueError('undefined prismatic joint limit')
1086+
else:
1087+
v = link.qlim
10751088
else:
1076-
v = link.qlim
1089+
# fixed link
1090+
continue
1091+
10771092
limits[:, j] = v
1093+
j += 1
10781094
return limits
10791095

10801096
# TODO, the remaining functions, I have only a hazy understanding

0 commit comments

Comments
 (0)