def build()

in robogym/envs/dactyl/reach.py [0:0]


    def build(cls, n_substeps: int = 10):
        """Construct a ShadowHandReachSimulation object.

        :param n_substeps: (int) sim.nsubsteps, num of substeps
        :return: a ShadowHandReachSimulation object with properly constructed sim.
        """
        xml = MujocoXML()
        xml.add_default_compiler_directive()

        xml.append(
            MujocoXML.parse(cls.FLOOR_XML).set_named_objects_attr(
                "floor", tag="body", pos=[1, 1, 0]
            )
        )

        target = MujocoXML.parse(cls.TARGET_XML)

        colors = [
            [1.0, 0.0, 0.0, 1.0],
            [0.0, 1.0, 0.0, 1.0],
            [0.0, 0.0, 1.0, 1.0],
            [1.0, 1.0, 0.0, 1.0],
            [1.0, 0.0, 1.0, 1.0],
        ]

        for site, color in zip(FINGERTIP_SITE_NAMES, colors):
            target.set_named_objects_attr(
                f"target_{site}",
                pos=[0.5, 0.5, 0.0],
                type="sphere",
                rgba=color,
                size=0.005,
            )

        xml.append(target)

        xml.append(
            MujocoXML.parse(cls.HAND_XML)
            .add_name_prefix("robot0:")
            .set_named_objects_attr(
                "robot0:hand_mount",
                tag="body",
                pos=[1.0, 1.25, 0.15],
                euler=[np.pi / 2, 0, np.pi],
            )
            .remove_objects_by_name("robot0:annotation:outer_bound")
            # Remove hand base free joint so that hand is immovable
            .remove_objects_by_name("robot0:hand_base")
        )

        xml.append(MujocoXML.parse(cls.LIGHT_XML))

        simulation = cls(xml.build(nsubsteps=n_substeps))

        # Move fingers out of the way.
        simulation.shadow_hand.set_position_control(
            simulation.shadow_hand.denormalize_position_control(
                simulation.shadow_hand.zero_control()
            )
        )

        for _ in range(20):
            simulation.step()

        return simulation