timor.task.Task =============== .. py:module:: timor.task.Task Attributes ---------- .. autoapisummary:: timor.task.Task.GRAVITY timor.task.Task.robot_or_robots Classes ------- .. autoapisummary:: timor.task.Task.Task timor.task.Task.TaskHeader Module Contents --------------- .. py:data:: GRAVITY .. py:class:: Task(header, obstacles = None, goals = None, constraints = None, frames = None) .. autoapi-inheritance-diagram:: timor.task.Task.Task :parts: 1 :private-bases: A task describes a problem that must be solved by one or multiple robots. The problem can be composed of multiple goals, each with their own constraints. Global constraints, e.g. valid base placements or the order of goals can be defined on the task-level. Create a Task: :param header: The header contains meta informaton about the task. Must at least contain an ID. :param obstacles: Obstacles in the task/environment the robots should not collide with. :param goals: The complete set of goals that need to be achieved in order to solve the task :param constraints: "Global" constraint that must hold for the whole task. .. py:method:: __deepcopy__(memodict={}) Custom deepcopy for the task class. Experimental! .. py:method:: __eq__(other) Tasks are equal if headers, goals, constraints, and obstacles are equal. .. py:method:: __getstate__() Return objects which will be pickled and saved. .. py:method:: __hash__() Hash is given by the unique ID. .. py:method:: __repr__() Debug representation of a task. .. py:method:: __setstate__(state) Take object from parameter and use it to retrieve class state. .. py:method:: _deduce_package_dir(filepath, content) :staticmethod: Deduce the package directory from the filepath and the content of the task. A task is always stored in /.json. The package_dir is the directory; the task.id may also contain subdirectories / namespacing denoted with "/". :param filepath: The path to the task file :param content: The content of the task file return: The package directory that all file keys in content are relative to. .. py:method:: add_obstacle(obstacle) Adds an obstacle to the existing task. :param obstacle: Any obstacle derived from the Obstacle class. This can contain a single geometry or compositions of such. .. py:property:: base_constraint :type: timor.task.Constraints.BasePlacement Returns the base constraint of this task. :raise: AttributeError if not BasePlacement Constraint given. .. py:property:: collision_objects :type: Tuple[hppfcl.hppfcl.CollisionObject, Ellipsis] All hppfcl collision objects by obstacles in the task .. py:attribute:: constraints :type: Tuple[timor.task.Constraints.ConstraintBase] .. py:method:: empty() :classmethod: Returns an empty task with an empty header .. py:attribute:: frames :value: None .. py:method:: from_id(id, package_dir) :classmethod: Load a task based on its id stored in package_dir/id.json. :param id: id (including namespace with "/" to look for. :param package_dir: The directory to look for the task in. .. py:method:: from_json_data(d, *args, **kwargs) :classmethod: Loads a task from a parsed json (=dictionary). :param d: The parsed json data .. py:method:: from_json_file(filepath, *args, **kwargs) :classmethod: Factory method to load a class instance from a json file. :param filepath: The path to the json file. :param args: Additional arguments to pass to the from_json_data factory method of the specific class. :param kwargs: Additional arguments to pass to the from_json_data factory method of the specific class. .. py:method:: from_json_string(s, *args, **kwargs) :classmethod: Create from a json string. .. py:method:: from_srf_file(filepath) :staticmethod: :abstractmethod: Future Work .. py:attribute:: goals :type: Tuple[timor.task.Goals.GoalBase] :value: () .. py:property:: goals_by_id :type: Dict[str, timor.task.Goals.GoalBase] Return a mapping from all goal ID's to their python instances .. py:attribute:: header .. py:property:: id :type: str The unique ID of the task .. py:property:: name :type: str Returns the task ID, use not recommended .. py:property:: obstacle_names :type: Tuple[str, Ellipsis] Returns the names of all obstacles in the task .. py:attribute:: obstacles :type: List[timor.task.Obstacle.Obstacle] :value: [] .. py:method:: to_json_data() Returns the serialized task dictionary .. py:method:: to_json_file(save_at, handle_missing_assets = None, *args, **kwargs) Save the task to a json file. :param save_at: The path to save the task to. If it is a directory, the task will be saved to save_at/.json. If it is a file, the task will be saved to save_at and it is ensured that the filename ends in .json. :param handle_missing_assets: How to handle missing assets. See :meth:`timor.utilities.helper.handle_assets` for details. .. py:method:: to_json_string() Return the json string representation. .. py:method:: visualize(viz = None, robots = None, show_obstacle = True, show_goals = True, show_constraints = True, show_frames = False, show_names = False, center_view = True) Plots the task in a Meshcat visualizer. Calls the "visualize" function for each Object, Robot, Goal and Constraint in the task. As Objects are the high-level representation of "things" in the Environment, this visualization function uses their high-level plotting functionalities, so visual meshes etc. will be chosen if available. :param viz: MeshcatViusalizer to work in; default: create new one :param robots: Robots to be visualized :param show_obstacle: bool to turn on obstacle rendering (default true) :param show_goals: bool to turn on goal rendering (default true) :param show_constraints: bool to turn on constraint rendering for those that can be displayed (default true) :param show_frames: bool to turn on frame rendering (default true) :param show_names: bool to turn on name rendering, e.g., for goals (default false) :param center_view: if set to true try to find a reasonable camera position such that task visible, i.e. try to center camera on the first robot's base and if that is not set try to center the base constraint pose. .. py:class:: TaskHeader .. autoapi-inheritance-diagram:: timor.task.Task.TaskHeader :parts: 1 :private-bases: The header every task contains .. py:attribute:: ID :type: str .. py:method:: __delattr__(item) Delete attribute .. py:method:: __eq__(other) Equality of headers is given by equality of attributes .. py:method:: __post_init__() Post init function that ensures the correct datatypes .. py:method:: __setattr__(key, value) Sets an attribute of this class .. py:method:: _raise_immutable(f) Raises error if objects in this dataclass are to be resetted but the instance is set to immutable .. py:attribute:: affiliation :type: List[str] .. py:method:: asdict() Returns a dictionary representation of this object .. py:attribute:: author :type: List[str] .. py:method:: cast(value, cast_to_type) :staticmethod: Casts the value to the dtype .. py:method:: cast_to_date(value) :staticmethod: Casts the value to a datetime.date object .. py:attribute:: date :type: datetime.date .. py:attribute:: email :type: List[str] .. py:method:: empty() :classmethod: Returns an empty task header .. py:method:: fields() :classmethod: Returns the fields of this class .. py:attribute:: gravity :type: numpy.ndarray .. py:method:: string_list_factory() :staticmethod: Returns a field with a default factory that returns a list with one empty string .. py:attribute:: tags :type: List :value: [] .. py:attribute:: taskName :type: str :value: '' .. py:attribute:: timeStepSize :type: float :value: 0.01 .. py:attribute:: version :type: str :value: '2023' .. py:data:: robot_or_robots