Skip to content

🪄 Transition Rules

Description

Transition rules are OmniGibson's method for simulating complex physical phenomena not directly supported by the underlying omniverse physics engine, such as slicing, blending, and cooking. A given TransitionRule dynamically checks for its internal sets of conditions, and, if validated, executes its corresponding transition.

Transition Rules must be enabled before usage!

To enable usage of transition rules, gm.ENABLE_TRANSITION_RULES (1) must be set!

  1. Access global macros via from omnigibson.macros import gm

Usage

Creating

Because TransitionRules are monolithic classes, these should be defined before OmniGibson is launched. A rule can be easily extended by subclassing the BaseTransitionRule class and implementing the necessary functions. For a simple example, please see the SlicingRule class.

Runtime

At runtime, each scene owns a TransitionRuleAPI instance, which automatically handles the stepping and processing of all defined transition rule classes. For efficiency reasons, rules are dynamically loaded and checked based on the object / system set currently active in the scene. A rule will only be checked if there is at least one valid candidate combination amongst the current object / system set. For example, if there is no sliceable object present in this scene, then SlicingRule will not be active. Every time an object / system is added / removed from the scene, all rules are refreshed so that the current active transition rule set is always accurate.

In general, you should not need to interface with the TransitionRuleAPI class at all -- if your rule implementation is correct, then the API will automatically handle the transition when the appropriate conditions are met!

Types

OmniGibson currently supports _ types of diverse transition rules, each representing a different complex physical phenomena:

SlicingRule


Encapsulates slicing an object into halves (e.g.: slicing an apple).

Required Candidates
  • 1+ sliceable objects
  • 1+ slicer objects


Conditions
  • slicer is touching sliceable object
  • slicer is active


Transition
  • sliceable object is removed
  • x2 sliceable half objects are spawned where the original object was
slicing_rule_before slicing_rule_after
DicingRule


Encapsulates dicing a diceable into small chunks (e.g.: dicing an apple).

Required Candidates
  • 1+ diceable objects
  • 1+ slicer objects


Conditions
  • slicer is touching diceable object
  • slicer is active


Transition
  • sliceable object is removed
  • diceable physical particles are spawned where the original object was
dicing_rule_before dicing_rule_after
MeltingRule


Encapsulates melting an object into liquid (e.g.: melting chocolate).

Required Candidates
  • 1+ meltable objects


Conditions
  • meltable object's max temperature > melting temperature


Transition
  • meltable object is removed
  • melted__<category> fluid particles are spawned where the original object was
melting_rule_before melting_rule_after
CookingPhysicalParticleRule


Encapsulates cooking physical particles (e.g.: boiling water).

Required Candidates
  • 1+ fillable and heatable objects


Conditions
  • fillable object is heated


Transition
  • particles within the fillable object are removed
  • cooked__<category> particles are spawned where the original particles were
cooking_physical_particle_rule_before cooking_physical_particle_rule_after
ToggleableMachineRule


Encapsulates transformative changes when a button is pressed (e.g.: blending a smoothie). Valid transitions are defined by a pre-defined set of "recipes" (input / output combinations).

Required Candidates
  • 1+ fillable and toggleable objects


Conditions
  • fillable object has just been toggled on


Transition
  • all objects and particles within the fillable object are removed
  • if relevant recipe is found given inputs, relevant output is spawned in the fillable object, otherwise "sludge" is spawned instead
toggleable_machine_rule_before toggleable_machine_rule_after
MixingToolRule


Encapsulates transformative changes during tool-driven mixing (e.g.: mixing a drink with a stirrer). Valid transitions are defined by a pre-defined set of "recipes" (input / output combinations).

Required Candidates
  • 1+ fillable objects
  • 1+ mixingTool objects


Conditions
  • mixingTool object has just touched fillable object
  • valid recipe is found


Transition
  • recipe-relevant objects and particles within the fillable object are removed
  • relevant recipe output is spawned in the fillable object
mixing_rule_before mixing_rule_after
CookingRule


Encapsulates transformative changes during cooking (e.g.: baking a cake). Valid transitions are defined by a pre-defined set of "recipes" (input / output combinations).

Required Candidates
  • 1+ fillable objects
  • 1+ heatSource objects


Conditions
  • heatSource object is on and affecting fillable object
  • a certain amount of time has passed


Transition
  • recipe-relevant objects and particles within the fillable object are removed
  • relevant recipe output is spawned in the fillable object
cooking_rule_before cooking_rule_after
WasherRule


Encapsulates washing mechanism (e.g.: cleaning clothes in the washing machine with detergent). Washing behavior (i.e.: what types of particles are removed from clothes during washing) is predefined.

Required Candidates
  • 1+ washer objects


Conditions
  • washer object is closed
  • washer object has just been toggled on


Transition
  • all "stain"-type particles within the washer object are removed
  • all objects within the washer object are covered and saturated with water
washer_rule_before washer_rule_after
DryerRule


Encapsulates drying mechanism (e.g.: drying clothes in the drying machine).

Required Candidates
  • 1+ clothes_dryer objects


Conditions
  • washer object is closed
  • washer object has just been toggled on


Transition
  • all water particles within the washer object are removed
  • all objects within the washer object are no longer saturated with water
dryer_rule_before dryer_rule_after