Skip to content

Commit

Permalink
Merge pull request #611 from StanfordVL/fix/sampling-fixes
Browse files Browse the repository at this point in the history
fix bugs during sampling
  • Loading branch information
cremebrule authored Feb 17, 2024
2 parents ca095ea + b41dad1 commit 2782c6e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions omnigibson/object_states/slicer_active.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ def state_size(self):
# For this state, we simply store its value.
def _dump_state(self):
state = super()._dump_state()
state["previously_touching"] = self.PREVIOUSLY_TOUCHING[self.OBJ_IDXS[self.obj.name]]
state["delay_counter"] = self.DELAY_COUNTER[self.OBJ_IDXS[self.obj.name]]
state["previously_touching"] = bool(self.PREVIOUSLY_TOUCHING[self.OBJ_IDXS[self.obj.name]])
state["delay_counter"] = int(self.DELAY_COUNTER[self.OBJ_IDXS[self.obj.name]])

return state

Expand Down
3 changes: 3 additions & 0 deletions omnigibson/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,9 @@ def play(self):
if robot.initialized:
robot.update_controller_mode()

# Also refresh any transition rules that became stale while sim was stopped
TransitionRuleAPI.refresh_all_rules()

# Additionally run non physics things
self._non_physics_step()

Expand Down
1 change: 1 addition & 0 deletions omnigibson/systems/macro_particle_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@ def _compute_batch_particles_position_orientation(cls, particles, local=False):
# get the transform, and not obj.get_local_pose() which will give us the local pose of the
# root link!
link_tfs[obj] = T.pose2mat(XFormPrim.get_local_pose(obj))
link = obj
else:
link = cls._particles_info[name]["link"]
if link not in link_tfs:
Expand Down
10 changes: 6 additions & 4 deletions omnigibson/systems/system_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ def initialize(cls):
SYSTEM_REGISTRY.add(obj=cls)

# Avoid circular import
from omnigibson.transition_rules import TransitionRuleAPI
TransitionRuleAPI.refresh_all_rules()
if og.sim.is_playing():
from omnigibson.transition_rules import TransitionRuleAPI
TransitionRuleAPI.refresh_all_rules()

# Run any callbacks
for callback in _CALLBACKS_ON_SYSTEM_INIT.values():
Expand Down Expand Up @@ -224,8 +225,9 @@ def _clear(cls):
SYSTEM_REGISTRY.remove(obj=cls)

# Avoid circular import
from omnigibson.transition_rules import TransitionRuleAPI
TransitionRuleAPI.refresh_all_rules()
if og.sim.is_playing():
from omnigibson.transition_rules import TransitionRuleAPI
TransitionRuleAPI.refresh_all_rules()

@classmethod
def reset(cls):
Expand Down
6 changes: 4 additions & 2 deletions omnigibson/utils/bddl_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,8 @@ def __init__(
self.is_system = is_substance_synset(self.synset)

# Infer the correct category to assign
self.og_categories = OBJECT_TAXONOMY.get_subtree_categories(self.synset)
self.og_categories = OBJECT_TAXONOMY.get_subtree_substances(self.synset) \
if self.is_system else OBJECT_TAXONOMY.get_subtree_categories(self.synset)

super().__init__(obj=entity)

Expand Down Expand Up @@ -741,6 +742,7 @@ def _build_inroom_object_scope(self):
obj_synset = self._object_instance_to_synset[obj_inst]

# We allow burners to be used as if they are stoves
# No need to safeguard check for subtree_substances because inroom objects will never be substances
categories = OBJECT_TAXONOMY.get_subtree_categories(obj_synset)
abilities = OBJECT_TAXONOMY.get_abilities(obj_synset)

Expand Down Expand Up @@ -921,7 +923,7 @@ def _import_sampleable_objects(self):
if is_substance_synset(obj_synset):
assert len(self._activity_conditions.parsed_objects[obj_synset]) == 1, "Systems are singletons"
obj_inst = self._activity_conditions.parsed_objects[obj_synset][0]
system_name = OBJECT_TAXONOMY.get_subtree_categories(obj_synset)[0]
system_name = OBJECT_TAXONOMY.get_subtree_substances(obj_synset)[0]
self._object_scope[obj_inst] = BDDLEntity(
bddl_inst=obj_inst,
entity=None if obj_inst in self._future_obj_instances else get_system(system_name),
Expand Down

0 comments on commit 2782c6e

Please sign in to comment.