Skip to content

Commit

Permalink
debugging vlm known/unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
wmcclinton committed Oct 29, 2024
1 parent 974457e commit 1580f6f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
56 changes: 28 additions & 28 deletions predicators/cogman.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,34 +84,34 @@ def step(self, observation: Observation) -> Optional[Action]:
self._exec_monitor.env_task = self._current_env_task
if self._exec_monitor.step(state):
logging.info("[CogMan] Replanning triggered.")
import jellyfish
def map_goal_to_state(goal_predicates, state_data):
goal_to_state_mapping = {}
state_usage_count = {state_obj: 0 for state_obj in state_data.keys()}
for pred in goal_predicates:
for goal_obj in pred.objects:
goal_obj_name = str(goal_obj)
closest_state_obj = None
min_distance = float('inf')
for state_obj in state_data.keys():
state_obj_name = str(state_obj)
distance = jellyfish.levenshtein_distance(goal_obj_name, state_obj_name)
if distance < min_distance:
min_distance = distance
closest_state_obj = state_obj
if state_usage_count[closest_state_obj] > 0:
virtual_obj = Object(f"{closest_state_obj}_{state_usage_count[closest_state_obj]}", closest_state_obj.type)
goal_to_state_mapping[goal_obj] = virtual_obj
else:
goal_to_state_mapping[goal_obj] = closest_state_obj
state_usage_count[closest_state_obj] += 1
return goal_to_state_mapping
mapping = map_goal_to_state(self._exec_monitor._curr_goal, state.data)
new_goal = set()
for pred in self._exec_monitor._curr_goal:
new_goal.add(GroundAtom(pred.predicate, [mapping[obj] for obj in pred.objects]))
import ipdb; ipdb.set_trace()
self._current_goal = new_goal
# import jellyfish
# def map_goal_to_state(goal_predicates, state_data):
# goal_to_state_mapping = {}
# state_usage_count = {state_obj: 0 for state_obj in state_data.keys()}
# for pred in goal_predicates:
# for goal_obj in pred.objects:
# goal_obj_name = str(goal_obj)
# closest_state_obj = None
# min_distance = float('inf')
# for state_obj in state_data.keys():
# state_obj_name = str(state_obj)
# distance = jellyfish.levenshtein_distance(goal_obj_name, state_obj_name)
# if distance < min_distance:
# min_distance = distance
# closest_state_obj = state_obj
# if state_usage_count[closest_state_obj] > 0:
# virtual_obj = Object(f"{closest_state_obj}_{state_usage_count[closest_state_obj]}", closest_state_obj.type)
# goal_to_state_mapping[goal_obj] = virtual_obj
# else:
# goal_to_state_mapping[goal_obj] = closest_state_obj
# state_usage_count[closest_state_obj] += 1
# return goal_to_state_mapping
# mapping = map_goal_to_state(self._exec_monitor._curr_goal, state.data)
# new_goal = set()
# for pred in self._exec_monitor._curr_goal:
# new_goal.add(GroundAtom(pred.predicate, [mapping[obj] for obj in pred.objects]))
# import ipdb; ipdb.set_trace()
# self._current_goal = new_goal
assert self._current_goal is not None
task = Task(state, self._current_goal)
self._reset_policy(task)
Expand Down
6 changes: 3 additions & 3 deletions predicators/perception/spot_perceiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,9 +566,9 @@ def _create_goal(self, state: State,
Inside = pred_name_to_pred["Inside"]
if state.data == {}:
return {
#GroundAtom(ContainingFoodKnown, [cup]),
#GroundAtom(NotContainingFood, [cup]),
GroundAtom(Inside, [cup, plastic_bin]),
GroundAtom(ContainingFoodKnown, [cup]),
GroundAtom(NotContainingFood, [cup]),
#GroundAtom(Inside, [cup, plastic_bin]),
}
object_name_to_object = {}
return self._parse_vlm_goal_from_state(state, goal_description, object_name_to_object)
Expand Down

0 comments on commit 1580f6f

Please sign in to comment.