robosuite_task_zoo/environments/manipulation/hammer_place.py
def _load_model(self):
        """
        Loads an xml model, puts it in self.model
        """
        super()._load_model()

        # Adjust base pose accordingly
        xpos = self.robots[0].robot_model.base_xpos_offset["table"](self.table_full_size[0])
        self.robots[0].robot_model.set_base_xpos(xpos)

        # load model for table top workspace
        mujoco_arena = TableArena(
            table_full_size=self.table_full_size,
            table_offset=self.table_offset,
            table_friction=(0.6, 0.005, 0.0001)
        )

        # Arena always gets set to zero origin
        mujoco_arena.set_origin([0, 0, 0])

        # Modify default agentview camera
        mujoco_arena.set_camera(
            camera_name="agentview",
            pos=[0.5386131746834771, -4.392035683362857e-09, 1.4903500240372423],
            quat=[0.6380177736282349, 0.3048497438430786, 0.30484986305236816, 0.6380177736282349]
        )

        mujoco_arena.set_camera(
            camera_name="sideview",
            pos=[0.5586131746834771, 0.3, 1.2903500240372423],
            quat=[0.4144233167171478, 0.3100920617580414, 0.49641484022140503, 0.6968992352485657]
        )
        
        
        bread = CustomMaterial(
            texture="Bread",
            tex_name="bread",
            mat_name="MatBread",
            tex_attrib={"type": "cube"},
            mat_attrib={"texrepeat": "3 3", "specular": "0.4","shininess": "0.1"}
        )

        darkwood = CustomMaterial(
            texture="WoodDark",
            tex_name="darkwood",
            mat_name="MatDarkWood",
            tex_attrib={"type": "cube"},
            mat_attrib={"texrepeat": "3 3", "specular": "0.4","shininess": "0.1"}
        )

        lightwood = CustomMaterial(
            texture="WoodLight",
            tex_name="lightwood",
            mat_name="MatLightWood",
            tex_attrib={"type": "cube"},
            mat_attrib={"texrepeat": "3 3", "specular": "0.4","shininess": "0.1"}
        )

        metal = CustomMaterial(
            texture="Metal",
            tex_name="metal",
            mat_name="MatMetal",
            tex_attrib={"type": "cube"},
            mat_attrib={"specular": "1", "shininess": "0.3", "rgba": "0.9 0.9 0.9 1"}
        )

        tex_attrib = {
            "type": "cube"
        }

        mat_attrib = {
            "texrepeat": "1 1",
            "specular": "0.4",
            "shininess": "0.1"
        }
        
        greenwood = CustomMaterial(
            texture="WoodGreen",
            tex_name="greenwood",
            mat_name="greenwood_mat",
            tex_attrib=tex_attrib,
            mat_attrib=mat_attrib,
        )
        redwood = CustomMaterial(
            texture="WoodRed",
            tex_name="redwood",
            mat_name="MatRedWood",
            tex_attrib=tex_attrib,
            mat_attrib=mat_attrib,
        )
        
        bluewood = CustomMaterial(
            texture="WoodBlue",
            tex_name="bluewood",
            mat_name="handle1_mat",
            tex_attrib={"type": "cube"},
            mat_attrib={"texrepeat": "1 1", "specular": "0.4", "shininess": "0.1"},
        )

        ceramic = CustomMaterial(
            texture="Ceramic",
            tex_name="ceramic",
            mat_name="MatCeramic",
            tex_attrib=tex_attrib,
            mat_attrib=mat_attrib,
        )

        ingredient_size = [0.03, 0.018, 0.025]
        
        self.sorting_object = HammerObject(name="hammer",
                                           handle_length=(0.045, 0.05),
                                           handle_radius=(0.012, 0.012),
                                           head_density_ratio=1.0
        )

        self.cabinet_object = CabinetObject(
            name="CabinetObject")
        cabinet_object = self.cabinet_object.get_obj(); cabinet_object.set("pos", array_to_string((0.2, 0.30, 0.03))); mujoco_arena.table_body.append(cabinet_object)
        
        for obj_body in [
                self.cabinet_object,
        ]:
            for material in [lightwood, darkwood, metal, redwood, ceramic]:
                tex_element, mat_element, _, used = add_material(root=obj_body.worldbody,
                                                                 naming_prefix=obj_body.naming_prefix,
                                                                 custom_material=deepcopy(material))
                obj_body.asset.append(tex_element)
                obj_body.asset.append(mat_element)

        ingredient_size = [0.015, 0.025, 0.02]
        
        self.placement_initializer = SequentialCompositeSampler(name="ObjectSampler")

        self.placement_initializer.append_sampler(
        sampler = UniformRandomSampler(
            name="ObjectSampler-pot",
            mujoco_objects=self.sorting_object,
            x_range=[0.10,  0.18],
            y_range=[-0.20, -0.13],
            rotation=(-0.1, 0.1),
            rotation_axis='z',
            ensure_object_boundary_in_range=False,
            ensure_valid_placement=True,
            reference_pos=self.table_offset,
            z_offset=0.02,
        ))
        
        mujoco_objects = [
            self.sorting_object,
        ]

        # task includes arena, robot, and objects of interest
        self.model = ManipulationTask(
            mujoco_arena=mujoco_arena,
            mujoco_robots=[robot.robot_model for robot in self.robots], 
            mujoco_objects=mujoco_objects,
        )
        self.objects = [
            self.sorting_object,
            self.cabinet_object,
        ]
        self.model.merge_assets(self.sorting_object)
        self.model.merge_assets(self.cabinet_object)

        Loads an xml model, puts it in self.model
        
Loads an xml model, puts it in self.model
Loads an xml model puts it in self . model
def _load_model(self):
        super()._load_model()
        xpos = self.robots[0].robot_model.base_xpos_offset["table"](self.table_full_size[0])
        self.robots[0].robot_model.set_base_xpos(xpos)
        mujoco_arena = TableArena(
            table_full_size=self.table_full_size,
            table_offset=self.table_offset,
            table_friction=(0.6, 0.005, 0.0001)
        )
        mujoco_arena.set_origin([0, 0, 0])
        mujoco_arena.set_camera(
            camera_name="agentview",
            pos=[0.5386131746834771, -4.392035683362857e-09, 1.4903500240372423],
            quat=[0.6380177736282349, 0.3048497438430786, 0.30484986305236816, 0.6380177736282349]
        )
        mujoco_arena.set_camera(
            camera_name="sideview",
            pos=[0.5586131746834771, 0.3, 1.2903500240372423],
            quat=[0.4144233167171478, 0.3100920617580414, 0.49641484022140503, 0.6968992352485657]
        )
        bread = CustomMaterial(
            texture="Bread",
            tex_name="bread",
            mat_name="MatBread",
            tex_attrib={"type": "cube"},
            mat_attrib={"texrepeat": "3 3", "specular": "0.4","shininess": "0.1"}
        )
        darkwood = CustomMaterial(
            texture="WoodDark",
            tex_name="darkwood",
            mat_name="MatDarkWood",
            tex_attrib={"type": "cube"},
            mat_attrib={"texrepeat": "3 3", "specular": "0.4","shininess": "0.1"}
        )
        lightwood = CustomMaterial(
            texture="WoodLight",
            tex_name="lightwood",
            mat_name="MatLightWood",
            tex_attrib={"type": "cube"},
            mat_attrib={"texrepeat": "3 3", "specular": "0.4","shininess": "0.1"}
        )
        metal = CustomMaterial(
            texture="Metal",
            tex_name="metal",
            mat_name="MatMetal",
            tex_attrib={"type": "cube"},
            mat_attrib={"specular": "1", "shininess": "0.3", "rgba": "0.9 0.9 0.9 1"}
        )
        tex_attrib = {
            "type": "cube"
        }
        mat_attrib = {
            "texrepeat": "1 1",
            "specular": "0.4",
            "shininess": "0.1"
        }
        greenwood = CustomMaterial(
            texture="WoodGreen",
            tex_name="greenwood",
            mat_name="greenwood_mat",
            tex_attrib=tex_attrib,
            mat_attrib=mat_attrib,
        )
        redwood = CustomMaterial(
            texture="WoodRed",
            tex_name="redwood",
            mat_name="MatRedWood",
            tex_attrib=tex_attrib,
            mat_attrib=mat_attrib,
        )
        bluewood = CustomMaterial(
            texture="WoodBlue",
            tex_name="bluewood",
            mat_name="handle1_mat",
            tex_attrib={"type": "cube"},
            mat_attrib={"texrepeat": "1 1", "specular": "0.4", "shininess": "0.1"},
        )
        ceramic = CustomMaterial(
            texture="Ceramic",
            tex_name="ceramic",
            mat_name="MatCeramic",
            tex_attrib=tex_attrib,
            mat_attrib=mat_attrib,
        )
        ingredient_size = [0.03, 0.018, 0.025]
        self.sorting_object = HammerObject(name="hammer",
                                           handle_length=(0.045, 0.05),
                                           handle_radius=(0.012, 0.012),
                                           head_density_ratio=1.0
        )
        self.cabinet_object = CabinetObject(
            name="CabinetObject")
        cabinet_object = self.cabinet_object.get_obj(); cabinet_object.set("pos", array_to_string((0.2, 0.30, 0.03))); mujoco_arena.table_body.append(cabinet_object)
        for obj_body in [
                self.cabinet_object,
        ]:
            for material in [lightwood, darkwood, metal, redwood, ceramic]:
                tex_element, mat_element, _, used = add_material(root=obj_body.worldbody,
                                                                 naming_prefix=obj_body.naming_prefix,
                                                                 custom_material=deepcopy(material))
                obj_body.asset.append(tex_element)
                obj_body.asset.append(mat_element)
        ingredient_size = [0.015, 0.025, 0.02]
        self.placement_initializer = SequentialCompositeSampler(name="ObjectSampler")
        self.placement_initializer.append_sampler(
        sampler = UniformRandomSampler(
            name="ObjectSampler-pot",
            mujoco_objects=self.sorting_object,
            x_range=[0.10,  0.18],
            y_range=[-0.20, -0.13],
            rotation=(-0.1, 0.1),
            rotation_axis='z',
            ensure_object_boundary_in_range=False,
            ensure_valid_placement=True,
            reference_pos=self.table_offset,
            z_offset=0.02,
        ))
        mujoco_objects = [
            self.sorting_object,
        ]
        self.model = ManipulationTask(
            mujoco_arena=mujoco_arena,
            mujoco_robots=[robot.robot_model for robot in self.robots], 
            mujoco_objects=mujoco_objects,
        )
        self.objects = [
            self.sorting_object,
            self.cabinet_object,
        ]
        self.model.merge_assets(self.sorting_object)
        self.model.merge_assets(self.cabinet_object)
def _load_model ( self ) : super ( ) . _load_model ( ) xpos = self . robots [ 0 ] . robot_model . base_xpos_offset [ "table" ] ( self . table_full_size [ 0 ] ) self . robots [ 0 ] . robot_model . set_base_xpos ( xpos ) mujoco_arena = TableArena ( table_full_size = self . table_full_size , table_offset = self . table_offset , table_friction = ( 0.6 , 0.005 , 0.0001 ) ) mujoco_arena . set_origin ( [ 0 , 0 , 0 ] ) mujoco_arena . set_camera ( camera_name = "agentview" , pos = [ 0.5386131746834771 , - 4.392035683362857e-09 , 1.4903500240372423 ] , quat = [ 0.6380177736282349 , 0.3048497438430786 , 0.30484986305236816 , 0.6380177736282349 ] ) mujoco_arena . set_camera ( camera_name = "sideview" , pos = [ 0.5586131746834771 , 0.3 , 1.2903500240372423 ] , quat = [ 0.4144233167171478 , 0.3100920617580414 , 0.49641484022140503 , 0.6968992352485657 ] ) bread = CustomMaterial ( texture = "Bread" , tex_name = "bread" , mat_name = "MatBread" , tex_attrib = { "type" : "cube" } , mat_attrib = { "texrepeat" : "3 3" , "specular" : "0.4" , "shininess" : "0.1" } ) darkwood = CustomMaterial ( texture = "WoodDark" , tex_name = "darkwood" , mat_name = "MatDarkWood" , tex_attrib = { "type" : "cube" } , mat_attrib = { "texrepeat" : "3 3" , "specular" : "0.4" , "shininess" : "0.1" } ) lightwood = CustomMaterial ( texture = "WoodLight" , tex_name = "lightwood" , mat_name = "MatLightWood" , tex_attrib = { "type" : "cube" } , mat_attrib = { "texrepeat" : "3 3" , "specular" : "0.4" , "shininess" : "0.1" } ) metal = CustomMaterial ( texture = "Metal" , tex_name = "metal" , mat_name = "MatMetal" , tex_attrib = { "type" : "cube" } , mat_attrib = { "specular" : "1" , "shininess" : "0.3" , "rgba" : "0.9 0.9 0.9 1" } ) tex_attrib = { "type" : "cube" } mat_attrib = { "texrepeat" : "1 1" , "specular" : "0.4" , "shininess" : "0.1" } greenwood = CustomMaterial ( texture = "WoodGreen" , tex_name = "greenwood" , mat_name = "greenwood_mat" , tex_attrib = tex_attrib , mat_attrib = mat_attrib , ) redwood = CustomMaterial ( texture = "WoodRed" , tex_name = "redwood" , mat_name = "MatRedWood" , tex_attrib = tex_attrib , mat_attrib = mat_attrib , ) bluewood = CustomMaterial ( texture = "WoodBlue" , tex_name = "bluewood" , mat_name = "handle1_mat" , tex_attrib = { "type" : "cube" } , mat_attrib = { "texrepeat" : "1 1" , "specular" : "0.4" , "shininess" : "0.1" } , ) ceramic = CustomMaterial ( texture = "Ceramic" , tex_name = "ceramic" , mat_name = "MatCeramic" , tex_attrib = tex_attrib , mat_attrib = mat_attrib , ) ingredient_size = [ 0.03 , 0.018 , 0.025 ] self . sorting_object = HammerObject ( name = "hammer" , handle_length = ( 0.045 , 0.05 ) , handle_radius = ( 0.012 , 0.012 ) , head_density_ratio = 1.0 ) self . cabinet_object = CabinetObject ( name = "CabinetObject" ) cabinet_object = self . cabinet_object . get_obj ( ) ; cabinet_object . set ( "pos" , array_to_string ( ( 0.2 , 0.30 , 0.03 ) ) ) ; mujoco_arena . table_body . append ( cabinet_object ) for obj_body in [ self . cabinet_object , ] : for material in [ lightwood , darkwood , metal , redwood , ceramic ] : tex_element , mat_element , _ , used = add_material ( root = obj_body . worldbody , naming_prefix = obj_body . naming_prefix , custom_material = deepcopy ( material ) ) obj_body . asset . append ( tex_element ) obj_body . asset . append ( mat_element ) ingredient_size = [ 0.015 , 0.025 , 0.02 ] self . placement_initializer = SequentialCompositeSampler ( name = "ObjectSampler" ) self . placement_initializer . append_sampler ( sampler = UniformRandomSampler ( name = "ObjectSampler-pot" , mujoco_objects = self . sorting_object , x_range = [ 0.10 , 0.18 ] , y_range = [ - 0.20 , - 0.13 ] , rotation = ( - 0.1 , 0.1 ) , rotation_axis = 'z' , ensure_object_boundary_in_range = False , ensure_valid_placement = True , reference_pos = self . table_offset , z_offset = 0.02 , ) ) mujoco_objects = [ self . sorting_object , ] self . model = ManipulationTask ( mujoco_arena = mujoco_arena , mujoco_robots = [ robot . robot_model for robot in self . robots ] , mujoco_objects = mujoco_objects , ) self . objects = [ self . sorting_object , self . cabinet_object , ] self . model . merge_assets ( self . sorting_object ) self . model . merge_assets ( self . cabinet_object )
Loads an xml model, puts it in self.model
Loads an xml model puts it in self . model
"""
        Loads an xml model, puts it in self.model
        """ # Adjust base pose accordingly # load model for table top workspace # Arena always gets set to zero origin # Modify default agentview camera # task includes arena, robot, and objects of interest
self