pycram.datastructures.partial_designator#
Attributes#
Classes#
A partial designator_description is somewhat between a DesignatorDescription and a specified designator_description. Basically it is a |
Module Contents#
- pycram.datastructures.partial_designator.T#
- class pycram.datastructures.partial_designator.PartialDesignator(performable: T, *args, **kwargs)#
Bases:
pycram.language.LanguageMixin,typing_extensions.Iterable[T]A partial designator_description is somewhat between a DesignatorDescription and a specified designator_description. Basically it is a partially initialized specified designator_description which can take a list of input arguments (like a DesignatorDescription) and generate a list of specified designators with all possible permutations of the input arguments.
PartialDesignators are designed as generators, as such they need to be iterated over to yield the possible specified designators. Please also keep in mind that at the time of iteration all parameter of the specified designator_description need to be filled, otherwise a TypeError will be raised, see the example below for usage.
# Example usage partial_designator = PartialDesignator(PickUpAction, milk_object_designator, arm=[Arms.RIGHT, Arms.LEFT]) for performable in partial_designator(Grasp.FRONT): performable.perform()
- performable: T = None#
Reference to the performable class that should be initialized
- args: typing_extensions.Tuple[typing_extensions.Any, Ellipsis] = None#
Arguments that are passed to the performable
- kwargs: typing_extensions.Dict[str, typing_extensions.Any] = None#
Keyword arguments that are passed to the performable
- __call__(*fargs, **fkwargs)#
Creates a new PartialDesignator with the given arguments and keyword arguments added. Existing arguments will be prioritized over the new arguments.
- Parameters:
fargs – Additional arguments that should be added to the new PartialDesignator
fkwargs – Additional keyword arguments that should be added to the new PartialDesignator
- Returns:
A new PartialDesignator with the given arguments and keyword arguments added
- __iter__() typing_extensions.Iterator[T]#
Iterates over all possible permutations of the arguments and keyword arguments and creates a new performable object for each permutation. In case there are conflicting parameters the args will be used over the keyword arguments.
- Returns:
A new performable object for each permutation of arguments and keyword arguments
- generate_permutations() typing_extensions.Iterator[typing_extensions.Dict[str, typing_extensions.Any]]#
Generates the cartesian product of the given arguments. Arguments can also be a list of lists of arguments.
- Yields:
A list with a possible permutation of the given arguments
- missing_parameter() typing_extensions.List[str]#
Returns a list of all parameters that are missing for the performable to be initialized.
- Returns:
A list of parameter names that are missing from the performable
- resolve()#
Returns the Designator with the first set of parameters
- Returns:
A fully parametrized Designator
- to_dict()#
- flatten() typing_extensions.List[pycram.has_parameters.leaf_types]#
Flattens a partial designator, very similar to HasParameters.flatten but this method can deal with parameters thet are None.
- Returns:
A list of flattened field values from the object.
- flatten_parameters() typing_extensions.Dict[str, pycram.has_parameters.leaf_types]#
The flattened parameter types of the performable.
- Returns:
A dict with the flattened parameter types of the performable.