timor.Module ============ .. py:module:: timor.Module Attributes ---------- .. autoapisummary:: timor.Module.RobotConvertible Classes ------- .. autoapisummary:: timor.Module.AtomicModule timor.Module.ModuleAssembly timor.Module.ModuleBase timor.Module.ModuleHeader timor.Module.ModulesDB Functions --------- .. autoapisummary:: timor.Module.robot_from_convertible Module Contents --------------- .. py:class:: AtomicModule(header, bodies = (), joints = ()) .. autoapi-inheritance-diagram:: timor.Module.AtomicModule :parts: 1 :private-bases: Atomic Modules are the simplest module representation. They are static (immutable) and can be (de)serialized. Overwrites the default constructor for more precise type hints .. py:method:: __copy__() Deactivates the builtin copy method. .. py:method:: __eq__(other) Equality check for modules. Two modules are equal if they have the same header, bodies, names, and joints. .. py:method:: __getstate__() Return objects which will be pickled and saved. .. py:method:: __hash__() Custom hash function for modules that should be uniquely determined by their ID. .. py:method:: __setstate__(state) Take object from parameter and use it to retrieve class state. .. py:attribute:: __slots__ :value: () .. py:method:: __str__() String representation for the module. .. py:attribute:: _bodies :type: timor.Bodies.BodySet .. py:method:: _check_unique_connectors() Sanity check that all connectors are unique .. py:method:: _deduce_package_dir(filepath, content) :staticmethod: Logic for deducing the package directory if the JSONable object is loaded from a file. :param filepath: The path to the file. :param content: The content of the file parsed into a dictionary. :note: This method can be overridden by subclasses to provide custom package directory resolution; e.g. Task.py. .. py:attribute:: _joints :type: timor.Joints.JointSet .. py:attribute:: _module_graph :type: networkx.DiGraph .. py:property:: available_connectors :type: Dict[Tuple[str, str, str], timor.Bodies.Connector] Returns all connectors of all bodies contained in this module as a mapping ID -> instance .. py:property:: bodies :type: timor.Bodies.BodySet Returns all bodies contained in this module. .. py:method:: build_module_graph() Builds the directed graph of atomic module elements. See module_graph property for more information. .. py:method:: can_connect(other) Returns true if at least one of the connectors of this module matches at least one connector of other .. py:property:: connectors_by_own_id :type: Dict[str, timor.Bodies.Connector] Returns a mapping of connector._id values to the instance. Keep in mind, these are not the composed id's of the connectors, so they are not unambiguous outside a module! .. py:method:: copy(suffix) Copies a module, but changes the id of the copy. :param suffix: Suffix to add to the copies' id. Necessary, to distinguish original and copy :return: A functional copy of this module with altered ID .. py:method:: debug_visualization(viz = None, show_com = True, base_placement = Transformation.neutral()) Do not use this method in proper environment visualizations :param viz: MeshcatVisualizer to show debug information in :param show_com: show center of mass frame :param base_placement: where to show this module in the global frame :return: visualizer object (keep if you want to add more to this) .. py:method:: from_concert_specification(d, package_dir) :classmethod: Maps a concert-module description to an instance of this class. This library was developed in the context of the EU sponsored CONCERT project. For more information visit https://concertproject.eu/ The concert module definition closely follows the Timor one. However, in the concert project, we only deal with "serial", "chain-like" robots and monodirectional modules. For the sake of simplicity (makes implementation for partners easier), proximal (here: female) connectors are pointing INSIDE the module. To work in the more general case this toolbox is dealing with, they have to be "turned to the outside". Furthermore, CONCERT defines child geometries relative to joint frames, while we would define them relative to their body frames (for CONCERT, the "body" frame always aligns with the connector frame). Therefore, geometry placements after joints need to be offset. :param package_dir: Package directory relative to which mesh file paths are defined :param d: A dictionary with relevant meta-information :return: An instantiated module and a color for visualization .. py:method:: from_json_data(d, package_dir = None, **kwargs) :classmethod: Maps the json module description to an instance of this class. The dictionary will be modified in-place until empty (everything was parsed). :param package_dir: Package directory relative to which mesh file paths are defined :param d: A dictionary with relevant meta-information :return: An instantiated module .. 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) :classmethod: Maps the json module string to an instance of this class. :param s: A json string with relevant meta-information :return: An instantiated module .. py:method:: from_monolithic_robot(robot) :classmethod: Wraps a kinematic/dynamic robot model into a single module. :param robot: A pinocchio robot model to be wrapped. :returns: The robot, wrapped in a single atomic module. .. py:attribute:: header :type: ModuleHeader .. py:property:: id :type: str The unique ID of this module. .. py:property:: joints :type: timor.Joints.JointSet Returns all joints contained in this module .. py:property:: mass :type: float Returns the total mass of the module. .. py:property:: module_graph :type: networkx.DiGraph Returns a graph with nodes that can either be joints, bodies or connectors. Each element in the module graph belongs to one body, joint or connector. The edges define child-parent relationships between the elements. Every edge has a transform property, describing the relative transformation from one element's reference frame to another element's reference frame. The edges are directed and anti-parallel, s.t. for every edge between two nodes (u, v), there exists an edge between (v, u) for which the transform attribute is the inverse of the first edge's transform. .. py:property:: name :type: str Returns the unique name of this module. .. py:property:: num_bodies The number of bodies in this module. .. py:property:: num_connectors The number of connectors available in the module. .. py:property:: num_joints The number of joints in this module .. py:method:: to_json_data() Write a json in that fully describes this module. :return: Returns the module specification in a json-ready dictionary .. py:method:: to_json_file(save_at, *args, **kwargs) Writes the instance to a json file. :param save_at: File location or folder to write the class to. .. py:method:: to_json_string() Return the json string representation. .. py:class:: ModuleAssembly(database, assembly_modules = (), connections = (), base_connector = None, **model_generation_kwargs) .. autoapi-inheritance-diagram:: timor.Module.ModuleAssembly :parts: 1 :private-bases: A combination of modules with defined connections between each another. Represents a high-level abstraction to a robot and provides an interface to the kinematic model. A combination of modules, drawn from a common module database and arranged by defined connections. :param database: A ModulesDB instance holding all relevant modules for the assembly :param assembly_modules: This list defines which modules are within the assembly and also defines their index position when referencing single modules. This list holds module IDs, but opposed to a ModuleSet, IDs can be present multiple times. (Read: If multiple copies of the conceptually same module should be used in an assembly) The order itself is arbitrary (but will be used for further referencing), but in case of tree- or chain-like assemblies, it is recommended to provide the ID's in the order of the kinematic chain. :param connections: Defines how the modules are connected to each other. Each connection consists of a tuple that specifies (module_a, c_a, module_b, c_b), where c_a and c_b are the connectors used for the connection between modules module_a and module_b. Connectors can either be provided as instance reference or via ID. Modules should be provided as indices of the module_instances list. :param base_connector: For every assembly, there must be a 'base' connector that indicates where the base of the robot coordinate system is. If it is not explicitly given, there must be exactly one connector of type 'base' in the assembly. The base connector argument is expected to be of type [module_idx, connector._id] :param model_generation_kwargs: Additional arguments passed to the generating method for the kinematic/dynamic model of the assembly. .. py:method:: __eq__(other) Two assemblies are basically equal when they describe the same robot with equal modules. Equality is given by equal connections (which implies equal connectors and modules) and equal kwargs for the model generation: This means that equal assemblies must not necessarily be constructed from modules coming from the same DB. However, all modules must be equal and the resulting robots must have the same kinematic, dynamic, and geometric properties. .. py:method:: __getstate__() Used for pickling .. py:method:: __hash__() Hash is based on the connections, as they are the defining property of an assembly. .. py:method:: __setstate__(state) Used for pickling .. py:method:: _add_module(module_id, set_base = False) Takes modules from a database and ensures duplicate module_ids do not lead to identical module instances. The added module is not connected - use self.add() method to properly add a new module from outside this class :param module_id: The module id - the right instance will be drawn from the internal db :param set_base: Needs to be set if the first module is added externally to an empty assembly. :return: Returns the module index (as in the internal module order) .. py:method:: _assert_is_valid() Sanity checks to ensure the assembly has a unique and well-defined meaning .. py:attribute:: _base_connector :value: None .. py:method:: _deduce_package_dir(filepath, content) :staticmethod: Logic for deducing the package directory if the JSONable object is loaded from a file. :param filepath: The path to the file. :param content: The content of the file parsed into a dictionary. :note: This method can be overridden by subclasses to provide custom package directory resolution; e.g. Task.py. .. py:method:: _deterministic_connections() Returns the connections in a deterministic order, so that the assembly can be hashed and compared. .. py:attribute:: _module_copies :type: Dict[str, str] .. py:attribute:: _robot :type: timor.utilities.dtypes.Lazy[timor.Robot.PinRobot] .. py:attribute:: _robot_kwargs .. py:method:: add(new, new_connector, to, to_connector) Add a new module to the assembly. Works with ``add(*connection)``. :param new: The new module to add :param new_connector: The connector's own id to use in the new connection :param to: The module to add the module to :param to_connector: The connectors own id in module "to" that is used for the connection. Alternatively, the full connector id. :return: new_module_index .. py:method:: add_random_from_db(db_filter = None) Adds a random module from the database to this assembly :param db_filter: If provided, only modules that fulfill the filter function will be taken into consideration :return: See add() .. py:property:: adjacency_matrix :type: numpy.ndarray Returns the adjacency matrix for the assembly graph. Assumes every module is a node and links are tuples of connectors (as defined in self.connections). This method assumes undirected edges and no self-loops. :return: An NxN matrix, where N=#modules and A(i, j)=#connections between i and j .. py:property:: assembly_graph :type: networkx.DiGraph Returns a networkx graph representing the internal modules in the assembly on a body, connector and joint level. Nodes represent either of (body, joint, connector) while the directed edges define child-parent relations between them with their edge properties containing information about the relative transformation from one of the objects to another. .. py:property:: base_connector :type: timor.Bodies.Connector The first body in the kinematic chain of the robot .. py:property:: base_module :type: ModuleBase Returns the base module. .. py:attribute:: connection_type .. py:attribute:: connections :type: Set[Tuple[ModuleBase, timor.Bodies.Connector, ModuleBase, timor.Bodies.Connector]] .. py:method:: connections_between(mod_a, mod_b) Returns all connections that exist between module mod_a and module mod_b. :note: as connections are bidirectional, connections_between(a, b) == connections_between(b, a). :param mod_a: Either a module reference or the index of the module :param mod_b: Either a module reference or the index of the module :return: A set (so, unordered) of connections between the two modules .. py:attribute:: db :type: ModulesDB .. py:method:: empty() :classmethod: Creates an empty assembly built from an emtpy database .. py:method:: export_to_trimesh() Return a trimesh scene of this assembly in the configuration of the underlying robot. .. py:property:: free_connectors :type: Dict[Tuple[str, str, str], timor.Bodies.Connector] Returns a dict of all connectors in the Assembly that are not connected currently .. py:method:: from_json_data(d, module_db = None, *args, **kwargs) :classmethod: Create an assembly from description found in serialized solutions. :param d: dictionary with keys from solution that allow to reconstruct a module assembly. Always needs moduleSet field if no additional module_db given. Always needs moduleOrder. Supported combinations: - no moduleConnection: fallback linear assembly along moduleOrder; baseConnection deduced implicitly - no/empty baseConnection: try to build assembly and see if there is unique base connector left - default: moduleOrder + moduleConnection + baseConnection :param module_db: Optional db if generated adhoc or to recycle already loaded :param kwargs: * reload_DB: reload DB from file if already loaded (default), otherwise use existing in cache .. 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_monolithic_robot(robot) :classmethod: Wraps a robot model into an assembly that contains exactly one module (~the robot). Using this method is faster than using the Assembly constructor after creating the module from the robot manually, as the robot model is not re-evaluated. Furthermore, this method adds a base connector to the module, if not existent yet. The base placement of the robot will get lost if it is re-created from this assembly. :param robot: A pinocchio robot model to be wrapped. :returns: The robot, wrapped in a single atomic module which composes the assembly. .. py:method:: from_serial_modules(db, module_chain, **model_generation_kwargs) :classmethod: This function works on the assumption that the assembly modules are arranged in a chain. :param db: The database used to build the assembly :param module_chain: The series of modules in the assembly, referring to the module ids in the db. :param model_generation_kwargs: Additional arguments passed to the generating method for the kinematic/dynamic model of the assembly. .. py:property:: graph_of_modules :type: networkx.Graph The graph of modules represents all modules in an assembly and how they are connected to each other. Returns a networkx graph object with a node for every module in the assembly and connections for every connector-connector pair defined by one of the assemblies connections. Not to be confused with the module_graph (a graph depicting the structure of the elements within a single module), nor the assembly_graph (a more verbose variant of the graph_of_modules, where instead of module nodes, every module is represented by its module_graph) .. py:property:: internal_module_ids :type: Tuple[str] Returns the module IDs for the Assemblies Modules the way they are stored internally :note: this might differ significantly from the IDs in the db! .. py:property:: mass :type: float The total mass of the assembly .. py:attribute:: module_instances :type: List[ModuleBase] :value: [] .. py:property:: nJoints :type: int The number of joints in the assembly .. py:property:: nModules :type: int The number of modules in the assembly .. py:property:: original_module_ids :type: Tuple[str, Ellipsis] Returns the module base / type ID for each module in this assembly in order of internal_module_ids .. py:method:: plot_graph() Draws the assembly graph. .. py:property:: robot :type: timor.Robot.PinRobot Returns the robot model for this assembly. This property always contains the most up-to-date robot model, so if the assembly changes in between calls, the return will as well. Opposed to the ModuleAssembly itself, the model returned can be used to perform kinematic and dynamic calculations. Be aware that a call to this explicitly creates the robot model of not done so before. Compared to modelling an assembly, this is an expensive operation. (couple of ms for a standard 6-10 module, industrial robot) .. py:method:: to_json_data() Creates jsonable dictionary that serializes this assembly. :return: A dictionary that serializes this assembly .. py:method:: to_json_file(save_at, *args, **kwargs) Writes the instance to a json file. :param save_at: File location or folder to write the class to. .. py:method:: to_json_string() Return the json string representation. .. py:method:: to_pin_robot(base_placement = Transformation.neutral(), add_com_frames = False, ignore_collisions = 'via_joint') Creates a pinocchio robot from a module tree :param base_placement: Relative placement of the base in the world frame -- attention! This is not the placement for the "base connector" which is pointing "away" from the base, but it is the base connector placement rotated by 180° degrees around its x-axis. This way, an identity "base placement" (for the typical DB) corresponds to a base standing upright on the ground, centered in (0, 0, 0). :param add_com_frames: Add frames for the center of mass of each Body :param ignore_collisions: Should be one of 'rigid', 'via_joint' or 'rigid_via_joint'. This argument defines, which pairs of bodies of the robot are IGNORED when checking for collisions. All possible collision pairs that are not explicitly ignored will be checked for - the following list provides details: * rigid: All bodies can collide as long as they are not rigidly connected * via_joint: Two bodies that are directly connected by a joint cannot collide * rigid_via_joint: Only bodies with 2 or more joints in between them can collide - in other words: Any number of body-connector pairs can form a rigid connection. Rigid connections that are directly connected by a joint can not collide :return: pinocchio robot for this assembly .. py:method:: to_urdf(name = None, write_to = None, replace_wrl = False, handle_missing_assets = None) Creates a URDF file from the assembly. :param name: name to be given to robot inside URDF :param write_to: output URDF file :param replace_wrl: Whether to replace wrl geometries with visual geometry (if available). :param handle_missing_assets: How to handle missing assets in package (parent of write_to). See :meth:`timor.utilities.helper.handle_assets` for details. .. py:class:: ModuleBase(header, bodies = (), joints = ()) .. autoapi-inheritance-diagram:: timor.Module.ModuleBase :parts: 1 :private-bases: Base class for any robot module. A single module, the basic building block of a modular robot. :param header: The header of the module containing distinct meta-information :param bodies: The bodies contained in the module - defaults to none. :param joints: The joints contained in the module - defaults to none. The parent and child bodies must be provided for each joint. .. py:method:: __copy__() :abstractmethod: Disable builtin copy, there should be no use case for two instances of a module with the same ID. .. py:method:: __eq__(other) Equality check for modules. Two modules are equal if they have the same header, bodies, names, and joints. .. py:method:: __getstate__() Return objects which will be pickled and saved. .. py:method:: __hash__() Custom hash function for modules that should be uniquely determined by their ID. .. py:method:: __setstate__(state) Take object from parameter and use it to retrieve class state. .. py:attribute:: __slots__ :value: () .. py:method:: __str__() String representation for the module. .. py:attribute:: _bodies :type: timor.Bodies.BodySet .. py:method:: _check_unique_connectors() Sanity check that all connectors are unique .. py:method:: _deduce_package_dir(filepath, content) :staticmethod: Logic for deducing the package directory if the JSONable object is loaded from a file. :param filepath: The path to the file. :param content: The content of the file parsed into a dictionary. :note: This method can be overridden by subclasses to provide custom package directory resolution; e.g. Task.py. .. py:attribute:: _joints :type: timor.Joints.JointSet .. py:attribute:: _module_graph :type: networkx.DiGraph .. py:property:: available_connectors :type: Dict[Tuple[str, str, str], timor.Bodies.Connector] Returns all connectors of all bodies contained in this module as a mapping ID -> instance .. py:property:: bodies :type: timor.Bodies.BodySet Returns all bodies contained in this module. .. py:method:: build_module_graph() Builds the directed graph of atomic module elements. See module_graph property for more information. .. py:method:: can_connect(other) Returns true if at least one of the connectors of this module matches at least one connector of other .. py:property:: connectors_by_own_id :type: Dict[str, timor.Bodies.Connector] Returns a mapping of connector._id values to the instance. Keep in mind, these are not the composed id's of the connectors, so they are not unambiguous outside a module! .. py:method:: copy(suffix) Copies a module, but changes the id of the copy. :param suffix: Suffix to add to the copies' id. Necessary, to distinguish original and copy :return: A functional copy of this module with altered ID .. py:method:: debug_visualization(viz = None, show_com = True, base_placement = Transformation.neutral()) Do not use this method in proper environment visualizations :param viz: MeshcatVisualizer to show debug information in :param show_com: show center of mass frame :param base_placement: where to show this module in the global frame :return: visualizer object (keep if you want to add more to this) .. py:method:: from_json_data(d, *args, **kwargs) :classmethod: Create from a json description. .. 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:attribute:: header :type: ModuleHeader .. py:property:: id :type: str The unique ID of this module. .. py:property:: joints :type: timor.Joints.JointSet Returns all joints contained in this module .. py:property:: mass :type: float Returns the total mass of the module. .. py:property:: module_graph :type: networkx.DiGraph Returns a graph with nodes that can either be joints, bodies or connectors. Each element in the module graph belongs to one body, joint or connector. The edges define child-parent relationships between the elements. Every edge has a transform property, describing the relative transformation from one element's reference frame to another element's reference frame. The edges are directed and anti-parallel, s.t. for every edge between two nodes (u, v), there exists an edge between (v, u) for which the transform attribute is the inverse of the first edge's transform. .. py:property:: name :type: str Returns the unique name of this module. .. py:property:: num_bodies The number of bodies in this module. .. py:property:: num_connectors The number of connectors available in the module. .. py:property:: num_joints The number of joints in this module .. py:method:: to_json_data() Write a json in that fully describes this module. :return: Returns the module specification in a json-ready dictionary .. py:method:: to_json_file(save_at, *args, **kwargs) Writes the instance to a json file. :param save_at: File location or folder to write the class to. .. py:method:: to_json_string() Return the json string representation. .. py:class:: ModuleHeader .. autoapi-inheritance-diagram:: timor.Module.ModuleHeader :parts: 1 :private-bases: The header every module contains .. py:attribute:: ID :type: str .. py:method:: __delattr__(item) Delete attribute .. py:method:: __hash__() Hash the header by hashing the unique ID and name. .. 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:: cost :type: float :value: 0.0 .. py:attribute:: date :type: datetime.date .. py:attribute:: email :type: List[str] .. py:method:: fields() :classmethod: Returns the fields of this class .. py:attribute:: name :type: str .. py:method:: string_list_factory() :staticmethod: Returns a field with a default factory that returns a list with one empty string .. py:class:: ModulesDB(*modules, name = None, **model_generation_kwargs) .. autoapi-inheritance-diagram:: timor.Module.ModulesDB :parts: 1 :private-bases: A Database of Modules. The inheritance from SingleSet ensures no duplicates are within one DB. Also, this means this class offers many useful methods inherited from Set, such as add() and update(). This class provides safety regarding uniqueness of module, joint, body and connector IDs, but this comes at a price. Adding and removing elements can be expensive with growing modules. This class is not intended to be changed much, after being instantiated! Initializes the database from any number of modules. :param modules: Any iterable over modules to be within the database :param name: Optional name of the database, i.e. for referencing them in the CoBRA API :param model_generation_kwargs: Key-word arguments to pass to the robot model generation; esp. for setting ignore_collisions :source: Get selected ModulesDBs using the API: https://cobra.cps.cit.tum.de/api/robots .. py:method:: __contains__(item) If a new module should be added to a Module DB, the following properties must be preserved: (All of the below holds for modules and their sub-modules and their sub-sub-modules, and... to keep it short, all of those are just described as "modules") * All module IDs in the DB are unique * All module names in the DB are unique * All JointIDs in the DB are unique * All BodyIDs in the DB are unique * All ConnectorIDs in the DB are unique :param item: A module :return: Boolean indicator whether the module OR ANY OF THE INHERENT IDs are already in the DB .. py:method:: __eq__(other) Two DBs are equal if they contain the same modules, have the same name, and generate the same robot model. .. py:method:: __hash__() Hash all the contained elements .. py:method:: __ne__(other) Override the not equal operatorof a set .. py:method:: __setstate__(state) Overwrite jsonable; most is handled by __reduce__ and python internal set just need to set helper properties. .. py:attribute:: _db_cache :type: Dict[str, ModulesDB] .. py:method:: _deduce_package_dir(filepath, content) :staticmethod: Logic for deducing the package directory if the JSONable object is loaded from a file. :param filepath: The path to the file. :param content: The content of the file parsed into a dictionary. :note: This method can be overridden by subclasses to provide custom package directory resolution; e.g. Task.py. .. py:attribute:: _err :value: 'Element {} already present!' .. py:attribute:: _model_generation_kwargs :type: dict[str, Any] .. py:attribute:: _name :type: Optional[str] .. py:method:: _sorting_key(element) :classmethod: :abstractmethod: Key function for sorting elements in this set .. py:method:: add(element) As the connector ID is composed of (module ID, body ID, connector ID), we need an additional check, we don't want two allow two connectors with same names in a module, even if attached to different bodies. .. py:property:: all_bodies :type: timor.Bodies.BodySet All bodies in all modules in the DB .. py:property:: all_connector_own_ids :type: Set[str] :abstractmethod: All local connector ids in the DB (not full connector IDs, which would consist of [module, body, connectorID]) .. py:property:: all_connectors :type: timor.Bodies.ConnectorSet All connectors of all bodies of all modules in the DB .. py:property:: all_connectors_by_id :type: Dict[Tuple[str, str, str], timor.Bodies.Connector] All complete connector IDs in the DB (counter piece to all_connector_own_ids, which is basically a subset) .. py:property:: all_joints :type: timor.Joints.JointSet All joints in all modules in the DB .. py:property:: all_module_ids :type: Set[str] All IDs of modules in the DB .. py:property:: all_module_names :type: Set[str] All names of modules in the DB .. py:property:: bases :type: ModulesDB[ModuleBase] Returns all modules containing at least one base connector .. py:property:: by_id :type: Dict[str, ModuleBase] Returns this DB as a dictionary, mapping the Module ID to the module .. py:property:: by_name :type: Dict[str, ModuleBase] Returns this DB as a dictionary, mapping the Module Name to the module .. py:attribute:: connection_type .. py:property:: connectivity_graph :type: networkx.MultiDiGraph Returns a graph of all possible module connections in the db. :return: A directed graph with anti-parallel edges for each possible connection. Multiple edges between two are possible (in fact, they will almost certainly exist for standard module sets). .. py:method:: copy() Custom copy should also return a SingleSet .. py:method:: debug_visualization(viz = None, stride = 1) Show debug visualization of all contained modules (show them in a square array) :param viz: MeshcatVisualizer to use :param stride: Distance between the plotted modules in meters (default: 1m) :return: MeshcatVisualizer used .. py:property:: default_model_generation_kwargs A default set of model generation kwargs to use with this modules db. .. py:property:: end_effectors :type: ModulesDB[ModuleBase] Returns all modules containing at least one eef connector .. py:method:: filter(func) Apply a custom filter to this DB to get a new DB with only the modules that pass the filter. :param func: A function that takes a module and returns a boolean :return: A new DB with only the modules that pass the filter. The name is intentionally discarded to avoid confusion. .. py:method:: find_modules_with_same_connectors(module) Serves as a helper function for the mutation operation. Find all modules that can potentially replace the module given. In order to do so, we look for modules with the same connectors regarding its type, size and gender, including itself. :param module: The module for which we are looking for replacement candidates. .. py:method:: from_json_data(data, name = None, validate = True, *args, **kwargs) :classmethod: Loads a modules Database from a json string. :param data: Set of dicts describing the individual modules in the DB. :param name: Referencing name for the database :param validate: Whether to validate the data against the module schema :return: A ModulesDB .. py:method:: from_json_file(filepath, *args, **kwargs) :classmethod: Loads a modules Database from a json file. :param filepath: Path to the json file :return: The loaded ModulesDB .. py:method:: from_json_string(s, *args, **kwargs) :classmethod: Create from a json string. .. py:method:: from_name(module_db_name, reload = True) :classmethod: Create module DB from name of a module DB configured as loadable robot in timor.config :param module_db_name: Name of the module DB to load :param reload: If True, the DB will be reloaded from file, even if it was already loaded .. py:method:: intersection(*s) Intersection should also retutrn a SingleSet .. py:property:: name :type: str Return name of module db as given in the CoBRA API .. py:property:: possible_connections :type: Set[ModulesDB] Returns a set of all possible connections in this db. As connections are symmetric, only one copy of {(A, c_a) --> (B, c_b), (B, c_b) --> (A, c_a)} will be returned. .. py:method:: to_json_data() Turn modulesDB into jsonable dict. :return: The jsonable data. .. py:method:: to_json_file(save_at, *args, **kwargs) Writes the ModulesDB to a json file. :param save_at: File location or folder to write the DB to. .. py:method:: to_json_string() Return the json string representation. .. py:method:: union(*s) Returns a SingleSet of the union of this and the input .. py:method:: update(*s) Update method that does not change this instance if the input iterable contains duplicates .. py:data:: RobotConvertible .. py:function:: robot_from_convertible(robot) Map a robot convertible to a RobotBase instance