Skip to content

Commit

Permalink
still broken
Browse files Browse the repository at this point in the history
  • Loading branch information
wmcclinton committed Oct 6, 2023
1 parent e249e09 commit 04be489
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 8 deletions.
2 changes: 1 addition & 1 deletion predicators/behavior_utils/behavior_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1076,7 +1076,7 @@ def sample_navigation_params(igibson_behavior_env: "BehaviorEnv",
Implemented in a separate method to enable code reuse in
option_model_fns.
"""
closeness_limit = 2.00
closeness_limit = 1.00 #2.00
nearness_limit = 0.15
distance = nearness_limit + (
(closeness_limit - nearness_limit) * rng.random())
Expand Down
1 change: 1 addition & 0 deletions predicators/behavior_utils/motion_planner_fns.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ def sample_fn(env: "BehaviorEnv",
obstacles=obstacles,
override_sample_fn=lambda: sample_fn(env, rng),
rng=rng,
max_distance=0.01,
)
p.restoreState(state)
else:
Expand Down
10 changes: 7 additions & 3 deletions predicators/behavior_utils/option_model_fns.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ def graspObjectOptionModel(_state: State, env: "BehaviorEnv") -> None:
rh_final_grasp_postion,
p.getQuaternionFromEuler(rh_final_grasp_orn))

# 3. Close hand and simulate grasp
# 1.1 step the environment a few timesteps to update location.
for _ in range(3):
env.step(np.zeros(env.action_space.shape))

# 2. Close hand and simulate grasp.
a = np.zeros(env.action_space.shape, dtype=float)
a[16] = 1.0
assisted_grasp_action = np.zeros(28, dtype=float)
Expand All @@ -141,7 +145,7 @@ def graspObjectOptionModel(_state: State, env: "BehaviorEnv") -> None:
env.robots[0].parts["right_hand"].handle_assisted_grasping(
assisted_grasp_action,
override_ag_data=(grasp_obj_body_id, -1),
bypass_force_check=True)
bypass_force_check=False)
# 3.2 step the environment a few timesteps to complete grasp
for _ in range(5):
env.step(a)
Expand Down Expand Up @@ -216,7 +220,7 @@ def placeOntopObjectOptionModel(_init_state: State,
rh_orig_grasp_position, rh_orig_grasp_orn)
# this is running a series of zero action to step simulator
# to let the object fall into its place
for _ in range(15):
for _ in range(25):
env.step(np.zeros(env.action_space.shape))
# Check whether object is ontop of not a target object
objs_under = set()
Expand Down
2 changes: 1 addition & 1 deletion predicators/envs/behavior.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ def _reachable_classifier(self,
return False
return (np.linalg.norm( # type: ignore
np.array(robot_obj.get_position()) -
np.array(ig_obj.get_position())) < 2)
np.array(ig_obj.get_position())) < 1.0)

def _reachable_nothing_classifier(
self,
Expand Down
21 changes: 20 additions & 1 deletion predicators/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
--seed 0 --excluded_predicates all
"""

import curses
import numpy as np
import logging
import os
import sys
Expand All @@ -51,7 +53,7 @@
BilevelPlanningApproach
from predicators.approaches.gnn_approach import GNNApproach
from predicators.datasets import create_dataset
from predicators.envs import BaseEnv, create_new_env
from predicators.envs import BaseEnv, create_new_env, get_or_create_env
from predicators.envs.behavior import BehaviorEnv
from predicators.planning import _run_plan_with_option_model
from predicators.settings import CFG
Expand Down Expand Up @@ -340,6 +342,23 @@ def _run_testing(env: BaseEnv, approach: BaseApproach) -> Metrics:
last_plan = approach.get_last_plan()
last_traj = approach.get_last_traj()
option_model_start_time = time.time()
if CFG.env == "behavior" and \
CFG.behavior_mode == 'iggui': # pragma: no cover
env = get_or_create_env('behavior')
assert isinstance(env, BehaviorEnv)
win = curses.initscr()
win.nodelay(True)
win.addstr(
0, 0,
"VIDEO CREATION MODE: You have time to position the iggui window \
to the location you want for recording. Type 'q' to indicate you \
have finished positioning: ")
flag = win.getch()
while flag == -1 or chr(flag) != 'q':
env.igibson_behavior_env.step(np.zeros(env.action_space.shape))
flag = win.getch()
curses.endwin()
logging.info("VIDEO CREATION MODE: Starting planning.")
traj, solved = _run_plan_with_option_model(
task, test_task_idx, approach.get_option_model(),
last_plan, last_traj)
Expand Down
3 changes: 2 additions & 1 deletion predicators/planning.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,7 @@ def _run_plan_with_option_model(
lambda s, m, o, p: True).ground(option.objects, option.params)
action_option.memory = option.memory
actions[idx].set_option(action_option)
time.sleep(2)
# Since we're not checking the expected_atoms, we need to
# explicitly check if the goal is achieved.
if task.goal_holds(traj[-1]):
Expand Down Expand Up @@ -1011,7 +1012,7 @@ def _sesame_plan_with_fast_downward(
potentially add effects to null operators, but this ability is not
implemented here.
"""
init_atoms = utils.abstract(task.init, predicates)
init_atoms = utils.abstract(task.init, predicates, skip_allclose_check=True)
objects = list(task.init)
start_time = time.perf_counter()
# Create the domain and problem strings, then write them to tempfiles.
Expand Down
5 changes: 4 additions & 1 deletion predicators/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2542,7 +2542,10 @@ class VideoMonitor(Monitor):

def observe(self, state: State, action: Optional[Action]) -> None:
del state # unused
self._video.extend(self._render_fn(action, None))
render_state = self._render_fn(action, None)
self._video.extend(render_state)
self._video.extend(render_state)
self._video.extend(render_state)

def get_video(self) -> Video:
"""Return the video."""
Expand Down

0 comments on commit 04be489

Please sign in to comment.