timor.Module
Attributes
Classes
Atomic Modules are the simplest module representation. They are static (immutable) and can be (de)serialized. |
|
A combination of modules with defined connections between each another. |
|
Base class for any robot module. |
|
The header every module contains |
|
A Database of Modules. The inheritance from SingleSet ensures no duplicates are within one DB. |
Functions
|
Map a robot convertible to a RobotBase instance |
Module Contents
- class timor.Module.AtomicModule(header, bodies=(), joints=())

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
- Parameters:
header (Union[Dict, ModuleHeader])
bodies (Iterable[timor.Bodies.Body])
joints (Iterable[timor.Joints.Joint])
- __copy__()
Deactivates the builtin copy method.
- __eq__(other)
Equality check for modules. Two modules are equal if they have the same header, bodies, names, and joints.
- __getstate__()
Return objects which will be pickled and saved.
- __hash__()
Custom hash function for modules that should be uniquely determined by their ID.
- __setstate__(state)
Take object from parameter and use it to retrieve class state.
- __slots__ = ()
- __str__()
String representation for the module.
- _bodies: timor.Bodies.BodySet
- _check_unique_connectors()
Sanity check that all connectors are unique
- static _deduce_package_dir(filepath, content)
Logic for deducing the package directory if the JSONable object is loaded from a file.
- Parameters:
filepath (pathlib.Path) – The path to the file.
content (Union[Dict, List]) – 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.
- Return type:
- _joints: timor.Joints.JointSet
- _module_graph: networkx.DiGraph
- property available_connectors: Dict[Tuple[str, str, str], timor.Bodies.Connector]
Returns all connectors of all bodies contained in this module as a mapping ID -> instance
- Return type:
Dict[Tuple[str, str, str], timor.Bodies.Connector]
- property bodies: timor.Bodies.BodySet
Returns all bodies contained in this module.
- Return type:
- build_module_graph()
Builds the directed graph of atomic module elements. See module_graph property for more information.
- Return type:
networkx.DiGraph
- can_connect(other)
Returns true if at least one of the connectors of this module matches at least one connector of other
- Parameters:
other (ModuleBase)
- Return type:
- property connectors_by_own_id: 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!
- Return type:
Dict[str, timor.Bodies.Connector]
- copy(suffix)
Copies a module, but changes the id of the copy.
- Parameters:
suffix (str) – Suffix to add to the copies’ id. Necessary, to distinguish original and copy
- Returns:
A functional copy of this module with altered ID
- Return type:
- debug_visualization(viz=None, show_com=True, base_placement=Transformation.neutral())
Do not use this method in proper environment visualizations
- Parameters:
viz (pinocchio.visualize.MeshcatVisualizer) – MeshcatVisualizer to show debug information in
show_com (bool) – show center of mass frame
base_placement (numpy.array) – where to show this module in the global frame
- Returns:
visualizer object (keep if you want to add more to this)
- Return type:
pinocchio.visualize.MeshcatVisualizer
- classmethod from_concert_specification(d, package_dir)
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.
- Parameters:
package_dir (pathlib.Path) – Package directory relative to which mesh file paths are defined
d (Dict[str, any]) – A dictionary with relevant meta-information
- Returns:
An instantiated module and a color for visualization
- Return type:
Tuple[AtomicModule, numpy.ndarray]
- classmethod from_json_data(d, package_dir=None, **kwargs)
Maps the json module description to an instance of this class.
The dictionary will be modified in-place until empty (everything was parsed).
- Parameters:
package_dir (Optional[pathlib.Path]) – Package directory relative to which mesh file paths are defined
d (Dict) – A dictionary with relevant meta-information
- Returns:
An instantiated module
- Return type:
- classmethod from_json_file(filepath, *args, **kwargs)
Factory method to load a class instance from a json file.
- Parameters:
filepath (Union[pathlib.Path, str]) – The path to the json file.
args – Additional arguments to pass to the from_json_data factory method of the specific class.
kwargs – Additional arguments to pass to the from_json_data factory method of the specific class.
- classmethod from_json_string(s)
Maps the json module string to an instance of this class.
- Parameters:
s (str) – A json string with relevant meta-information
- Returns:
An instantiated module
- Return type:
- classmethod from_monolithic_robot(robot)
Wraps a kinematic/dynamic robot model into a single module.
- Parameters:
robot (timor.Robot.PinRobot) – A pinocchio robot model to be wrapped.
- Returns:
The robot, wrapped in a single atomic module.
- Return type:
- header: ModuleHeader
- property joints: timor.Joints.JointSet
Returns all joints contained in this module
- Return type:
- property module_graph: 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.
- Return type:
networkx.DiGraph
- property num_bodies
The number of bodies in this module.
- property num_connectors
The number of connectors available in the module.
- property num_joints
The number of joints in this module
- to_json_data()
Write a json in that fully describes this module.
- Returns:
Returns the module specification in a json-ready dictionary
- Return type:
Dict
- to_json_file(save_at, *args, **kwargs)
Writes the instance to a json file.
- Parameters:
save_at (Union[pathlib.Path, str]) – File location or folder to write the class to.
- class timor.Module.ModuleAssembly(database, assembly_modules=(), connections=(), base_connector=None, **model_generation_kwargs)

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.
- Parameters:
database (ModulesDB) – A ModulesDB instance holding all relevant modules for the assembly
assembly_modules (Collection[str]) – 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.
connections (Collection[connection_type]) – 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.
base_connector (Tuple[int, str]) – 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]
model_generation_kwargs – Additional arguments passed to the generating method for the kinematic/dynamic model of the assembly.
- __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.
- __getstate__()
Used for pickling
- __hash__()
Hash is based on the connections, as they are the defining property of an assembly.
- __setstate__(state)
Used for pickling
- _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
- _assert_is_valid()
Sanity checks to ensure the assembly has a unique and well-defined meaning
- _base_connector = None
- static _deduce_package_dir(filepath, content)
Logic for deducing the package directory if the JSONable object is loaded from a file.
- Parameters:
filepath (pathlib.Path) – The path to the file.
content (Union[Dict, List]) – 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.
- Return type:
- _deterministic_connections()
Returns the connections in a deterministic order, so that the assembly can be hashed and compared.
- Return type:
Tuple[Tuple[ModuleBase, timor.Bodies.Connector, ModuleBase, timor.Bodies.Connector], Ellipsis]
- _robot_kwargs
- add(new, new_connector, to, to_connector)
Add a new module to the assembly. Works with
add(*connection).- Parameters:
new (ModuleBase) – The new module to add
new_connector (str) – The connector’s own id to use in the new connection
to (int) – The module to add the module to
to_connector (Union[str, Tuple[str, str, str]]) – The connectors own id in module “to” that is used for the connection. Alternatively, the full connector id.
- Returns:
new_module_index
- Return type:
- add_random_from_db(db_filter=None)
Adds a random module from the database to this assembly
- Parameters:
db_filter (Callable[[ModuleBase], bool]) – If provided, only modules that fulfill the filter function will be taken into consideration
- Returns:
See add()
- Return type:
- property adjacency_matrix: 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.
- Returns:
An NxN matrix, where N=#modules and A(i, j)=#connections between i and j
- Return type:
- property assembly_graph: 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.
- Return type:
networkx.DiGraph
- property base_connector: timor.Bodies.Connector
The first body in the kinematic chain of the robot
- Return type:
- property base_module: ModuleBase
Returns the base module.
- Return type:
- connection_type
- connections: Set[Tuple[ModuleBase, timor.Bodies.Connector, ModuleBase, timor.Bodies.Connector]]
- 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).
- Parameters:
- Returns:
A set (so, unordered) of connections between the two modules
- Return type:
Set[ModuleAssembly]
- classmethod empty()
Creates an empty assembly built from an emtpy database
- export_to_trimesh()
Return a trimesh scene of this assembly in the configuration of the underlying robot.
- Return type:
trimesh.scene.Scene
- property free_connectors: Dict[Tuple[str, str, str], timor.Bodies.Connector]
Returns a dict of all connectors in the Assembly that are not connected currently
- Return type:
Dict[Tuple[str, str, str], timor.Bodies.Connector]
- classmethod from_json_data(d, module_db=None, *args, **kwargs)
Create an assembly from description found in serialized solutions.
- Parameters:
d (Dict[str, any]) –
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
module_db (Optional[ModulesDB]) – Optional db if generated adhoc or to recycle already loaded
kwargs –
reload_DB: reload DB from file if already loaded (default), otherwise use existing in cache
- Return type:
- classmethod from_json_file(filepath, *args, **kwargs)
Factory method to load a class instance from a json file.
- Parameters:
filepath (Union[pathlib.Path, str]) – The path to the json file.
args – Additional arguments to pass to the from_json_data factory method of the specific class.
kwargs – Additional arguments to pass to the from_json_data factory method of the specific class.
- classmethod from_monolithic_robot(robot)
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.
- Parameters:
robot (timor.Robot.PinRobot) – A pinocchio robot model to be wrapped.
- Returns:
The robot, wrapped in a single atomic module which composes the assembly.
- Return type:
- classmethod from_serial_modules(db, module_chain, **model_generation_kwargs)
This function works on the assumption that the assembly modules are arranged in a chain.
- Parameters:
- Return type:
- property graph_of_modules: 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)
- Return type:
networkx.Graph
- property internal_module_ids: 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!
- Return type:
Tuple[str]
- module_instances: List[ModuleBase] = []
- property original_module_ids: Tuple[str, Ellipsis]
Returns the module base / type ID for each module in this assembly in order of internal_module_ids
- Return type:
Tuple[str, Ellipsis]
- plot_graph()
Draws the assembly graph.
- property robot: 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)
- Return type:
- to_json_data()
Creates jsonable dictionary that serializes this assembly.
- Returns:
A dictionary that serializes this assembly
- Return type:
Dict[str, any]
- to_json_file(save_at, *args, **kwargs)
Writes the instance to a json file.
- Parameters:
save_at (Union[pathlib.Path, str]) – File location or folder to write the class to.
- to_pin_robot(base_placement=Transformation.neutral(), add_com_frames=False, ignore_collisions='via_joint')
Creates a pinocchio robot from a module tree
- Parameters:
base_placement (timor.utilities.transformation.TransformationLike) – 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).
add_com_frames (bool) – Add frames for the center of mass of each Body
ignore_collisions (str) –
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
- Returns:
pinocchio robot for this assembly
- Return type:
- to_urdf(name=None, write_to=None, replace_wrl=False, handle_missing_assets=None)
Creates a URDF file from the assembly.
- Parameters:
name (str) – name to be given to robot inside URDF
write_to (Optional[pathlib.Path]) – output URDF file
replace_wrl (bool) – Whether to replace wrl geometries with visual geometry (if available).
handle_missing_assets (Optional[str]) – How to handle missing assets in package (parent of write_to). See
timor.utilities.helper.handle_assets()for details.
- Return type:
- class timor.Module.ModuleBase(header, bodies=(), joints=())

Base class for any robot module.
A single module, the basic building block of a modular robot.
- Parameters:
header (Union[Dict, ModuleHeader]) – The header of the module containing distinct meta-information
bodies (Iterable[timor.Bodies.BodyBase]) – The bodies contained in the module - defaults to none.
joints (Iterable[timor.Joints.Joint]) – The joints contained in the module - defaults to none. The parent and child bodies must be provided for each joint.
- abstractmethod __copy__()
Disable builtin copy, there should be no use case for two instances of a module with the same ID.
- __eq__(other)
Equality check for modules. Two modules are equal if they have the same header, bodies, names, and joints.
- __getstate__()
Return objects which will be pickled and saved.
- __hash__()
Custom hash function for modules that should be uniquely determined by their ID.
- __setstate__(state)
Take object from parameter and use it to retrieve class state.
- __slots__ = ()
- __str__()
String representation for the module.
- _bodies: timor.Bodies.BodySet
- _check_unique_connectors()
Sanity check that all connectors are unique
- static _deduce_package_dir(filepath, content)
Logic for deducing the package directory if the JSONable object is loaded from a file.
- Parameters:
filepath (pathlib.Path) – The path to the file.
content (Union[Dict, List]) – 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.
- Return type:
- _joints: timor.Joints.JointSet
- _module_graph: networkx.DiGraph
- property available_connectors: Dict[Tuple[str, str, str], timor.Bodies.Connector]
Returns all connectors of all bodies contained in this module as a mapping ID -> instance
- Return type:
Dict[Tuple[str, str, str], timor.Bodies.Connector]
- property bodies: timor.Bodies.BodySet
Returns all bodies contained in this module.
- Return type:
- build_module_graph()
Builds the directed graph of atomic module elements. See module_graph property for more information.
- Return type:
networkx.DiGraph
- can_connect(other)
Returns true if at least one of the connectors of this module matches at least one connector of other
- Parameters:
other (ModuleBase)
- Return type:
- property connectors_by_own_id: 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!
- Return type:
Dict[str, timor.Bodies.Connector]
- copy(suffix)
Copies a module, but changes the id of the copy.
- Parameters:
suffix (str) – Suffix to add to the copies’ id. Necessary, to distinguish original and copy
- Returns:
A functional copy of this module with altered ID
- Return type:
- debug_visualization(viz=None, show_com=True, base_placement=Transformation.neutral())
Do not use this method in proper environment visualizations
- Parameters:
viz (pinocchio.visualize.MeshcatVisualizer) – MeshcatVisualizer to show debug information in
show_com (bool) – show center of mass frame
base_placement (numpy.array) – where to show this module in the global frame
- Returns:
visualizer object (keep if you want to add more to this)
- Return type:
pinocchio.visualize.MeshcatVisualizer
- classmethod from_json_data(d, *args, **kwargs)
Create from a json description.
- Parameters:
d (Dict)
- classmethod from_json_file(filepath, *args, **kwargs)
Factory method to load a class instance from a json file.
- Parameters:
filepath (Union[pathlib.Path, str]) – The path to the json file.
args – Additional arguments to pass to the from_json_data factory method of the specific class.
kwargs – Additional arguments to pass to the from_json_data factory method of the specific class.
- header: ModuleHeader
- property joints: timor.Joints.JointSet
Returns all joints contained in this module
- Return type:
- property module_graph: 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.
- Return type:
networkx.DiGraph
- property num_bodies
The number of bodies in this module.
- property num_connectors
The number of connectors available in the module.
- property num_joints
The number of joints in this module
- to_json_data()
Write a json in that fully describes this module.
- Returns:
Returns the module specification in a json-ready dictionary
- Return type:
Dict
- to_json_file(save_at, *args, **kwargs)
Writes the instance to a json file.
- Parameters:
save_at (Union[pathlib.Path, str]) – File location or folder to write the class to.
- class timor.Module.ModuleHeader

The header every module contains
- __delattr__(item)
Delete attribute
- __hash__()
Hash the header by hashing the unique ID and name.
- __post_init__()
Post init function that ensures the correct datatypes
- __setattr__(key, value)
Sets an attribute of this class
- _raise_immutable(f)
Raises error if objects in this dataclass are to be resetted but the instance is set to immutable
- Parameters:
f (Callable)
- Return type:
Callable
- static cast(value, cast_to_type)
Casts the value to the dtype
- Parameters:
value (Any)
cast_to_type (Type)
- Return type:
Any
- static cast_to_date(value)
Casts the value to a datetime.date object
- Parameters:
value (Union[str, datetime.date, datetime.datetime])
- Return type:
- date: datetime.date
- static string_list_factory()
Returns a field with a default factory that returns a list with one empty string
- Return type:
dataclasses.field
- class timor.Module.ModulesDB(*modules, name=None, **model_generation_kwargs)

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.
- Parameters:
modules (Iterable[ModuleBase]) – Any iterable over modules to be within the database
name (Optional[str]) – Optional name of the database, i.e. for referencing them in the CoBRA API
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
- __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
- Parameters:
item (ModuleBase) – A module
- Returns:
Boolean indicator whether the module OR ANY OF THE INHERENT IDs are already in the DB
- Return type:
- __eq__(other)
Two DBs are equal if they contain the same modules, have the same name, and generate the same robot model.
- __hash__()
Hash all the contained elements
- __ne__(other)
Override the not equal operatorof a set
- __setstate__(state)
Overwrite jsonable; most is handled by __reduce__ and python internal set just need to set helper properties.
- static _deduce_package_dir(filepath, content)
Logic for deducing the package directory if the JSONable object is loaded from a file.
- Parameters:
filepath (pathlib.Path) – The path to the file.
content (Union[Dict, List]) – 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.
- Return type:
- _err = 'Element {} already present!'
- classmethod _sorting_key(element)
- Abstractmethod:
- Parameters:
element (any)
- Return type:
any
Key function for sorting elements in this set
- 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.
- Parameters:
element (ModuleBase)
- Return type:
None
- property all_bodies: timor.Bodies.BodySet
All bodies in all modules in the DB
- Return type:
- property all_connector_own_ids: Set[str]
- Abstractmethod:
- Return type:
Set[str]
All local connector ids in the DB
(not full connector IDs, which would consist of [module, body, connectorID])
- property all_connectors: timor.Bodies.ConnectorSet
All connectors of all bodies of all modules in the DB
- Return type:
- property all_connectors_by_id: 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)
- Return type:
Dict[Tuple[str, str, str], timor.Bodies.Connector]
- property all_joints: timor.Joints.JointSet
All joints in all modules in the DB
- Return type:
- property bases: ModulesDB[ModuleBase]
Returns all modules containing at least one base connector
- Return type:
- property by_id: Dict[str, ModuleBase]
Returns this DB as a dictionary, mapping the Module ID to the module
- Return type:
Dict[str, ModuleBase]
- property by_name: Dict[str, ModuleBase]
Returns this DB as a dictionary, mapping the Module Name to the module
- Return type:
Dict[str, ModuleBase]
- connection_type
- property connectivity_graph: networkx.MultiDiGraph
Returns a graph of all possible module connections in the db.
- Returns:
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).
- Return type:
networkx.MultiDiGraph
- debug_visualization(viz=None, stride=1)
Show debug visualization of all contained modules (show them in a square array)
- Parameters:
viz (pinocchio.visualize.MeshcatVisualizer) – MeshcatVisualizer to use
stride (float) – Distance between the plotted modules in meters (default: 1m)
- Returns:
MeshcatVisualizer used
- Return type:
pinocchio.visualize.MeshcatVisualizer
- property default_model_generation_kwargs
A default set of model generation kwargs to use with this modules db.
- property end_effectors: ModulesDB[ModuleBase]
Returns all modules containing at least one eef connector
- Return type:
- filter(func)
Apply a custom filter to this DB to get a new DB with only the modules that pass the filter.
- Parameters:
func (Callable[[ModuleBase], bool]) – A function that takes a module and returns a boolean
- Returns:
A new DB with only the modules that pass the filter. The name is intentionally discarded to avoid confusion.
- Return type:
- 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.
- Parameters:
module (ModuleBase) – The module for which we are looking for replacement candidates.
- Return type:
List[ModuleBase]
- classmethod from_json_data(data, name=None, validate=True, *args, **kwargs)
Loads a modules Database from a json string.
- classmethod from_json_file(filepath, *args, **kwargs)
Loads a modules Database from a json file.
- Parameters:
filepath (Union[pathlib.Path, str]) – Path to the json file
- Returns:
The loaded ModulesDB
- Return type:
- classmethod from_name(module_db_name, reload=True)
Create module DB from name of a module DB configured as loadable robot in timor.config
- intersection(*s)
Intersection should also retutrn a SingleSet
- Parameters:
s (Iterable)
- Return type:
- property possible_connections: 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.
- Return type:
Set[ModulesDB]
- to_json_data()
Turn modulesDB into jsonable dict.
- to_json_file(save_at, *args, **kwargs)
Writes the ModulesDB to a json file.
- Parameters:
save_at (Union[pathlib.Path, str]) – File location or folder to write the DB to.
- union(*s)
Returns a SingleSet of the union of this and the input
- Parameters:
s (Iterable)
- Return type:
- update(*s)
Update method that does not change this instance if the input iterable contains duplicates
- Parameters:
s (Iterable)
- Return type:
None
- timor.Module.RobotConvertible
- timor.Module.robot_from_convertible(robot)
Map a robot convertible to a RobotBase instance
- Parameters:
robot (RobotConvertible)
- Return type: