def creat_goal(self, config): if 'goal' in config: self.goal_category = config['goal']['category'] self.goal_predicate_list = [] if self.goal_category == "traversal": self.goal_object_id = PlanParser.create_legal_object_name( config['goal']['metadata']['target']['id']) agent_final_loc = PlanParser.replace_digital_number( "loc|{:.2f}|{:.2f}|{:.2f}".format( self.object_loc_info[self.goal_object_id][0], self.object_loc_info[self.goal_object_id][1], self.object_loc_info[self.goal_object_id][2])) self.goal_predicate_list.append( "(agentAtLocation {} {})".format(self.AGENT_NAME, agent_final_loc)) elif self.goal_category == "retrieval": self.goal_object_id = PlanParser.create_legal_object_name( config['goal']['metadata']['target']['id']) self.goal_predicate_list.append("(held {} {})".format( self.AGENT_NAME, self.goal_object_id)) elif self.goal_category == "transferral": self.transfer_object_id = PlanParser.create_legal_object_name( config['goal']['metadata']['target_1']['id']) self.target_object_id = PlanParser.create_legal_object_name( config['goal']['metadata']['target_2']['id']) if config['goal']['metadata']['relationship'][1] == "next to": self.goal_predicate_list.append( "(objectNextTo {} {})".format(self.transfer_object_id, self.target_object_id)) elif config['goal']['metadata']['relationship'][ 1] == "on top of": self.goal_predicate_list.append( "(objectOnTopOf {} {})".format(self.transfer_object_id, self.target_object_id)) elif self.goal_category == "playroom": self.transfer_object_id = PlanParser.create_legal_object_name( "box_b") self.target_object_id = PlanParser.create_legal_object_name( "chair_b") for obj in config['objects']: if "openable" in obj and obj["openable"] == True: receptacle_object_id = PlanParser.create_legal_object_name( obj['id']) if "opened" in obj: self.object_open_close_info[ receptacle_object_id] = True else: self.object_open_close_info[ receptacle_object_id] = False self.apple_a = PlanParser.create_legal_object_name("apple_a") self.ball_a = PlanParser.create_legal_object_name("ball_a") self.ball_b = PlanParser.create_legal_object_name("ball_b") self.bowl_a = PlanParser.create_legal_object_name("bowl_a") self.goal_predicate_list.extend([ "(objectOnTopOf {} {})".format(self.apple_a, self.target_object_id), "(objectOnTopOf {} {})".format(self.ball_a, self.target_object_id), "(objectOnTopOf {} {})".format(self.ball_b, self.target_object_id), # "(objectOnTopOf {} {})".format(self.bowl_a, self.target_object_id), # "(objectOnTopOf {} {})".format(self.transfer_object_id, self.target_object_id), # "(inreceptacle {} {})".format(self.apple_a, self.bowl_a), # "(inreceptacle {} {})".format(self.ball_a, self.transfer_object_id), # "(inreceptacle {} {})".format(self.ball_b, self.transfer_object_id), # "(inreceptacle {} {})".format(self.bowl_a, self.transfer_object_id), ])
def creat_goal(self, config): if 'goal' in config: self.goal_category = config['goal']['category'] self.goal_predicate_list = [] if self.goal_category == "traversal": self.goal_object_id = PlanParser.create_legal_object_name( config['goal']['metadata']['target']['id']) if self.goal_object_id not in self.object_loc_info: return agent_final_loc = PlanParser.replace_digital_number( "loc|{:.2f}|{:.2f}|{:.2f}".format( self.object_loc_info[self.goal_object_id][0], self.object_loc_info[self.goal_object_id][1], self.object_loc_info[self.goal_object_id][2])) self.goal_predicate_list.append( "(agentAtLocation {} {})".format(self.AGENT_NAME, agent_final_loc)) elif self.goal_category == "retrieval": self.goal_object_id = PlanParser.create_legal_object_name( config['goal']['metadata']['target']['id']) for obj in config['objects']: if obj['id'] == self.goal_object_id: continue if "openable" in obj and obj["openable"] == True: receptacle_object_id = PlanParser.create_legal_object_name( obj['id']) if "opened" in obj: self.object_open_close_info[ receptacle_object_id] = True else: self.object_open_close_info[ receptacle_object_id] = False self.goal_predicate_list.append("(held {} {})".format( self.AGENT_NAME, self.goal_object_id)) elif self.goal_category == "transferral": self.transfer_object_id = PlanParser.create_legal_object_name( config['goal']['metadata']['target_1']['id']) if config['goal_in_hand'] == True: self.object_in_hand = PlanParser.create_legal_object_name( config['id_goal_in_hand']) self.target_object_id = PlanParser.create_legal_object_name( config['goal']['metadata']['target_2']['id']) for obj in config['objects']: if obj['id'] == self.transfer_object_id: continue if "openable" in obj and obj["openable"] == True: receptacle_object_id = PlanParser.create_legal_object_name( obj['id']) if "opened" in obj: self.object_open_close_info[ receptacle_object_id] = True else: self.object_open_close_info[ receptacle_object_id] = False if config['goal']['metadata']['relationship'][1] == "next to": self.goal_predicate_list.append( "(objectNextTo {} {})".format(self.transfer_object_id, self.target_object_id)) elif config['goal']['metadata']['relationship'][ 1] == "on top of": self.goal_predicate_list.append( "(objectOnTopOf {} {})".format(self.transfer_object_id, self.target_object_id))