Skip to content
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

Fix issue #765: add underscore to class implementation and change class to simulator-based ownership #835

Open
wants to merge 2 commits into
base: og-develop
Choose a base branch
from
Open
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
39 changes: 28 additions & 11 deletions omnigibson/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,12 @@ def __init__(
# This makes that possible (and also introduces possible issues around circular dependencies)
assert og.sim is None, "Only one Simulator instance can be created at a time!"
og.sim = self
self.collision_api = CollisionAPI
self.controlable_object_view_api = ControllableObjectViewAPI
self.flatcache_api = FlatcacheAPI
self.gripper_rigid_contact_api = GripperRigidContactAPI
self.pose_api = PoseAPI
self.rigid_contact_api = RigidContactAPI

# Sanity check physics vs. rendering vs. sim step dt
physics_dt = 1.0 / gm.DEFAULT_PHYSICS_FREQ if physics_dt is None else physics_dt
Expand Down Expand Up @@ -874,7 +880,8 @@ def _reset_variables(self):
def render(self):
super().render()
# During rendering, the Fabric API is updated, so we can mark it as clean
PoseAPI.mark_valid()
# PoseAPI.mark_valid()
og.sim.pose_api.mark_valid()

def update_handles(self):
# Handles are only relevant when physx is running
Expand All @@ -897,9 +904,12 @@ def update_handles(self):
system.refresh_particles_view()

# Finally update any unified views
RigidContactAPI.initialize_view()
GripperRigidContactAPI.initialize_view()
ControllableObjectViewAPI.initialize_view()
# RigidContactAPI.initialize_view()
# GripperRigidContactAPI.initialize_view()
# ControllableObjectViewAPI.initialize_view()
og.sim.rigid_contact_api.initialize_view()
og.sim.gripper_rigid_contact_api.initialize_view()
og.sim.controlable_object_view_api.initialize_view()

def _non_physics_step(self):
"""
Expand Down Expand Up @@ -978,9 +988,12 @@ def _omni_update_step(self):
Step any omni-related things
"""
# Clear the bounding box and contact caches so that they get updated during the next time they're called
RigidContactAPI.clear()
GripperRigidContactAPI.clear()
ControllableObjectViewAPI.clear()
# RigidContactAPI.clear()
# GripperRigidContactAPI.clear()
# ControllableObjectViewAPI.clear()
og.sim.rigid_contact_api.clear()
og.sim.gripper_rigid_contact_api.clear()
og.sim.controlable_object_view_api.clear()

def play(self):
if not self.is_playing():
Expand Down Expand Up @@ -1044,7 +1057,8 @@ def stop(self):

# If we're using flatcache, we also need to reset its API
if gm.ENABLE_FLATCACHE:
FlatcacheAPI.reset()
# FlatcacheAPI.reset()
og.sim.flatcache_api.reset()

# Run all callbacks
for callback in self._callbacks_on_stop.values():
Expand Down Expand Up @@ -1101,11 +1115,13 @@ def step_physics(self):

# Update all APIs
self._omni_update_step()
PoseAPI.invalidate()
# PoseAPI.invalidate()
og.sim.pose_api.invalidate()

def _on_physics_step(self):
# Make the controllable object view API refresh
ControllableObjectViewAPI.clear()
# ControllableObjectViewAPI.clear()
og.sim.controlable_object_view_api.clear()

# Run the controller step on every controllable object
for scene in self.scenes:
Expand All @@ -1114,7 +1130,8 @@ def _on_physics_step(self):
obj.step()

# Flush the controls from the ControllableObjectViewAPI
ControllableObjectViewAPI.flush_control()
# ControllableObjectViewAPI.flush_control()
og.sim.controlable_object_view_api.flush_control()

def _on_contact(self, contact_headers, contact_data):
"""
Expand Down
8 changes: 4 additions & 4 deletions omnigibson/utils/usd_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def create_joint(
return joint_prim


class RigidContactAPIImpl:
class _RigidContactAPIImpl:
"""
Class containing class methods to aggregate rigid body contacts across all rigid bodies in the simulator
"""
Expand Down Expand Up @@ -485,10 +485,10 @@ def clear(self):


# Instantiate the RigidContactAPI
RigidContactAPI = RigidContactAPIImpl()
RigidContactAPI = _RigidContactAPIImpl()


class GripperRigidContactAPIImpl(RigidContactAPIImpl):
class _GripperRigidContactAPIImpl(_RigidContactAPIImpl):
@classmethod
def get_column_filters(cls):
from omnigibson.robots.manipulation_robot import ManipulationRobot
Expand All @@ -512,7 +512,7 @@ def get_max_contact_data_count(cls):


# Instantiate the GripperRigidContactAPI
GripperRigidContactAPI = GripperRigidContactAPIImpl()
GripperRigidContactAPI = _GripperRigidContactAPIImpl()


class CollisionAPI:
Expand Down