Skip to content

Commit

Permalink
Merge pull request #623 from StanfordVL/fix/melt-dt
Browse files Browse the repository at this point in the history
Change default physics and render fps to 120 and 30; Fix minor bug in MeltingRule.
  • Loading branch information
ChengshuLi authored Feb 24, 2024
2 parents 871a217 + b707e46 commit 596f188
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 139 deletions.
4 changes: 2 additions & 2 deletions omnigibson/envs/env_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,8 +700,8 @@ def default_config(self):
return {
# Environment kwargs
"env": {
"action_frequency": 60,
"physics_frequency": 60,
"action_frequency": 30,
"physics_frequency": 120,
"device": None,
"automatic_reset": False,
"flatten_action_space": False,
Expand Down
2 changes: 1 addition & 1 deletion omnigibson/examples/robots/robot_control_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def main(random_selection=False, headless=False, short_exec=False):
# Create the config for generating the environment we want
env_cfg = dict()
env_cfg["action_frequency"] = 10
env_cfg["physics_frequency"] = 60
env_cfg["physics_frequency"] = 120

scene_cfg = dict()
if scene_model == "empty":
Expand Down
24 changes: 12 additions & 12 deletions omnigibson/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ class Simulator(lazy.omni.isaac.core.simulation_context.SimulationContext, Seria
Args:
gravity (float): gravity on z direction.
physics_dt (float): dt between physics steps. Defaults to 1.0 / 60.0.
physics_dt (float): dt between physics steps. Defaults to 1.0 / 120.0.
rendering_dt (float): dt between rendering steps. Note: rendering means rendering a frame of the current
application and not only rendering a frame to the viewports/ cameras. So UI elements of Isaac Sim will
be refreshed with this dt as well if running non-headless. Defaults to 1.0 / 60.0.
be refreshed with this dt as well if running non-headless. Defaults to 1.0 / 30.0.
stage_units_in_meters (float): The metric units of assets. This will affect gravity value..etc.
Defaults to 0.01.
viewer_width (int): width of the camera image, in pixels
Expand All @@ -178,8 +178,8 @@ class Simulator(lazy.omni.isaac.core.simulation_context.SimulationContext, Seria
def __init__(
self,
gravity=9.81,
physics_dt=1.0 / 60.0,
rendering_dt=1.0 / 60.0,
physics_dt=1.0 / 120.0,
rendering_dt=1.0 / 30.0,
stage_units_in_meters=1.0,
viewer_width=gm.DEFAULT_VIEWER_WIDTH,
viewer_height=gm.DEFAULT_VIEWER_HEIGHT,
Expand Down Expand Up @@ -254,8 +254,8 @@ def __init__(
def __new__(
cls,
gravity=9.81,
physics_dt=1.0 / 60.0,
rendering_dt=1.0 / 60.0,
physics_dt=1.0 / 120.0,
rendering_dt=1.0 / 30.0,
stage_units_in_meters=1.0,
viewer_width=gm.DEFAULT_VIEWER_WIDTH,
viewer_height=gm.DEFAULT_VIEWER_HEIGHT,
Expand Down Expand Up @@ -1194,12 +1194,12 @@ def _open_new_stage(self):

# Store physics dt and rendering dt to reuse later
# Note that the stage may have been deleted previously; if so, we use the default values
# of 1/60, 1/60
# of 1/120, 1/30
try:
physics_dt = self.get_physics_dt()
except:
print("WARNING: Invalid or non-existent physics scene found. Setting physics dt to 1/60.")
physics_dt = 1 / 60.
print("WARNING: Invalid or non-existent physics scene found. Setting physics dt to 1/120.")
physics_dt = 1 / 120.
rendering_dt = self.get_rendering_dt()

# Open new stage -- suppressing warning that we're opening a new stage
Expand Down Expand Up @@ -1230,12 +1230,12 @@ def _load_stage(self, usd_path):

# Store physics dt and rendering dt to reuse later
# Note that the stage may have been deleted previously; if so, we use the default values
# of 1/60, 1/60
# of 1/120, 1/30
try:
physics_dt = self.get_physics_dt()
except:
print("WARNING: Invalid or non-existent physics scene found. Setting physics dt to 1/60.")
physics_dt = 1/60.
print("WARNING: Invalid or non-existent physics scene found. Setting physics dt to 1/120.")
physics_dt = 1/120.
rendering_dt = self.get_rendering_dt()

# Open new stage -- suppressing warning that we're opening a new stage
Expand Down
5 changes: 4 additions & 1 deletion omnigibson/transition_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,10 @@ def transition(cls, object_candidates):

# Convert the meltable object into its melted substance
for meltable_obj in object_candidates["meltable"]:
system = get_system(f"melted__{meltable_obj.category}")
# All meltable xyz, half_xyz and diced__xyz transform into melted__xyz
root_category = meltable_obj.category.removeprefix("half_").removeprefix("diced__")
system_name = f"melted__{root_category}"
system = get_system(system_name)
system.generate_particles_from_link(meltable_obj, meltable_obj.root_link, check_contact=False, use_visual_meshes=False)

# Delete original object from stage.
Expand Down
4 changes: 2 additions & 2 deletions tests/benchmark/profiling.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def main():

cfg = {
"env": {
"action_frequency": 60,
"physics_frequency": 300,
"action_frequency": 30,
"physics_frequency": 120,
}
}
if args.robot > 0:
Expand Down
8 changes: 3 additions & 5 deletions tests/test_object_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,15 +633,15 @@ def test_toggled_on():
robot = og.sim.scene.object_registry("name", "robot0")

stove.set_position_orientation([1.46, 0.3, 0.45], T.euler2quat([0, 0, -np.pi / 2.0]))
robot.set_position_orientation([0.01, 0.38, 0.01], [0, 0, 0, 1])
robot.set_position_orientation([0.0, 0.38, 0.01], [0, 0, 0, 1])

assert not stove.states[ToggledOn].get_value()

q = robot.get_joint_positions()
jnt_idxs = {name: i for i, name in enumerate(robot.joints.keys())}
q[jnt_idxs["torso_lift_joint"]] = 0.0
q[jnt_idxs["shoulder_pan_joint"]] = np.deg2rad(90.0)
q[jnt_idxs["shoulder_lift_joint"]] = np.deg2rad(8.0)
q[jnt_idxs["shoulder_lift_joint"]] = np.deg2rad(9.0)
q[jnt_idxs["upperarm_roll_joint"]] = 0.0
q[jnt_idxs["elbow_flex_joint"]] = 0.0
q[jnt_idxs["forearm_roll_joint"]] = 0.0
Expand Down Expand Up @@ -1147,12 +1147,10 @@ def test_covered():
og.sim.step()

assert obj.states[Covered].set_value(system, True)
for _ in range(10):
og.sim.step()
og.sim.step()
assert obj.states[Covered].get_value(system)

assert obj.states[Covered].set_value(system, False)

# We don't call og.sim.step() here because it's possible for the "second" layer of particles to fall down
# and make Covered to be True again. Instead, we clear the caches and check that Covered is False.
obj.states[Covered].clear_cache()
Expand Down
Loading

0 comments on commit 596f188

Please sign in to comment.