def recognize_srv_callback(self, req):
"""
Method callback for the Recognize.srv
:param req: The service request
"""
self._response.recognitions = []
self._recognizing = True
try:
cv_image = self.bridge.imgmsg_to_cv2(req.image, "bgr8")
except CvBridgeError as e:
rospy.logerr(e)
self._image_widget.set_image(cv_image)
self._done_recognizing_button.setDisabled(False)
timeout = 60.0 # Maximum of 60 seconds
future = rospy.Time.now() + rospy.Duration(timeout)
rospy.loginfo("Waiting for manual recognition, maximum of %d seconds", timeout)
while not rospy.is_shutdown() and self._recognizing:
if rospy.Time.now() > future:
raise rospy.ServiceException("Timeout of %d seconds exceeded .." % timeout)
rospy.sleep(rospy.Duration(0.1))
self._done_recognizing_button.setDisabled(True)
return self._response
评论列表
文章目录