Skip to content

Commit 56c6fa0

Browse files
fix issue of not listing new JTCs (#1891)
1 parent 9d06851 commit 56c6fa0

File tree

2 files changed

+47
-45
lines changed

2 files changed

+47
-45
lines changed

rqt_joint_trajectory_controller/rqt_joint_trajectory_controller/joint_limits_urdf.py

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -71,55 +71,55 @@ def get_joint_limits(node, joints_names, use_smallest_joint_limits=True):
7171
continue
7272
name = child.getAttribute("name")
7373

74-
if name in joints_names:
74+
try:
75+
limit = child.getElementsByTagName("limit")[0]
7576
try:
76-
limit = child.getElementsByTagName("limit")[0]
77-
try:
78-
minval = float(limit.getAttribute("lower"))
79-
maxval = float(limit.getAttribute("upper"))
80-
except ValueError:
81-
if jtype == "continuous":
82-
minval = -pi
83-
maxval = pi
84-
else:
85-
raise Exception(
86-
f"Missing lower/upper position limits for the joint : {name} of type : {jtype} in the robot_description!"
87-
)
88-
try:
89-
maxvel = float(limit.getAttribute("velocity"))
90-
except ValueError:
77+
minval = float(limit.getAttribute("lower"))
78+
maxval = float(limit.getAttribute("upper"))
79+
except ValueError:
80+
if jtype == "continuous":
81+
minval = -pi
82+
maxval = pi
83+
else:
9184
raise Exception(
92-
f"Missing velocity limits for the joint : {name} of type : {jtype} in the robot_description!"
85+
f"Missing lower/upper position limits for the joint : {name} of type : {jtype} in the robot_description!"
9386
)
94-
except IndexError:
87+
try:
88+
maxvel = float(limit.getAttribute("velocity"))
89+
except ValueError:
90+
raise Exception(
91+
f"Missing velocity limits for the joint : {name} of type : {jtype} in the robot_description!"
92+
)
93+
except IndexError:
94+
if name in joints_names:
9595
raise Exception(
9696
f"Missing limits tag for the joint : {name} in the robot_description!"
9797
)
98-
safety_tags = child.getElementsByTagName("safety_controller")
99-
if use_small and len(safety_tags) == 1:
100-
tag = safety_tags[0]
101-
if tag.hasAttribute("soft_lower_limit"):
102-
minval = max(minval, float(tag.getAttribute("soft_lower_limit")))
103-
if tag.hasAttribute("soft_upper_limit"):
104-
maxval = min(maxval, float(tag.getAttribute("soft_upper_limit")))
105-
106-
mimic_tags = child.getElementsByTagName("mimic")
107-
if use_mimic and len(mimic_tags) == 1:
108-
tag = mimic_tags[0]
109-
entry = {"parent": tag.getAttribute("joint")}
110-
if tag.hasAttribute("multiplier"):
111-
entry["factor"] = float(tag.getAttribute("multiplier"))
112-
if tag.hasAttribute("offset"):
113-
entry["offset"] = float(tag.getAttribute("offset"))
114-
115-
dependent_joints[name] = entry
116-
continue
117-
118-
if name in dependent_joints:
119-
continue
120-
121-
joint = {"min_position": minval, "max_position": maxval}
122-
joint["has_position_limits"] = jtype != "continuous"
123-
joint["max_velocity"] = maxvel
124-
free_joints[name] = joint
98+
safety_tags = child.getElementsByTagName("safety_controller")
99+
if use_small and len(safety_tags) == 1:
100+
tag = safety_tags[0]
101+
if tag.hasAttribute("soft_lower_limit"):
102+
minval = max(minval, float(tag.getAttribute("soft_lower_limit")))
103+
if tag.hasAttribute("soft_upper_limit"):
104+
maxval = min(maxval, float(tag.getAttribute("soft_upper_limit")))
105+
106+
mimic_tags = child.getElementsByTagName("mimic")
107+
if use_mimic and len(mimic_tags) == 1:
108+
tag = mimic_tags[0]
109+
entry = {"parent": tag.getAttribute("joint")}
110+
if tag.hasAttribute("multiplier"):
111+
entry["factor"] = float(tag.getAttribute("multiplier"))
112+
if tag.hasAttribute("offset"):
113+
entry["offset"] = float(tag.getAttribute("offset"))
114+
115+
dependent_joints[name] = entry
116+
continue
117+
118+
if name in dependent_joints:
119+
continue
120+
121+
joint = {"min_position": minval, "max_position": maxval}
122+
joint["has_position_limits"] = jtype != "continuous"
123+
joint["max_velocity"] = maxvel
124+
free_joints[name] = joint
125125
return free_joints

rqt_joint_trajectory_controller/rqt_joint_trajectory_controller/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ def _srv_exists(node, srv_name, srv_type):
152152

153153
srv_list = node.get_service_names_and_types()
154154
srv_info = [item for item in srv_list if item[0] == srv_name]
155+
if len(srv_info) == 0:
156+
return False
155157
srv_obtained_type = srv_info[0][1][0]
156158
return srv_type == srv_obtained_type
157159

0 commit comments

Comments
 (0)