parameters: (
      args,
      objects,
      num_objects=30,
      box_size=2,
      object_speed=2,
      post_throw_settling_time=5,
      useVHACD=False,
      VHACDParams=def_params,
  )
return_statement: return data
docstring: Drops a specified number of objects into a box and returns metrics including the time to simulate each frame, render each frame, and the number of collisions each frame.
docstring_summary: Drops a specified number of objects into a box and returns metrics including the time to simulate each frame, render each frame, and the number of collisions each frame.
docstring_tokens: Drops a specified number of objects into a box and returns metrics including the time to simulate each frame render each frame and the number of collisions each frame .
function: def box_drop_test(
      args,
      objects,
      num_objects=30,
      box_size=2,
      object_speed=2,
      post_throw_settling_time=5,
      useVHACD=False,
      VHACDParams=def_params,
  ):  # take in parameters here
      """Drops a specified number of objects into a box and returns metrics including the time to simulate each frame, render each frame, and the number of collisions each frame."""
  
      data = {
          "observations": [],
          "physics_step_times": [],
          "graphics_render_times": [],
          "collisions": [],
      }
  
      cfg = make_configuration()
      with habitat_sim.Simulator(cfg) as sim:
          sim.initialize_agent(
              0,
              habitat_sim.AgentState(
                  [5.45 * box_size, 2.4 * box_size, 1.2 * box_size],
                  np.quaternion(-0.8000822, 0.1924500, -0.5345973, -0.1924500),
              ),
          )
  
          # get the physics object attributes manager
          obj_templates_mgr = sim.get_object_template_manager()
          # get the rigid object manager, which provides direct
          # access to objects
          rigid_obj_mgr = sim.get_rigid_object_manager()
  
          # build box
          cube_handle = obj_templates_mgr.get_template_handles("cube")[0]
          box_parts = []
          box_objs = []
          for _i in range(5):
              box_parts += [obj_templates_mgr.get_template_by_handle(cube_handle)]
          box_parts[0].scale = np.array([1.0, 0.1, 1.0]) * box_size
          box_parts[1].scale = np.array([1.0, 0.6, 0.1]) * box_size
          box_parts[2].scale = np.array([1.0, 0.6, 0.1]) * box_size
          box_parts[3].scale = np.array([0.1, 0.6, 1.0]) * box_size
          box_parts[4].scale = np.array([0.1, 0.6, 1.0]) * box_size
  
          for i in range(5):
              part_name = "box_part_" + str(i)
              obj_templates_mgr.register_template(box_parts[i], part_name)
              box_objs += [rigid_obj_mgr.add_object_by_template_handle(part_name)]
              box_objs[i].motion_type = habitat_sim.physics.MotionType.KINEMATIC
  
          box_objs[0].translation = np.array([2.50, 0.05, 0.4]) * box_size
          box_objs[1].translation = np.array([2.50, 0.35, 1.30]) * box_size
          box_objs[2].translation = np.array([2.50, 0.35, -0.50]) * box_size
          box_objs[3].translation = np.array([3.40, 0.35, 0.4]) * box_size
          box_objs[4].translation = np.array([1.60, 0.35, 0.4]) * box_size
          for i in range(5):
              box_objs[i].motion_type = habitat_sim.physics.MotionType.STATIC
  
          # load some object templates from configuration files
          object_ids = []
          for obj in objects:
              obj_path = obj["path"]
              object_ids += [
                  obj_templates_mgr.load_configs(str(os.path.join(data_path, obj_path)))[
                      0
                  ]
              ]
              obj_template = obj_templates_mgr.get_template_by_id(object_ids[-1])
  
              if "scale" in obj:
                  obj_template.scale *= obj["scale"]
              obj_handle = obj_template.render_asset_handle
  
              if useVHACD:
                  new_handle = sim.apply_convex_hull_decomposition(
                      obj_handle, VHACDParams, True, False
                  )
  
                  new_obj_template = obj_templates_mgr.get_template_by_handle(new_handle)
  
                  if "scale" in obj:
                      new_obj_template.scale *= obj["scale"]
  
                  obj_templates_mgr.register_template(
                      new_obj_template, force_registration=True
                  )
                  object_ids[-1] = new_obj_template.ID
                  print("Template Registered")
              else:
                  obj_templates_mgr.register_template(
                      obj_template, force_registration=True
                  )
  
          # throw objects into box
          for i in range(num_objects):
              cur_obj = rigid_obj_mgr.add_object_by_template_id(
                  object_ids[i % len(object_ids)]
              )
  
              obj_node = cur_obj.root_scene_node
              obj_bb = obj_node.cumulative_bb
              diagonal_length = obj_bb.size().length()
              time_til_next_obj = diagonal_length / (object_speed * box_size) / 2
  
              # set object position and velocity
              cur_obj.translation = np.multiply(np.array([1.50, 2, 1.2]), box_size)
              cur_obj.linear_velocity = (
                  mn.Vector3(1, 0, -1).normalized() * object_speed * box_size
              )
  
              # simulate a short amount of time, then add next object
              simulate(sim, dt=time_til_next_obj, get_frames=args.make_video, data=data)
  
          simulate(
              sim, dt=post_throw_settling_time, get_frames=args.make_video, data=data
          )
  
          # [/basics]
          # return total time to run, time to load, time to simulate physics, time for rendering
          rigid_obj_mgr.remove_all_objects()
      return data
function_tokens: def box_drop_test ( args , objects , num_objects = 30 , box_size = 2 , object_speed = 2 , post_throw_settling_time = 5 , useVHACD = False , VHACDParams = def_params , ) : # take in parameters here data = { "observations" : [ ] , "physics_step_times" : [ ] , "graphics_render_times" : [ ] , "collisions" : [ ] , } cfg = make_configuration ( ) with habitat_sim . Simulator ( cfg ) as sim : sim . initialize_agent ( 0 , habitat_sim . AgentState ( [ 5.45 * box_size , 2.4 * box_size , 1.2 * box_size ] , np . quaternion ( - 0.8000822 , 0.1924500 , - 0.5345973 , - 0.1924500 ) , ) , ) # get the physics object attributes manager obj_templates_mgr = sim . get_object_template_manager ( ) # get the rigid object manager, which provides direct # access to objects rigid_obj_mgr = sim . get_rigid_object_manager ( ) # build box cube_handle = obj_templates_mgr . get_template_handles ( "cube" ) [ 0 ] box_parts = [ ] box_objs = [ ] for _i in range ( 5 ) : box_parts += [ obj_templates_mgr . get_template_by_handle ( cube_handle ) ] box_parts [ 0 ] . scale = np . array ( [ 1.0 , 0.1 , 1.0 ] ) * box_size box_parts [ 1 ] . scale = np . array ( [ 1.0 , 0.6 , 0.1 ] ) * box_size box_parts [ 2 ] . scale = np . array ( [ 1.0 , 0.6 , 0.1 ] ) * box_size box_parts [ 3 ] . scale = np . array ( [ 0.1 , 0.6 , 1.0 ] ) * box_size box_parts [ 4 ] . scale = np . array ( [ 0.1 , 0.6 , 1.0 ] ) * box_size for i in range ( 5 ) : part_name = "box_part_" + str ( i ) obj_templates_mgr . register_template ( box_parts [ i ] , part_name ) box_objs += [ rigid_obj_mgr . add_object_by_template_handle ( part_name ) ] box_objs [ i ] . motion_type = habitat_sim . physics . MotionType . KINEMATIC box_objs [ 0 ] . translation = np . array ( [ 2.50 , 0.05 , 0.4 ] ) * box_size box_objs [ 1 ] . translation = np . array ( [ 2.50 , 0.35 , 1.30 ] ) * box_size box_objs [ 2 ] . translation = np . array ( [ 2.50 , 0.35 , - 0.50 ] ) * box_size box_objs [ 3 ] . translation = np . array ( [ 3.40 , 0.35 , 0.4 ] ) * box_size box_objs [ 4 ] . translation = np . array ( [ 1.60 , 0.35 , 0.4 ] ) * box_size for i in range ( 5 ) : box_objs [ i ] . motion_type = habitat_sim . physics . MotionType . STATIC # load some object templates from configuration files object_ids = [ ] for obj in objects : obj_path = obj [ "path" ] object_ids += [ obj_templates_mgr . load_configs ( str ( os . path . join ( data_path , obj_path ) ) ) [ 0 ] ] obj_template = obj_templates_mgr . get_template_by_id ( object_ids [ - 1 ] ) if "scale" in obj : obj_template . scale *= obj [ "scale" ] obj_handle = obj_template . render_asset_handle if useVHACD : new_handle = sim . apply_convex_hull_decomposition ( obj_handle , VHACDParams , True , False ) new_obj_template = obj_templates_mgr . get_template_by_handle ( new_handle ) if "scale" in obj : new_obj_template . scale *= obj [ "scale" ] obj_templates_mgr . register_template ( new_obj_template , force_registration = True ) object_ids [ - 1 ] = new_obj_template . ID print ( "Template Registered" ) else : obj_templates_mgr . register_template ( obj_template , force_registration = True ) # throw objects into box for i in range ( num_objects ) : cur_obj = rigid_obj_mgr . add_object_by_template_id ( object_ids [ i % len ( object_ids ) ] ) obj_node = cur_obj . root_scene_node obj_bb = obj_node . cumulative_bb diagonal_length = obj_bb . size ( ) . length ( ) time_til_next_obj = diagonal_length / ( object_speed * box_size ) / 2 # set object position and velocity cur_obj . translation = np . multiply ( np . array ( [ 1.50 , 2 , 1.2 ] ) , box_size ) cur_obj . linear_velocity = ( mn . Vector3 ( 1 , 0 , - 1 ) . normalized ( ) * object_speed * box_size ) # simulate a short amount of time, then add next object simulate ( sim , dt = time_til_next_obj , get_frames = args . make_video , data = data ) simulate ( sim , dt = post_throw_settling_time , get_frames = args . make_video , data = data ) # [/basics] # return total time to run, time to load, time to simulate physics, time for rendering rigid_obj_mgr . remove_all_objects ( ) return data