Skip to content

Commit 8913248

Browse files
committed
Merge pull request #191 from cdondrup/wait_for_service
[qsr_prob_rep] Waiting for services to become available
2 parents c23b183 + 58af930 commit 8913248

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

qsr_prob_rep/src/qsrrep_ros/ros_client.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ def call_service(self, req):
2727
"""
2828
assert(issubclass(req.__class__, HMMRepRequestAbstractclass))
2929
s = rospy.ServiceProxy(self.services[req.__class__],QSRProbRep)
30-
res = s(QSRProbRepRequest(qsr_type=req.kwargs.pop("qsr_type"), data=json.dumps(req.kwargs)))
30+
try:
31+
s.wait_for_service(timeout=10.)
32+
res = s(QSRProbRepRequest(qsr_type=req.kwargs.pop("qsr_type"), data=json.dumps(req.kwargs)))
33+
except (rospy.ROSException, rospy.ROSInterruptException, rospy.ServiceException) as e:
34+
rospy.logerr(e)
35+
return None
3136
try:
3237
data = json.loads(res.data)
3338
except ValueError:

0 commit comments

Comments
 (0)