From f278494bffb4b9f52fbb8556a972d1b6f9948c28 Mon Sep 17 00:00:00 2001 From: Nishanth Kumar Date: Thu, 2 Nov 2023 15:13:47 -0400 Subject: [PATCH 1/2] add more documentation (#85) * add more documentation * fix mypy requirements * updated mypy * yapf --- behavior.md | 11 +++++++++++ predicators/utils.py | 2 +- scripts/cluster_utils.py | 7 ++++--- setup.py | 5 ++--- tests/envs/test_base_env.py | 2 +- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/behavior.md b/behavior.md index 6f6488f6f9..494c3438bb 100644 --- a/behavior.md +++ b/behavior.md @@ -91,7 +91,18 @@ python predicators/main.py --env behavior --approach oracle --option_model_name * Be sure to set `--plan_only_eval True`: this is necessary to account for the fact that the iGibson simulator is non-deterministic when saving and loading states (which is currently an unresolved bug). * Example command: `python predicators/main.py --env behavior --approach oracle --option_model_name oracle_behavior --num_train_tasks 0 --num_test_tasks 1 --behavior_train_scene_name Pomaria_2_int --behavior_test_scene_name Pomaria_2_int --behavior_task_list "[opening_packages]" --seed 1000 --offline_data_planning_timeout 500.0 --timeout 500.0 --behavior_option_model_eval True --plan_only_eval True`. +## Creating and Saving Video +The codebase is also equipped with functionality to create and save videos of robot execution. For most videos, you'll want to do actual motion planning for navigation, but teleport the hands for grasping/placing (you can do actual motion planning for these as well, but it tends to get rather slow). + +Here is an example command that creates and saves video: +``` +python predicators/main.py --env behavior --approach oracle --option_model_name oracle_behavior --num_train_tasks 0 --num_test_tasks 1 --behavior_train_scene_name Pomaria_2_int --behavior_test_scene_name Pomaria_2_int --behavior_task_list "[collecting_aluminum_cans]" --seed 456 --offline_data_planning_timeout 500.0 --timeout 500.0 --behavior_option_model_eval True --plan_only_eval True --behavior_mode iggui --behavior_save_video True --sesame_task_planner fdopt --simulate_nav True --behavior_option_model_rrt True +``` + ## Troubleshooting +### Common Error Messages +- `invalid render device choice 0 < 0`. This means there is a CUDA driver-related mismatch. If this wasn't happening before and starts happening suddenly, then just run `sudo reboot` to reboot your machine and it should go away. + ### Visualizing what the robot is doing If a lot of plans are failing in refinement, then visualization can be an extremely powerful debugging tool (e.g. it's often the case that samplers are simply struggling to find good samples to accomplish a particular action). Unfortunately, due to OpenGL version issues on MIT SuperCloud, visualization cannot be done on SuperCloud itself and requires a local installation. Moreover, some minor file editing is required: 1. Open the `igibson/render/mesh_renderer/shaders/450/optimized_vert.shader` within the `iGibson` repo (remember, this should be the LIS fork of iGibson!). diff --git a/predicators/utils.py b/predicators/utils.py index e62855b853..3d7458cd0d 100644 --- a/predicators/utils.py +++ b/predicators/utils.py @@ -1848,7 +1848,7 @@ def all_ground_nsrts_fd_translator( prob_str = create_pddl_problem(objects, init_atoms, goal, "mydomain", "myproblem") with nostdout(): - sas_task = downward_translate(dom_str, prob_str) + sas_task = downward_translate(dom_str, prob_str) # type: ignore for operator in sas_task.operators: split_name = operator.name[1:-1].split() # strip out ( and ) nsrt = nsrt_name_to_nsrt[split_name[0]] diff --git a/scripts/cluster_utils.py b/scripts/cluster_utils.py index 90d1aa3101..d8be5dc4d1 100644 --- a/scripts/cluster_utils.py +++ b/scripts/cluster_utils.py @@ -3,7 +3,7 @@ import os import subprocess from dataclasses import dataclass -from typing import Any, Dict, Iterator, List, Tuple +from typing import Any, Dict, Iterator, List, Optional, Tuple import yaml @@ -140,8 +140,9 @@ def run_cmds_on_machine( cmds: List[str], user: str, machine: str, - ssh_key: str = None, - allowed_return_codes: Tuple[int, ...] = (0, )) -> None: + ssh_key: Optional[str] = None, + allowed_return_codes: Tuple[int, ...] = (0, ) +) -> None: """SSH into the machine, run the commands, then exit.""" host = f"{user}@{machine}" ssh_cmd = f"ssh -tt -o StrictHostKeyChecking=no {host}" diff --git a/setup.py b/setup.py index ffb57c0db2..2f3bb1f17e 100644 --- a/setup.py +++ b/setup.py @@ -8,6 +8,7 @@ version="0.1.0", packages=find_packages(include=["predicators", "predicators.*"]), install_requires=[ + "mypy", "numpy>=1.22.3", "pytest", "gym==0.26.2", @@ -15,7 +16,7 @@ "imageio", "imageio-ffmpeg", "pandas", - "torch", + "torch==2.0.1", "scipy", "tabulate", "dill", @@ -44,7 +45,5 @@ "yapf==0.32.0", "docformatter==1.4", "isort==5.10.1", - "mypy@git+https://github.com/python/mypy.git@9bd651758e8ea2494" + - "837814092af70f8d9e6f7a1", ] }) diff --git a/tests/envs/test_base_env.py b/tests/envs/test_base_env.py index 7f3062f8df..20756715e7 100644 --- a/tests/envs/test_base_env.py +++ b/tests/envs/test_base_env.py @@ -1,7 +1,7 @@ """Test cases for the base environment class.""" import pytest -from test_oracle_approach import ENV_NAME_AND_CLS +from test_oracle_approach import ENV_NAME_AND_CLS # type: ignore from predicators import utils from predicators.envs import BaseEnv, create_new_env, get_or_create_env From c4e38c0ecaf95e3b5d441037b15895b926833d55 Mon Sep 17 00:00:00 2001 From: Nishanth Kumar Date: Thu, 2 Nov 2023 15:31:21 -0400 Subject: [PATCH 2/2] make changes necessary to prevent crashing on supercloud expers (#82) Co-authored-by: Willie McClinton --- predicators/main.py | 2 +- scripts/configs/behavior_pick_place_evaluation.yaml | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/predicators/main.py b/predicators/main.py index de27151760..e7d14c626e 100644 --- a/predicators/main.py +++ b/predicators/main.py @@ -123,7 +123,7 @@ def main() -> None: # Run the full pipeline. _run_pipeline(env, approach, stripped_train_tasks, offline_dataset) script_time = time.perf_counter() - script_start - if CFG.env == "behavior": # pragma: no cover + if CFG.env == "behavior" and CFG.behavior_save_video: # pragma: no cover assert isinstance(env, BehaviorEnv) task_name = str(CFG.behavior_task_list)[2:-2] env.igibson_behavior_env.simulator.viewer.make_video( diff --git a/scripts/configs/behavior_pick_place_evaluation.yaml b/scripts/configs/behavior_pick_place_evaluation.yaml index 7e7330f8c4..cc765cd624 100644 --- a/scripts/configs/behavior_pick_place_evaluation.yaml +++ b/scripts/configs/behavior_pick_place_evaluation.yaml @@ -84,7 +84,7 @@ FLAGS: # general flags behavior_override_learned_samplers: True behavior_ignore_discover_failures: True num_train_tasks: 10 - num_test_tasks: 0 -START_SEED: 463 -NUM_SEEDS: 2 + num_test_tasks: 10 +START_SEED: 456 +NUM_SEEDS: 10 USE_GPU: False