Skip to content

Observe part validity


Air Force Research Laboratory (AFRL) Autonomous Capabilities Team (ACT3) Reinforcement Learning (RL) Core.

This is a US Government Work not subject to copyright protection in the US.

The use, dissemination or disclosure of data in this file is subject to limitation or restriction. See accompanying README and LICENSE for details.


ObservePartValidity (BaseAgentPlatformGlue) ¤

Glue to observe a part's validity flag

Source code in corl/glues/common/observe_part_validity.py
class ObservePartValidity(BaseAgentPlatformGlue):
    """Glue to observe a part's validity flag
    """

    # pylint: disable=too-few-public-methods
    class Fields:
        """
        Fields in this glue
        """
        VALIDITY_OBSERVATION = "validity_observation"

    @property
    def get_validator(self) -> typing.Type[ObservePartValidityValidator]:
        return ObservePartValidityValidator

    def __init__(self, **kwargs) -> None:
        self.config: ObservePartValidityValidator
        super().__init__(**kwargs)

        self._part: BasePlatformPart = get_part_by_name(self._platform, self.config.part)
        self._part_name: str = self.config.part

    @lru_cache(maxsize=1)
    def get_unique_name(self) -> str:
        """Class method that retrieves the unique name for the glue instance
        """
        return "ObserveValidity_" + self._part_name

    @lru_cache(maxsize=1)
    def observation_units(self):
        """Units of the sensors in this glue
        """
        d = gym.spaces.dict.Dict()
        d.spaces[self.Fields.VALIDITY_OBSERVATION] = NoneUnitType
        return d

    @lru_cache(maxsize=1)
    def observation_space(self) -> gym.spaces.Space:
        """Observation Space
        """
        d = gym.spaces.dict.Dict()
        d.spaces[self.Fields.VALIDITY_OBSERVATION] = gym.spaces.Discrete(2)
        return d

    def get_observation(self) -> OrderedDict:
        """Observation Values
        """
        d = OrderedDict()
        d[self.Fields.VALIDITY_OBSERVATION] = int(self._part.valid)

        return d

get_validator: Type[corl.glues.common.observe_part_validity.ObservePartValidityValidator] property readonly ¤

returns the validator for this class

Returns:

Type Description
Type[corl.glues.common.observe_part_validity.ObservePartValidityValidator]

BaseAgentGlueValidator -- A pydantic validator to be used to validate kwargs

Fields ¤

Fields in this glue

Source code in corl/glues/common/observe_part_validity.py
class Fields:
    """
    Fields in this glue
    """
    VALIDITY_OBSERVATION = "validity_observation"

get_observation(self) ¤

Observation Values

Source code in corl/glues/common/observe_part_validity.py
def get_observation(self) -> OrderedDict:
    """Observation Values
    """
    d = OrderedDict()
    d[self.Fields.VALIDITY_OBSERVATION] = int(self._part.valid)

    return d

get_unique_name(self) ¤

Class method that retrieves the unique name for the glue instance

Source code in corl/glues/common/observe_part_validity.py
@lru_cache(maxsize=1)
def get_unique_name(self) -> str:
    """Class method that retrieves the unique name for the glue instance
    """
    return "ObserveValidity_" + self._part_name

observation_space(self) ¤

Observation Space

Source code in corl/glues/common/observe_part_validity.py
@lru_cache(maxsize=1)
def observation_space(self) -> gym.spaces.Space:
    """Observation Space
    """
    d = gym.spaces.dict.Dict()
    d.spaces[self.Fields.VALIDITY_OBSERVATION] = gym.spaces.Discrete(2)
    return d

observation_units(self) ¤

Units of the sensors in this glue

Source code in corl/glues/common/observe_part_validity.py
@lru_cache(maxsize=1)
def observation_units(self):
    """Units of the sensors in this glue
    """
    d = gym.spaces.dict.Dict()
    d.spaces[self.Fields.VALIDITY_OBSERVATION] = NoneUnitType
    return d

ObservePartValidityValidator (BaseAgentPlatformGlueValidator) pydantic-model ¤

part: which part to find on the platform

Source code in corl/glues/common/observe_part_validity.py
class ObservePartValidityValidator(BaseAgentPlatformGlueValidator):
    """
    part: which part to find on the platform
    """
    part: str