robosuite_task_zoo/environments/manipulation/tool_use.py
def _setup_observables(self):
        """
        Sets up observables to be used for this environment. Creates object-based observables if enabled

        Returns:
            OrderedDict: Dictionary mapping observable names to its corresponding Observable object
        """
        observables = super()._setup_observables()

        observables["robot0_joint_pos"]._active = True
        
        # low-level object information
        if self.use_object_obs:
            # Get robot prefix and define observables modality
            pf = self.robots[0].robot_model.naming_prefix
            modality = "object"
            sensors = []
            names = [s.__name__ for s in sensors]

            # Also append handle qpos if we're using a locked drawer version with rotatable handle

            # Create observables
            for name, s in zip(names, sensors):
                observables[name] = Observable(
                    name=name,
                    sensor=s,
                    sampling_rate=self.control_freq,
                )

        pf = self.robots[0].robot_model.naming_prefix
        modality = f"{pf}proprio"

        @sensor(modality="object")
        def world_pose_in_gripper(obs_cache):
            return T.pose_inv(T.pose2mat((obs_cache[f"{pf}eef_pos"], obs_cache[f"{pf}eef_quat"]))) if\
                f"{pf}eef_pos" in obs_cache and f"{pf}eef_quat" in obs_cache else np.eye(4)

        sensors.append(world_pose_in_gripper)
        names.append("world_pose_in_gripper")

        @sensor(modality=modality)
        def gripper_contact(obs_cache):
            return self._has_gripper_contact

        @sensor(modality=modality)
        def force_norm(obs_cache):
            return np.linalg.norm(self.robots[0].ee_force - self.ee_force_bias)

        sensors += [gripper_contact, force_norm]
        names += [f"{pf}contact", f"{pf}eef_force_norm"]

        for name, s in zip(names, sensors):
            if name == "world_pose_in_gripper":
                observables[name] = Observable(
                    name=name,
                    sensor=s,
                    sampling_rate=self.control_freq,
                    enabled=True,
                    active=False,
                )
            else:
                observables[name] = Observable(
                    name=name,
                    sensor=s,
                    sampling_rate=self.control_freq
                )
                
        return observables

        Sets up observables to be used for this environment. Creates object-based observables if enabled

        Returns:
            OrderedDict: Dictionary mapping observable names to its corresponding Observable object
        
Sets up observables to be used for this environment. Creates object-based observables if enabled
Sets up observables to be used for this environment . Creates object - based observables if enabled
def _setup_observables(self):
        observables = super()._setup_observables()
        observables["robot0_joint_pos"]._active = True
        if self.use_object_obs:
            pf = self.robots[0].robot_model.naming_prefix
            modality = "object"
            sensors = []
            names = [s.__name__ for s in sensors]
            for name, s in zip(names, sensors):
                observables[name] = Observable(
                    name=name,
                    sensor=s,
                    sampling_rate=self.control_freq,
                )
        pf = self.robots[0].robot_model.naming_prefix
        modality = f"{pf}proprio"
        @sensor(modality="object")
        def world_pose_in_gripper(obs_cache):
            return T.pose_inv(T.pose2mat((obs_cache[f"{pf}eef_pos"], obs_cache[f"{pf}eef_quat"]))) if\
                f"{pf}eef_pos" in obs_cache and f"{pf}eef_quat" in obs_cache else np.eye(4)
        sensors.append(world_pose_in_gripper)
        names.append("world_pose_in_gripper")
        @sensor(modality=modality)
        def gripper_contact(obs_cache):
            return self._has_gripper_contact
        @sensor(modality=modality)
        def force_norm(obs_cache):
            return np.linalg.norm(self.robots[0].ee_force - self.ee_force_bias)
        sensors += [gripper_contact, force_norm]
        names += [f"{pf}contact", f"{pf}eef_force_norm"]
        for name, s in zip(names, sensors):
            if name == "world_pose_in_gripper":
                observables[name] = Observable(
                    name=name,
                    sensor=s,
                    sampling_rate=self.control_freq,
                    enabled=True,
                    active=False,
                )
            else:
                observables[name] = Observable(
                    name=name,
                    sensor=s,
                    sampling_rate=self.control_freq
                )
        return observables
def _setup_observables ( self ) : observables = super ( ) . _setup_observables ( ) observables [ "robot0_joint_pos" ] . _active = True if self . use_object_obs : pf = self . robots [ 0 ] . robot_model . naming_prefix modality = "object" sensors = [ ] names = [ s . __name__ for s in sensors ] for name , s in zip ( names , sensors ) : observables [ name ] = Observable ( name = name , sensor = s , sampling_rate = self . control_freq , ) pf = self . robots [ 0 ] . robot_model . naming_prefix modality = f"{pf}proprio" @ sensor ( modality = "object" ) def world_pose_in_gripper ( obs_cache ) : return T . pose_inv ( T . pose2mat ( ( obs_cache [ f"{pf}eef_pos" ] , obs_cache [ f"{pf}eef_quat" ] ) ) ) if f"{pf}eef_pos" in obs_cache and f"{pf}eef_quat" in obs_cache else np . eye ( 4 ) sensors . append ( world_pose_in_gripper ) names . append ( "world_pose_in_gripper" ) @ sensor ( modality = modality ) def gripper_contact ( obs_cache ) : return self . _has_gripper_contact @ sensor ( modality = modality ) def force_norm ( obs_cache ) : return np . linalg . norm ( self . robots [ 0 ] . ee_force - self . ee_force_bias ) sensors += [ gripper_contact , force_norm ] names += [ f"{pf}contact" , f"{pf}eef_force_norm" ] for name , s in zip ( names , sensors ) : if name == "world_pose_in_gripper" : observables [ name ] = Observable ( name = name , sensor = s , sampling_rate = self . control_freq , enabled = True , active = False , ) else : observables [ name ] = Observable ( name = name , sensor = s , sampling_rate = self . control_freq ) return observables
Sets up observables to be used for this environment.
Sets up observables to be used for this environment .
"""
        Sets up observables to be used for this environment. Creates object-based observables if enabled

        Returns:
            OrderedDict: Dictionary mapping observable names to its corresponding Observable object
        """ # low-level object information # Get robot prefix and define observables modality # Also append handle qpos if we're using a locked drawer version with rotatable handle # Create observables
Dictionary mapping observable names to its corresponding Observable object
Dictionary mapping observable names to its corresponding Observable object
OrderedDict
self