Demo to use the raycasting-based sampler to load objects onTop and/or inside another
Loads a cabinet, a microwave open on top of it, and two plates with apples on top, one inside and one on top of the cabinet
Then loads a shelf and cracker boxes inside of it
Source code in omnigibson/examples/object_states/sample_kinematics_demo.py
defmain(random_selection=False,headless=False,short_exec=False):""" Demo to use the raycasting-based sampler to load objects onTop and/or inside another Loads a cabinet, a microwave open on top of it, and two plates with apples on top, one inside and one on top of the cabinet Then loads a shelf and cracker boxes inside of it """og.log.info(f"Demo {__file__}\n "+"*"*80+"\n Description:\n"+main.__doc__+"*"*80)# Create the scene config to load -- empty scenecfg={"scene":{"type":"Scene",},}# Define objects we want to sample at runtimemicrowave_cfg=dict(type="DatasetObject",name="microwave",category="microwave",model="hjjxmi",bounding_box=[0.768,0.512,0.392],)cabinet_cfg=dict(type="DatasetObject",name="cabinet",category="bottom_cabinet",model="bamfsz",bounding_box=[1.075,1.131,1.355],)plate_cfgs=[dict(type="DatasetObject",name=f"plate{i}",category="plate",model="iawoof",bounding_box=th.tensor([0.20,0.20,0.05]),)foriinrange(2)]apple_cfgs=[dict(type="DatasetObject",name=f"apple{i}",category="apple",model="agveuv",bounding_box=[0.065,0.065,0.077],)foriinrange(4)]shelf_cfg=dict(type="DatasetObject",name=f"shelf",category="shelf",model="pkgbcp",bounding_box=th.tensor([1.0,0.4,2.0]),)box_cfgs=[dict(type="DatasetObject",name=f"box{i}",category="box_of_crackers",model="cmdigf",bounding_box=th.tensor([0.2,0.05,0.3]),)foriinrange(5)]# Compose objects cfgobjects_cfg=[microwave_cfg,cabinet_cfg,*plate_cfgs,*apple_cfgs,shelf_cfg,*box_cfgs,]# Update their spawn positions so they don't collide immediatelyfori,obj_cfginenumerate(objects_cfg):obj_cfg["position"]=[100+i,100+i,100+i]cfg["objects"]=objects_cfg# Create the environmentenv=og.Environment(configs=cfg)env.step([])# Sample microwave and boxessample_boxes_on_shelf(env)sample_microwave_plates_apples(env)max_steps=100ifshort_execelse-1step=0whilestep!=max_steps:env.step(th.empty(0))step+=1# Always close environment at the endog.clear()