def validate_action_space()

in deepracer_navigation_pkg/deepracer_navigation_pkg/deepracer_navigation_node.py [0:0]


    def validate_action_space(self):
        """Helper method that validates the action space for specific action space type.

        Raises:
            Exception: Raise an exception if the action space values are invalid.
        """
        valid_action_space = True
        if self.action_space_type == constants.ActionSpaceTypes.DISCRETE:
            for action_dict in self.action_space:
                if constants.ModelMetadataKeys.STEERING not in action_dict \
                  or constants.ModelMetadataKeys.SPEED not in action_dict:
                    valid_action_space = False
                    break
        elif self.action_space_type == constants.ActionSpaceTypes.CONTINUOUS:
            if constants.ModelMetadataKeys.STEERING not in self.action_space \
              or constants.ModelMetadataKeys.SPEED not in self.action_space:
                valid_action_space = False
            else:
                steering_action_dict = self.action_space[constants.ModelMetadataKeys.STEERING]
                speed_action_dict = self.action_space[constants.ModelMetadataKeys.SPEED]
                if (constants.ModelMetadataKeys.CONTINUOUS_HIGH not in steering_action_dict
                    or constants.ModelMetadataKeys.CONTINUOUS_LOW not in steering_action_dict
                    or constants.ModelMetadataKeys.CONTINUOUS_HIGH not in speed_action_dict
                    or constants.ModelMetadataKeys.CONTINUOUS_LOW not in speed_action_dict
                    or steering_action_dict[constants.ModelMetadataKeys.CONTINUOUS_HIGH]
                        <= steering_action_dict[constants.ModelMetadataKeys.CONTINUOUS_LOW]
                    or speed_action_dict[constants.ModelMetadataKeys.CONTINUOUS_HIGH]
                        <= speed_action_dict[constants.ModelMetadataKeys.CONTINUOUS_LOW]):
                    valid_action_space = False
        if not valid_action_space:
            raise Exception(f"Incorrect action space values: {self.action_space}")