Skip to content

Commit 4eb48bb

Browse files
ASzotvincentpierreASzotjimmytyyangrpartsey
authored
[0.2.3]Skill Upgrades, Hierarchical Policy Upgrade, Bug Fixes (#959)
* [bugfix] Reconfigure the sim even if the sim is not None * addressing comments, better way to decide wether or not to reconfigure sim_obj * same fix for the robot base * Added back caching to pick task * Fixed up nav to obj task * Fixed up open and close skills * Added back inits for nav to obj * Batched HRL policy * Updated task conditions * Fixed key mismatch in TP-SRL * Fixed issue with nav to obj skill * Fixed early stop issue * Fixed bad filter condition * Updated training configs * Refactored and cleaned up config files * Fixed up reward. Renamed configs * Added wandb resume * Refactored eval with debug sensor code. * Added get policy info * Hopefully fixed resuming, added safe drop * Added improved Fetch model * Removed refactored files * Added back default * Removed habitat folder * Fixed pick task * Fixed navigation skill * Removed redundancy in skill training configs * Addressed some comments * Removed nav pick * Update .gitignore Co-authored-by: Vincent-Pierre BERGES <[email protected]> * PR comments * [v0.2.3] Hab2 fixup : merging main and resolving conflicts (#1022) * [v0.2.3] Add robot document (#1018) * [v0.2.3] [Stretch] play stretch demo (#1014) * [Fix] Documentation gym example path (#1016) Co-authored-by: vincentpierre <[email protected]> * [0.2.3]Hydra migration 3 v2 (#1000) * updated md files * updated habitat2_gym_tutorial * updated Habitat2_Quickstart * updated Habitat_Lab * updated docs * partially removed YACS (note there are some inpedendent parts of code that still rely on YACS) * made all DictConfig imports to be from omegaconf using if TYPE_CHECKING * removed link to the outdated notebook * fixed tests * [Hydra Migration] Removing yacs and migratting the dataset generation code of rearrange (#1001) * removing yacs and migratting the dataset generation code of rearrange * addressing comments * typechecking corrections Co-authored-by: vincentpierre <[email protected]> * renaming SensorConfig to LabSensorConfig * fixing svg link * fixing svg; * using relative path is better for svg * addressed comments * [0.2.3][Hydra Migration] Made agents to be of type Dict[str, AgentConfig] and added migration readme (#1007) * made habitat.simulator.agents be a Dict[str, AgentConfig] * addressed comments * refactored sim agents configuration * moved rearrange agents declarations to agents folder; finised agents configuration updates; updated docs * updated get_config import * Cfg sys migration readme (#2) * added habitat-lab config readme * addressed most of the comments * added main_agent alias * renamed habitat config reagme and added baselines config readme * Update habitat-lab/habitat/config/default.py Co-authored-by: Vincent-Pierre BERGES <[email protected]> * added desctiption for the agents_order field * added a dot :) Co-authored-by: Vincent-Pierre BERGES <[email protected]> * fixing conflicts Co-authored-by: Vincent-Pierre BERGES <[email protected]> Co-authored-by: vincentpierre <[email protected]> * Fix links in MANIFEST.in (#991) * Fix broken links in MANIFEST.in * fixig video_render_view * fixing issue with gym maker * editing test that changed with recent config modifications * [v0.2.3] Fixing mypy (#1023) * Unpin habitat-lab requirements * Reorder dependencies * Fix mypy config * remove unnecessary mypy args * Update mypy version * Fix python lint * Fix pre-commit mypy further * fix mypy ignored errors * fixing mypy * fixing mypy * more accurate type:ignores * adding docs/ to exclude mypy * trying to fix python_lint * exlude arguments * exlude arguments * Container needs to be a string Co-authored-by: Aaron Gokaslan <[email protected]> Co-authored-by: vincentpierre <[email protected]> * removing the gym envs keys that were removed Co-authored-by: Jimmy Yang <[email protected]> Co-authored-by: vincentpierre <[email protected]> Co-authored-by: Ruslan <[email protected]> Co-authored-by: Mikaël Dallaire Côté <[email protected]> Co-authored-by: Aaron Gokaslan <[email protected]> * Merged * Removed bad file and fixed IK * Env fixes * Fixed precommit * Fixed eval and fixed wandb logging * Fix for the resume in VER and the force threshold for open tasks * Update habitat-baselines/habitat_baselines/rl/ddppo/policy/resnet_policy.py Co-authored-by: Aaron Gokaslan <[email protected]> * tp-srl fixes * tp-srl fixes * Fixed more tests * Cleaned up nav action * Added tests for all tasks in baseline trainer * Corrected test overrides * Improved agents loop in resnet_policy Improved agents loop in resnet_policy Co-authored-by: Ruslan <[email protected]> * Fixed policy docs and improvements. Added docs to spawn robot method. * [0.2.3] 959 PR review suggested changes (#1029) * removed habitat-baselines/habitat_baselines/config path prefix * improved adding render view uuids to the gym obs_keys * made config keys lowercase * Updated docs * Update habitat-lab/habitat/tasks/rearrange/rearrange_task.py Co-authored-by: Vincent-Pierre BERGES <[email protected]> * Update habitat-baselines/habitat_baselines/rl/ddppo/policy/resnet_policy.py Co-authored-by: Aaron Gokaslan <[email protected]> * Fixed formatting * tp-srl config fix * fixing documentation ? Co-authored-by: vincentpierre <[email protected]> Co-authored-by: ASzot <[email protected]> Co-authored-by: Vincent-Pierre BERGES <[email protected]> Co-authored-by: Jimmy Yang <[email protected]> Co-authored-by: Ruslan <[email protected]> Co-authored-by: Mikaël Dallaire Côté <[email protected]> Co-authored-by: Aaron Gokaslan <[email protected]> Co-authored-by: Aaron Gokaslan <[email protected]> Co-authored-by: Oleksandr <[email protected]> Co-authored-by: Oleksandr Maksymets <[email protected]> Co-authored-by: SergioArnaud <[email protected]>
1 parent fbdd183 commit 4eb48bb

File tree

97 files changed

+1186
-2593
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+1186
-2593
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,4 @@ data
9999
# outputs from other libraries
100100
/sandbox
101101
/plots/outputs
102+
/wandb/

docs/pages/habitat2.rst

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,10 @@ Habitat includes an implementation of DD-PPO. As an example, start training a pi
3131
.. code:: sh
3232
3333
python -u habitat_baselines/run.py \
34-
--exp-config habitat_baselines/config/rearrange/ddppo_pick.yaml \
34+
--exp-config habitat_baselines/config/rearrange/rl_skill.yaml \
3535
--run-type train
3636
37-
Find the `complete list of RL configurations here <https://github.com/facebookresearch/habitat-lab/tree/main/habitat-baselines/habitat_baselines/config/rearrange>`__, any config starting with "ddppo" can be substituted into :code:`--exp-config`. See `here <https://github.com/facebookresearch/habitat-lab/tree/main/habitat-baselines/habitat_baselines#baselines>`__ for more information on how to run with Habitat Baselines.
38-
39-
`Home Assistant Benchmark (HAB) Tasks`_
40-
=======================================
41-
42-
To run the HAB tasks, use any of the training configurations `here <https://github.com/facebookresearch/habitat-lab/tree/main/habitat-baselines/habitat_baselines/config/rearrange/hab>`__. For example, to run monolithic RL training on the Tidy House task run:
43-
44-
.. code:: sh
45-
46-
python -u habitat_baselines/run.py \
47-
--exp-config habitat_baselines/config/rearrange/hab/ddppo_tidy_house.yaml \
48-
--run-type train
37+
This trains the Pick skill by default. To train the other skills, specify: :code:`benchmark/rearrange=skill_name` where :code:`skill_name` can be :code:`close_cab`, :code:`close_fridge`, :code:`open_fridge`, :code:`pick`, :code:`place`, or :code:`nav_to_obj`. See `here <https://github.com/facebookresearch/habitat-lab/tree/main/habitat-baselines/habitat_baselines#baselines>`__ for more information on how to run with Habitat Baselines.
4938

5039
`Task-Planning with Skills RL Baseline`_
5140
========================================
@@ -56,20 +45,21 @@ Here we will detail how to run the Task-Planning with Skills trained via reinfor
5645
.. code:: sh
5746
5847
python -u habitat_baselines/run.py \
59-
--exp-config habitat_baselines/config/rearrange/ddppo_place.yaml \
48+
--exp-config habitat_baselines/config/rearrange/rl_skill.yaml \
6049
--run-type train \
61-
checkpoint_folder=./place_checkpoints/
50+
checkpoint_folder=./place_checkpoints/ \
51+
benchmark/rearrange=place
6252
6353
2. To work on HAB tasks, you must also train a :code:`pick`, :code:`nav_to_obj`, :code:`open_cab`, :code:`close_cab`, :code:`open_fridge`, and :code:`close_fridge` policy. To do so, substitute the name of the other skill for :code:`place` in the above command.
6454

65-
3. By default, the TP-SRL baseline will look for the skill checkpoints as :code:`data/models/[skill name].pth` in the Habitat Lab directory as configured `here for each skill <https://github.com/facebookresearch/habitat-lab/blob/710beab2a5500074793b0c8047e3835fdb8f7b7e/habitat_baselines/config/rearrange/hab/tp_srl.yaml#L94>`__. The :code:`tp-srl.yaml` file can be changed to point to the skills you would like to evaluate, or you can copy the model checkpoints in :code:`data/models/`.
55+
3. By default, the TP-SRL baseline will look for the skill checkpoints as :code:`data/models/[skill name].pth`. The :code:`tp-srl.yaml` file can be changed to point to the skills you would like to evaluate, or you can copy the model checkpoints in :code:`data/models/`.
6656

6757
4. Evaluate the TP-SRL baseline on the :code:`tidy_house` HAB task via:
6858

6959
.. code:: sh
7060
7161
python -u habitat_baselines/run.py \
72-
--exp-config habitat_baselines/config/rearrange/hab/tp_srl.yaml \
62+
--exp-config habitat_baselines/config/rearrange/tp_srl.yaml \
7363
--run-type eval \
7464
benchmark/rearrange=tidy_house
7565

examples/interactive_play.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -604,10 +604,9 @@ def has_pygame():
604604
help="If true, make the task never end due to reaching max number of steps",
605605
)
606606
parser.add_argument(
607-
"--add-ik",
607+
"--disable-inverse-kinematics",
608608
action="store_true",
609-
default=False,
610-
help="If true, changes arm control to IK",
609+
help="If specified, does not add the inverse kinematics end-effector control.",
611610
)
612611
parser.add_argument(
613612
"--gfx",
@@ -668,12 +667,12 @@ def has_pygame():
668667
if args.never_end:
669668
env_config.max_episode_steps = 0
670669

671-
if args.add_ik:
670+
if not args.disable_inverse_kinematics:
672671
if "arm_action" not in task_config.actions:
673672
raise ValueError(
674-
"Action space does not have any arm control so incompatible with `--add-ik` option"
673+
"Action space does not have any arm control so cannot add inverse kinematics. Specify the `--disable-inverse-kinematics` option"
675674
)
676-
sim_config.agent_0.ik_arm_urdf = (
675+
sim_config.agents.main_agent.ik_arm_urdf = (
677676
"./data/robots/hab_fetch/robots/fetch_onlyarm.urdf"
678677
)
679678
task_config.actions.arm_action.arm_controller = "ArmEEAction"

examples/tutorials/colabs/Habitat2_Quickstart.ipynb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,10 +477,7 @@
477477
" lin_speed: 12.0\n",
478478
" ang_speed: 12.0\n",
479479
" allow_dyn_slide: True\n",
480-
" end_on_stop: False\n",
481480
" allow_back: True\n",
482-
" min_abs_lin_speed: 1.0\n",
483-
" min_abs_ang_speed: 1.0\n",
484481
" simulator:\n",
485482
" type: RearrangeSim-v0\n",
486483
" additional_object_paths:\n",

examples/tutorials/colabs/habitat2_gym_tutorial.ipynb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,6 @@
122122
" * `HabitatTidyHouse-v0`\n",
123123
" * `HabitatPrepareGroceries-v0`\n",
124124
" * `HabitatSetTable-v0`\n",
125-
" * `HabitatNavPick-v0`\n",
126-
" * `HabitatNavPickNavPlace-v0`\n",
127125
"\n",
128126
"The Gym environments are automatically registered from the RL training configurations under [\"habitat-lab/habitat/config/benchmark/rearrange\"](https://github.com/facebookresearch/habitat-lab/tree/main/habitat-lab/habitat/config/benchmark/rearrange). The `habitat.gym.auto_name` key in the YAML file determines the `[Task Name]`. The observation keys in `habitat.gym.obs_keys` are what is returned in the observation space. If the the observations are a set of 1D arrays, then the observation space is automatically flattened. For example, in `HabitatReachState-v0` the observation space is `habitat.gym.obs_keys = ['joint', 'relative_resting_position']`. `joint` is a 7D array and `relative_resting_position` is a 3D array. These two arrays are concatenated automatically to give a `10D` observation space. On the other hand, in environments with image observations, the observation is returned as a dictionary.\n",
129127
"\n",

examples/tutorials/nb_python/Habitat2_Quickstart.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,7 @@ class NavPickSuccessMeasurementConfig(MeasurementConfig):
426426
lin_speed: 12.0
427427
ang_speed: 12.0
428428
allow_dyn_slide: True
429-
end_on_stop: False
430429
allow_back: True
431-
min_abs_lin_speed: 1.0
432-
min_abs_ang_speed: 1.0
433430
simulator:
434431
type: RearrangeSim-v0
435432
additional_object_paths:

examples/tutorials/nb_python/habitat2_gym_tutorial.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@
103103
# * `HabitatTidyHouse-v0`
104104
# * `HabitatPrepareGroceries-v0`
105105
# * `HabitatSetTable-v0`
106-
# * `HabitatNavPick-v0`
107-
# * `HabitatNavPickNavPlace-v0`
108106
#
109107
# The Gym environments are automatically registered from the RL training configurations under ["habitat-lab/habitat/config/benchmark/rearrange"](https://github.com/facebookresearch/habitat-lab/tree/main/habitat-lab/habitat/config/benchmark/rearrange). The `habitat.gym.auto_name` key in the YAML file determines the `[Task Name]`. The observation keys in `habitat.gym.obs_keys` are what is returned in the observation space. If the the observations are a set of 1D arrays, then the observation space is automatically flattened. For example, in `HabitatReachState-v0` the observation space is `habitat.gym.obs_keys = ['joint', 'relative_resting_position']`. `joint` is a 7D array and `relative_resting_position` is a 3D array. These two arrays are concatenated automatically to give a `10D` observation space. On the other hand, in environments with image observations, the observation is returned as a dictionary.
110108
#

habitat-baselines/habitat_baselines/common/tensorboard_utils.py

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
# LICENSE file in the root directory of this source tree.
66

77
import os
8-
from typing import Any, List
8+
from typing import Any, List, Optional
99

1010
import numpy as np
1111
import torch
12+
from omegaconf import OmegaConf
1213
from torch.utils.tensorboard import SummaryWriter
1314

1415
try:
@@ -29,7 +30,13 @@ def get_writer(config, **kwargs):
2930

3031

3132
class TensorboardWriter:
32-
def __init__(self, log_dir: str, *args: Any, **kwargs: Any):
33+
def __init__(
34+
self,
35+
log_dir: str,
36+
*args: Any,
37+
resume_run_id: Optional[str] = None,
38+
**kwargs: Any,
39+
):
3340
r"""A Wrapper for tensorboard SummaryWriter. It creates a dummy writer
3441
when log_dir is empty string or None. It also has functionality that
3542
generates tb video directly from numpy images.
@@ -44,6 +51,9 @@ def __init__(self, log_dir: str, *args: Any, **kwargs: Any):
4451
if log_dir is not None and len(log_dir) > 0:
4552
self.writer = SummaryWriter(log_dir, *args, **kwargs)
4653

54+
def get_run_id(self) -> Optional[str]:
55+
return None
56+
4757
def __getattr__(self, item):
4858
if self.writer:
4959
return self.writer.__getattribute__(item)
@@ -90,7 +100,13 @@ def add_video_from_np_images(
90100

91101

92102
class WeightsAndBiasesWriter:
93-
def __init__(self, config, *args: Any, **kwargs: Any):
103+
def __init__(
104+
self,
105+
config,
106+
*args: Any,
107+
resume_run_id: Optional[str] = None,
108+
**kwargs: Any,
109+
):
94110
r"""
95111
Integrates with https://wandb.ai logging service.
96112
"""
@@ -112,9 +128,16 @@ def __init__(self, config, *args: Any, **kwargs: Any):
112128
raise ValueError(
113129
"Requested to log with wandb, but wandb is not installed."
114130
)
115-
116-
self.run = wandb.init(
117-
config={"slurm": slurm_info_dict, **config}, **wb_kwargs
131+
if resume_run_id is not None:
132+
wb_kwargs["id"] = resume_run_id
133+
wb_kwargs["resume"] = "must"
134+
135+
self.run = wandb.init( # type: ignore[attr-defined]
136+
config={
137+
"slurm": slurm_info_dict,
138+
**OmegaConf.to_container(config), # type: ignore[arg-type]
139+
},
140+
**wb_kwargs,
118141
)
119142

120143
def __getattr__(self, item):
@@ -128,14 +151,17 @@ def add_scalars(self, log_group, data_dict, step_id):
128151
f"{log_group}/{k.replace(' ', '')}": v
129152
for k, v in data_dict.items()
130153
}
131-
wandb.log(log_data_dict, step=int(step_id))
154+
wandb.log(log_data_dict, step=int(step_id)) # type: ignore[attr-defined]
132155

133156
def add_scalar(self, key, value, step_id):
134-
wandb.log({key: value}, step=int(step_id))
157+
wandb.log({key: value}, step=int(step_id)) # type: ignore[attr-defined]
135158

136159
def __enter__(self):
137160
return self
138161

162+
def get_run_id(self) -> Optional[str]:
163+
return self.run.id
164+
139165
def __exit__(self, exc_type, exc_val, exc_tb):
140166
if self.run:
141167
self.run.finish()

habitat-baselines/habitat_baselines/config/rearrange/ddppo_close_cab.yaml

Lines changed: 0 additions & 83 deletions
This file was deleted.

habitat-baselines/habitat_baselines/config/rearrange/ddppo_close_fridge.yaml

Lines changed: 0 additions & 83 deletions
This file was deleted.

0 commit comments

Comments
 (0)