def sense(self, action): """ Perform an action at current location and get the belief distribution over all categories. """ try: req = InfoMaxRequest() req.num_objects = self.num_objects req.objectNames = self.category_names req.actionNames = self.action_names req.numCats = self.num_categories req.catID = self.objects[self.current_location] req.actionID.val = action rospy.logdebug('calling sense service with action %d (%s) on object %d(%s)' % (req.actionID.val, self.action_names[req.actionID.val], req.catID, self.category_names[req.catID])) if not self.robot_server: res = self.get_belief_distribution(req) else: res = self.robot_server.handle_infomax_request(req) self.current_location = res.location self.current_state = res.state return res except rospy.ServiceException as e: rospy.logerr('Service call failed: %s' % e) return None
def sense(self, action): """ Perform an action at current location and get the belief distribution over all categories. """ try: req = InfoMaxRequest() req.num_objects = self.num_objects req.objectNames = self.category_names req.actionNames = self.action_names req.numCats = self.num_categories req.catID = self.objects[self.current_location] req.actionID.val = action rospy.logdebug( 'calling sense service with action %d (%s) on object %d(%s)' % (req.actionID.val, self.action_names[req.actionID.val], req.catID, self.category_names[req.catID])) if not self.robot_server: res = self.get_belief_distribution(req) else: res = self.robot_server.handle_infomax_request(req) self.current_location = res.location self.current_state = res.state return res except rospy.ServiceException as e: rospy.logerr('Service call failed: %s' % e) return None
req = InfoMaxRequest() req.objectNames = [ 'pink_glass', #0 'german_ball', #1 'blue_cup', #2 'blue_spiky_ball', #3 'screw_box', #4 'wire_spool', #5 'sqeaky_ball', #6 'duck_tape_roll', #7 'ace_terminals', #8 'chalkboard_eraser', #9 ] req.actionNames = map(str, actions) req.numCats = len(req.objectNames) req.catID = 4 for trial in range(1): rospy.loginfo('Trial number %d, object is %s' % (trial, req.objectNames[req.catID])) for action in actions: req.actionID.val = action try: infomax_srv(req) rospy.loginfo('infomax test done action %d' % action) except Exception as e: rospy.logerr('Something happened: %s' % str(e))
req = InfoMaxRequest() req.objectNames = ['pink_glass', #0 'german_ball', #1 'blue_cup', #2 'blue_spiky_ball', #3 'screw_box', #4 'wire_spool', #5 'sqeaky_ball', #6 'duck_tape_roll', #7 'ace_terminals', #8 'chalkboard_eraser', #9 ] req.actionNames = map(str, actions) req.numCats = len(req.objectNames) req.catID = 4 for trial in range(1): rospy.loginfo('Trial number %d, object is %s' % (trial,req.objectNames[req.catID])) for action in actions: req.actionID.val = action try: infomax_srv(req) rospy.loginfo('infomax test done action %d' % action) except Exception as e: rospy.logerr('Something happened: %s' % str(e))