Skip to content

[DO NOT MERGE]: tmp fix for ghost hand recording #1175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: feat/data-collection
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions omnigibson/envs/data_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,13 @@ def create_from_hdf5(

# Set scene file and disable online object sampling if BehaviorTask is being used
config["scene"]["scene_file"] = json.loads(f["data"].attrs["scene_file"])

# Fix: hot swap R1 USD path
if "ghost" in config["scene"]["scene_file"]["objects_info"]["init_info"]:
config["scene"]["scene_file"]["objects_info"]["init_info"]["ghost"]["args"]["usd_path"] = os.path.join(
gm.ASSET_PATH, "models/r1/usd/r1.usda"
)

if config["task"]["type"] == "BehaviorTask":
config["task"]["online_object_sampling"] = False

Expand Down Expand Up @@ -698,6 +705,12 @@ def __init__(
self.input_hdf5 = h5py.File(input_path, "r")
self.scene_file = json.loads(self.input_hdf5["data"].attrs["scene_file"])

# Fix: hot swap R1 USD path
if "ghost" in self.scene_file["objects_info"]["init_info"]:
self.scene_file["objects_info"]["init_info"]["ghost"]["args"]["usd_path"] = os.path.join(
gm.ASSET_PATH, "models/r1/usd/r1.usda"
)

# Store additional variables
self.n_render_iterations = n_render_iterations

Expand Down
14 changes: 8 additions & 6 deletions omnigibson/macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ class MacroDict(Dict):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self["_read"] = set()
object.__setattr__(self, '__locked', True) # disallow value updates after key is read
object.__setattr__(self, "__locked", True) # disallow value updates after key is read

def __setattr__(self, name, value):
if name in self.get("_read", set()) and self.is_locked:
raise AttributeError(f"Cannot set attribute {name} in MacroDict, it has already been used. "
f"If knowingly overwriting value, set value within context `with unlocked()`")
raise AttributeError(
f"Cannot set attribute {name} in MacroDict, it has already been used. "
f"If knowingly overwriting value, set value within context `with unlocked()`"
)
# Use the super's setattr for setting attributes, but handle _read directly to avoid recursion.
if name == "_read":
self[name] = value
Expand All @@ -43,13 +45,13 @@ def is_locked(self):
"""
Returns True if the config is locked (no value updates allowed after initial read).
"""
return object.__getattribute__(self, '__locked')
return object.__getattribute__(self, "__locked")

def lock(self):
"""
Lock the config. Afterward, key values cannot be updated after initial read
"""
object.__setattr__(self, '__locked', True)
object.__setattr__(self, "__locked", True)

for k in self:
if isinstance(self[k], MacroDict):
Expand All @@ -59,7 +61,7 @@ def unlock(self):
"""
Unlock the config. Afterward, key values can be updated even after initial read
"""
object.__setattr__(self, '__locked', False)
object.__setattr__(self, "__locked", False)

for k in self:
if isinstance(self[k], MacroDict):
Expand Down
2 changes: 1 addition & 1 deletion omnigibson/maps/segmentation_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(
"""
# Store internal values
self.scene_dir = scene_dir
self.map_default_resolution = 1.0 # Default floor plan images are in meters
self.map_default_resolution = 1.0 # Default floor plan images are in meters
self.floor_heights = floor_heights

# Other values that will be loaded at runtime
Expand Down
8 changes: 5 additions & 3 deletions omnigibson/sampling/create_stable_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
from utils import *

parser = argparse.ArgumentParser()
parser.add_argument("--scene_model", type=str, default=None,
help="Scene model to sample tasks in")
parser.add_argument("--scene_model", type=str, default=None, help="Scene model to sample tasks in")

gm.HEADLESS = False
gm.USE_GPU_DYNAMICS = False
Expand All @@ -19,14 +18,17 @@ def main(random_selection=False, headless=False, short_exec=False):

if args.scene_model is None:
# This MUST be specified
assert os.environ.get("SAMPLING_SCENE_MODEL"), "scene model MUST be specified, either as a command-line arg or as an environment variable!"
assert os.environ.get(
"SAMPLING_SCENE_MODEL"
), "scene model MUST be specified, either as a command-line arg or as an environment variable!"
args.scene_model = os.environ["SAMPLING_SCENE_MODEL"]

# If we want to create a stable scene config, do that now
default_scene_fpath = f"{gm.DATASET_PATH}/scenes/{args.scene_model}/json/{args.scene_model}_stable.json"
if not os.path.exists(default_scene_fpath):
create_stable_scene_json(scene_model=args.scene_model, record_feedback=True)


if __name__ == "__main__":
main()

Expand Down
2 changes: 1 addition & 1 deletion omnigibson/scenes/scene_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ def add_object(self, obj, register=True, _batched_call=False):
for link in obj.links.values():
CollisionAPI.add_to_collision_group(
col_group=(
"fixed_base_root_links" # if link == obj.root_link else "fixed_base_nonroot_links"
"fixed_base_root_links" # if link == obj.root_link else "fixed_base_nonroot_links"
),
prim_path=link.prim_path,
)
Expand Down
Loading