Skip to content

robot_related_states

Bases: AbsoluteObjectState, RobotStateMixin

Source code in OmniGibson/omnigibson/object_states/robot_related_states.py
class ObjectsInFOVOfRobot(AbsoluteObjectState, RobotStateMixin):
    def _get_value(self):
        """
        Gets all objects in the robot's field of view.

        Returns:
            set: Set of objects in the robot's field of view
        """
        if not any(isinstance(sensor, VisionSensor) for sensor in self.robot.sensors.values()):
            raise ValueError("No vision sensors found on robot.")
        objs = set()
        names_to_exclude = set(["background", "unlabelled"])
        for sensor in self.robot.sensors.values():
            if isinstance(sensor, VisionSensor):
                _, info = sensor.get_obs()
                objs.update(
                    set(
                        self.obj.scene.object_registry("name", name)
                        for name in info["seg_instance"].values()
                        if name not in names_to_exclude
                    )
                )
        # Return all objects, minus any that were mapped to None because they were not found in our object registry
        return objs - {None}