(self)
| 95 | self._load_start_preds(episode) |
| 96 | |
| 97 | def _load_sampled_names(self): |
| 98 | t_start = time.time() |
| 99 | self.new_entities: Dict[str, PddlEntity] = {} |
| 100 | for entity_name, entity_conds in self._sample_entities.items(): |
| 101 | match_type = self.pddl.expr_types[entity_conds["type"]] |
| 102 | matches = list(self.pddl.find_entities(match_type)) |
| 103 | |
| 104 | if entity_conds.get("ignore_articulated_receptacles", False): |
| 105 | matches = [ |
| 106 | m |
| 107 | for m in matches |
| 108 | if m.name |
| 109 | not in [ |
| 110 | "receptacle_aabb_middle_topfrl_apartment_refrigerator", |
| 111 | "receptacle_aabb_drawer_left_top_frl_apartment_kitchen_counter", |
| 112 | "receptacle_aabb_drawer_right_top_frl_apartment_kitchen_counter", |
| 113 | ] |
| 114 | ] |
| 115 | |
| 116 | pred_conds = entity_conds.get("pred_conds", []) |
| 117 | matches = _filter_matching_pred_conds( |
| 118 | matches, pred_conds, self.pddl, self.new_entities, entity_name |
| 119 | ) |
| 120 | |
| 121 | if len(matches) == 0: |
| 122 | obj_ref, obj_name = list(self.new_entities.items())[0] |
| 123 | on_top_pred = f"on_top({obj_ref},{entity_name})" |
| 124 | cmp_pred_cond = pred_conds[0].replace(" ", "") |
| 125 | if len(pred_conds) == 1 and cmp_pred_cond == on_top_pred: |
| 126 | use_entity_name: str = self._sim.ep_info.name_to_receptacle[ |
| 127 | obj_name.name |
| 128 | ] |
| 129 | entity = self.pddl.all_entities[use_entity_name] |
| 130 | else: |
| 131 | raise ValueError( |
| 132 | f"Could not find match for {entity_name}: {entity_conds}" |
| 133 | ) |
| 134 | elif self._sample_entities_use_constant_sampling: |
| 135 | entity = matches[0] |
| 136 | else: |
| 137 | entity = random.choice(matches) |
| 138 | |
| 139 | self.new_entities[entity_name] = entity |
| 140 | self._sampled_names = list(self.new_entities.keys()) |
| 141 | self._sim.add_perf_timing("find_entities", t_start) |
| 142 | |
| 143 | @property |
| 144 | def pddl_problem(self): |
no test coverage detected