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
def process_classify(req): return (['obj1', 'obj2'], [0.5, 0.5]) if __name__ == '__main__': rospy.Service('/classify', classify, process_classify) rospy.init_node('infomax_test', anonymous=True) rospy.loginfo('waiting for /get_category_distribution service') rospy.wait_for_service('/get_category_distribution') infomax_srv = rospy.ServiceProxy('/get_category_distribution', InfoMax) rospy.loginfo('connected to get_category_distribution service') actions = [InfomaxAction.DROP] * 1 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
def process_classify(req): return (['obj1','obj2'], [0.5,0.5]) if __name__ == '__main__': rospy.Service('/classify', classify, process_classify) rospy.init_node('infomax_test', anonymous=True) rospy.loginfo('waiting for /get_category_distribution service') rospy.wait_for_service('/get_category_distribution') infomax_srv = rospy.ServiceProxy('/get_category_distribution', InfoMax) rospy.loginfo('connected to get_category_distribution service') actions = [InfomaxAction.DROP]*1 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