timor.parameterized =================== .. py:module:: timor.parameterized Classes ------- .. autoapisummary:: timor.parameterized.DHJoint timor.parameterized.ParameterizableBody timor.parameterized.ParameterizableBoxBody timor.parameterized.ParameterizableCylinderBody timor.parameterized.ParameterizableJointModule timor.parameterized.ParameterizableModule timor.parameterized.ParameterizableMultiBody timor.parameterized.ParameterizableSphereBody timor.parameterized.ParameterizedCylinderLink timor.parameterized.ParameterizedOrthogonalJoint timor.parameterized.ParameterizedOrthogonalLink timor.parameterized.ParameterizedStraightJoint Module Contents --------------- .. py:class:: DHJoint(header, convention_parameters = (1.0, 1.0, np.pi / 2), convention = 'DH', radius = 1.0, mass_density = 1.0, limits = ((0, float('inf')), (-float('inf'), float('inf')), (-float('inf'), float('inf')), (-2 * np.pi, 2 * np.pi)), joint_type = TimorJointType.revolute, joint_parameters = None, connector_arguments = None) .. autoapi-inheritance-diagram:: timor.parameterized.DHJoint :parts: 1 :private-bases: A parameterizable module that represents one joint as defined by DH / MDH parameters. Creates a parameterized module defined by DH/MDH parameters. The joint is before or after the composed bodies. For this module, we assume that there are two bodies: one actual body that, up to the parameters, has an I or L-shape, and one "proxy" body with an empty geometry. These two are connected by a joint. Their order is defined by the convention that can either be DH (the joint is "before the real body" or MDH (the joint is "at the end of the body"). :param header: The module header for the generated module :param convention_parameters: Parameters in order (d, a, alpha) :param convention: Either DH (Denavit-Hartenberg) or MDH (modified, after Craig) :param radius: The radius of the cylinder bodies :param mass_density: The mass density of the bodies' material (kg/m^3) -- assumed to be uniform :param limits: Optional lower and upper bounds on the radius and parameters (r, d, a, alpha) :param joint_type: The type of joint to use -- currently, needs to be revolute. :param joint_parameters: Additional arguments for timor.Joint such as limits or gear ratio; applied to all joints within the module. :param connector_arguments: Mapping from keyword to 2-tuples of values .. py:attribute:: __connector_arguments :value: None .. 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__() For a parameterizable module, we can rely on the default pickling. .. py:method:: __hash__() Custom hash function for modules that should be uniquely determined by their ID. .. py:attribute:: __parameter_limits .. py:method:: __setstate__(state) For a parameterizable module, we can rely on the default pickling. .. 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:method:: _generate_connectors(ids = ('proximal', 'distal'), genders = (Gender.female, Gender.male), types = ('', ''), sizes = ((), ())) :staticmethod: Generates the connectors for this module. .. py:method:: _get_copy_args() Returns the arguments to use when copying this module. .. py:attribute:: _joint_parameters .. py:attribute:: _joints :type: timor.Joints.JointSet .. py:attribute:: _module_graph :type: networkx.DiGraph .. py:attribute:: _radius :type: float :value: 1.0 .. py:method:: _update_connector_placements() This updates the connector attached to the actual link .. py:method:: _update_geometry_placements() Makes sure the two cylinders composing this joint are placed correctly relative to each other. The body frames are aligned with "beginning" of the geometry here. .. py:method:: _update_joint_placement() For this module, we assume body coordinate frames to be at the 'beginning' of the body .. py:property:: a :type: float The a parameter of the DH/MDH convention. .. py:property:: alpha :type: float The alpha parameter of the DH/MDH convention. .. 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 the module and returns the copy. .. py:property:: d :type: float The d parameter of the DH/MDH convention. .. 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:: dh_transformation(theta = 0) Computes the DH transformation of this single joint. .. py:method:: freeze() Returns a static module representation of this module. .. 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:attribute:: joint .. 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 The module graph for a parameterizable module has to be recomputed with every resize. .. 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:property:: parameters :type: Tuple[float, float, float, float] Returns the defining parameters (radius, d, a, alpha) .. py:property:: radius :type: float The radius of the cylinders. .. py:method:: resize(parameters) The interface to change the link's length or radius and adapt the connector placements accordingly. :param parameters: A tuple of (radius, d, a, alpha) or (d, a, alpha) .. py:method:: to_json_data() Freezes the parameters of this module to serialize it. .. 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:: ParameterizableBody(body_id, parameters, parameter_limits = None, mass_density = 1.0, connectors = (), geometry_placement = Transformation.neutral(), in_module = None) .. autoapi-inheritance-diagram:: timor.parameterized.ParameterizableBody :parts: 1 :private-bases: A body that has a geometry which is subject to change depending on an arbitrary number of parameters. Construct a parameterizable body from a geometry reference and parameters. A parameterizable body has a fixed geometry type -- depending on this type, there is a fixed number of parameters that define the expansion of the geometry in the respective direction. For example, a sphere has a single parameter that defines the radius, a cylinder has two parameters that define the radius and the length, and a box has three parameters that define the expansion in x, y, and z direction. :param body_id: The unique ID of the body :param parameters: The number of parameters depends on the geometry type. Their (positive) value defines the expansion of the geometry in the respective direction. For a sphere, this is the radius, for a cylinder, this is the radius and the length, and for a box, this is the expansion in x, y, and z direction. :param parameter_limits: The lower and upper bounds for each parameter. If None is given (default), the bounds are set to [0, inf] for all parameters. Bounds for geometric attributes cannot be negative. :param mass_density: The mass density of the body (in kg/m^3), implicitly assuming a homogeneous material. :param connectors: The connectors of the body - their placement has to be externally and dynamically updated. The connector_placements_valid attribute is used to indicate whether the position of the connectors was updated since the parameters have been changed last time. :param geometry_placement: Parametrized bodies cannot contain composed geometries, so we need to define a relative geometry placement to the origin in order to combine multiple parameterized bodies in a module. This parameter defines the relative transformation between geometry origin and body frame. :param in_module: The module this body is part of. Will be automatically assigned if the body is defined and added to a module later on. .. py:method:: __copy__() Parameterizable bodies are actually quite easy to copy as geometries are calculated on-the-fly. .. py:method:: __eq__(other) Parameterizable body equality is given by the original parameters - no need to compute the geometry. .. py:attribute:: __geometry_type :type: timor.Geometry.GeometryType :value: None .. py:method:: __getstate__() For parameterized bodies, we can rely on the python builtin actually .. py:method:: __hash__() Hashing is equal to hashes of regular bodies - ID should be unique. .. py:method:: __setstate__(state) For parameterized bodies, we can rely on the python builtin actually .. py:attribute:: __slots__ :value: () .. py:method:: __str__() The string representation of a body .. 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:: _geometry_transformation :type: timor.utilities.transformation.Transformation .. py:attribute:: _id :type: str :value: '' .. py:attribute:: _parameter_limits :type: numpy.array :value: None .. py:attribute:: _parameters :type: List[float] .. py:attribute:: _visual :type: Optional[timor.Geometry.Geometry] :value: None .. py:method:: as_pin_body(placement = Transformation.neutral()) Extracts the body properties that describe a body in a pinocchio robot. Always places the body in the origin. :param placement: Relative placement of the body to its parent joint .. py:property:: collision :type: timor.Geometry.Geometry :abstractmethod: Returns the momentary collision geometry of the body taking the current parameters into account. For parameterizable bodies, the collision geometry is always the same as the visual geometry. As the visual defaults to collision anyways, we just need to implement the collision geometry here. We implicitly assume that the body frame coincides with the geometry center-of-mass frame. .. py:attribute:: connector_placements_valid :type: bool :value: False .. py:attribute:: connectors :type: timor.Bodies.ConnectorSet .. py:method:: freeze() Freeze the body, i.e. make it immutable by transforming it to an unparameterized body. .. 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:property:: geometry_type :type: timor.Geometry.GeometryType The geometry type of the body. Ensured to be in the set of valid geometry types. .. py:property:: id :type: Tuple[Union[None, str], str] Composed ID: (module ID, body ID) .. py:attribute:: in_module :type: timor.Module.ModuleBase :value: None .. py:property:: inertia :type: pinocchio.Inertia :abstractmethod: The inertia needs to be dynamically calculated, depending on the geometry. .. py:property:: mass :type: float The mass needs to be dynamically calculated, depending on the geometry expansion. .. py:attribute:: mass_density :value: 1.0 .. py:attribute:: num_parameters :type: int .. py:property:: parameter_limits :type: numpy.array Returns a copy of the parameter limits of the body. .. py:attribute:: parameter_order :type: Dict[timor.Geometry.GeometryType, Tuple[str, Ellipsis]] .. py:property:: parameters :type: Tuple[float, Ellipsis] The parameters of the geometry, returned as a tuple to avoid external changes. .. py:method:: possible_connections_with(other) Returns a set of connectors that can connect this with other body. This method does not check whether the connector IDs of the other body overlap with the connector IDs of this body - this has to be achieved by e.g. putting both bodies in a module or in the same ModulesDB. :param other: Another body :return: A list of matching connector pairs like (this_body_connector, other_body_connector) .. py:method:: to_json_data() Freezes the current body with the currently set parameters and returns the according JSON .. 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:property:: visual :type: timor.Geometry.Geometry Defaults to collision if not explicitly specified .. py:class:: ParameterizableBoxBody(body_id, parameters, parameter_limits = None, mass_density = 1.0, connectors = (), geometry_placement = Transformation.neutral(), in_module = None) .. autoapi-inheritance-diagram:: timor.parameterized.ParameterizableBoxBody :parts: 1 :private-bases: A module body composed of a box with parameterizable dimensions Construct a parameterizable body from a geometry reference and parameters. A parameterizable body has a fixed geometry type -- depending on this type, there is a fixed number of parameters that define the expansion of the geometry in the respective direction. For example, a sphere has a single parameter that defines the radius, a cylinder has two parameters that define the radius and the length, and a box has three parameters that define the expansion in x, y, and z direction. :param body_id: The unique ID of the body :param parameters: The number of parameters depends on the geometry type. Their (positive) value defines the expansion of the geometry in the respective direction. For a sphere, this is the radius, for a cylinder, this is the radius and the length, and for a box, this is the expansion in x, y, and z direction. :param parameter_limits: The lower and upper bounds for each parameter. If None is given (default), the bounds are set to [0, inf] for all parameters. Bounds for geometric attributes cannot be negative. :param mass_density: The mass density of the body (in kg/m^3), implicitly assuming a homogeneous material. :param connectors: The connectors of the body - their placement has to be externally and dynamically updated. The connector_placements_valid attribute is used to indicate whether the position of the connectors was updated since the parameters have been changed last time. :param geometry_placement: Parametrized bodies cannot contain composed geometries, so we need to define a relative geometry placement to the origin in order to combine multiple parameterized bodies in a module. This parameter defines the relative transformation between geometry origin and body frame. :param in_module: The module this body is part of. Will be automatically assigned if the body is defined and added to a module later on. .. py:method:: __copy__() Parameterizable bodies are actually quite easy to copy as geometries are calculated on-the-fly. .. py:method:: __eq__(other) Parameterizable body equality is given by the original parameters - no need to compute the geometry. .. py:attribute:: __geometry_type :type: timor.Geometry.GeometryType :value: None .. py:method:: __getstate__() For parameterized bodies, we can rely on the python builtin actually .. py:method:: __hash__() Hashing is equal to hashes of regular bodies - ID should be unique. .. py:method:: __setstate__(state) For parameterized bodies, we can rely on the python builtin actually .. py:attribute:: __slots__ :value: () .. py:method:: __str__() The string representation of a body .. 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:: _geometry_transformation :type: timor.utilities.transformation.Transformation .. py:attribute:: _id :type: str :value: '' .. py:attribute:: _parameter_limits :type: numpy.array :value: None .. py:attribute:: _parameters :type: List[float] .. py:attribute:: _visual :type: Optional[timor.Geometry.Geometry] :value: None .. py:method:: as_pin_body(placement = Transformation.neutral()) Extracts the body properties that describe a body in a pinocchio robot. Always places the body in the origin. :param placement: Relative placement of the body to its parent joint .. py:property:: collision :type: timor.Geometry.Box The collision geometry of the body. .. py:attribute:: connector_placements_valid :type: bool :value: False .. py:attribute:: connectors :type: timor.Bodies.ConnectorSet .. py:method:: freeze() Freeze the body, i.e. make it immutable by transforming it to an unparameterized body. .. 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:: geometry_type :type: timor.Geometry.GeometryType The geometry type of the body. Ensured to be in the set of valid geometry types. .. py:property:: id :type: Tuple[Union[None, str], str] Composed ID: (module ID, body ID) .. py:attribute:: in_module :type: timor.Module.ModuleBase :value: None .. py:property:: inertia :type: pinocchio.Inertia Assuming a homogeneous material, compute the inertia tensor of self for the current parameters .. py:property:: mass :type: float The mass needs to be dynamically calculated, depending on the geometry expansion. .. py:attribute:: mass_density :value: 1.0 .. py:attribute:: num_parameters :type: int :value: 3 .. py:property:: parameter_limits :type: numpy.array Returns a copy of the parameter limits of the body. .. py:attribute:: parameter_order :type: Dict[timor.Geometry.GeometryType, Tuple[str, Ellipsis]] .. py:property:: parameters :type: Tuple[float, Ellipsis] The parameters of the geometry, returned as a tuple to avoid external changes. .. py:method:: possible_connections_with(other) Returns a set of connectors that can connect this with other body. This method does not check whether the connector IDs of the other body overlap with the connector IDs of this body - this has to be achieved by e.g. putting both bodies in a module or in the same ModulesDB. :param other: Another body :return: A list of matching connector pairs like (this_body_connector, other_body_connector) .. py:method:: to_json_data() Freezes the current body with the currently set parameters and returns the according JSON .. 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:property:: visual :type: timor.Geometry.Geometry Defaults to collision if not explicitly specified .. py:property:: x :type: float The x dimension of the box. .. py:property:: y :type: float The y dimension of the box. .. py:property:: z :type: float The z dimension of the box. .. py:class:: ParameterizableCylinderBody(body_id, parameters, parameter_limits = None, mass_density = 1.0, connectors = (), geometry_placement = Transformation.neutral(), in_module = None) .. autoapi-inheritance-diagram:: timor.parameterized.ParameterizableCylinderBody :parts: 1 :private-bases: A module body composed of a cylinder with a parameterizable radius and length Construct a parameterizable body from a geometry reference and parameters. A parameterizable body has a fixed geometry type -- depending on this type, there is a fixed number of parameters that define the expansion of the geometry in the respective direction. For example, a sphere has a single parameter that defines the radius, a cylinder has two parameters that define the radius and the length, and a box has three parameters that define the expansion in x, y, and z direction. :param body_id: The unique ID of the body :param parameters: The number of parameters depends on the geometry type. Their (positive) value defines the expansion of the geometry in the respective direction. For a sphere, this is the radius, for a cylinder, this is the radius and the length, and for a box, this is the expansion in x, y, and z direction. :param parameter_limits: The lower and upper bounds for each parameter. If None is given (default), the bounds are set to [0, inf] for all parameters. Bounds for geometric attributes cannot be negative. :param mass_density: The mass density of the body (in kg/m^3), implicitly assuming a homogeneous material. :param connectors: The connectors of the body - their placement has to be externally and dynamically updated. The connector_placements_valid attribute is used to indicate whether the position of the connectors was updated since the parameters have been changed last time. :param geometry_placement: Parametrized bodies cannot contain composed geometries, so we need to define a relative geometry placement to the origin in order to combine multiple parameterized bodies in a module. This parameter defines the relative transformation between geometry origin and body frame. :param in_module: The module this body is part of. Will be automatically assigned if the body is defined and added to a module later on. .. py:method:: __copy__() Parameterizable bodies are actually quite easy to copy as geometries are calculated on-the-fly. .. py:method:: __eq__(other) Parameterizable body equality is given by the original parameters - no need to compute the geometry. .. py:attribute:: __geometry_type :type: timor.Geometry.GeometryType .. py:method:: __getstate__() For parameterized bodies, we can rely on the python builtin actually .. py:method:: __hash__() Hashing is equal to hashes of regular bodies - ID should be unique. .. py:method:: __setstate__(state) For parameterized bodies, we can rely on the python builtin actually .. py:attribute:: __slots__ :value: () .. py:method:: __str__() The string representation of a body .. 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:: _geometry_transformation :type: timor.utilities.transformation.Transformation .. py:attribute:: _id :type: str :value: '' .. py:attribute:: _parameter_limits :type: numpy.array :value: None .. py:attribute:: _parameters :type: List[float] .. py:attribute:: _visual :type: Optional[timor.Geometry.Geometry] :value: None .. py:method:: as_pin_body(placement = Transformation.neutral()) Extracts the body properties that describe a body in a pinocchio robot. Always places the body in the origin. :param placement: Relative placement of the body to its parent joint .. py:property:: collision :type: timor.Geometry.Cylinder The collision geometry of the body. .. py:attribute:: connector_placements_valid :type: bool :value: False .. py:attribute:: connectors :type: timor.Bodies.ConnectorSet .. py:method:: freeze() Freeze the body, i.e. make it immutable by transforming it to an unparameterized body. .. 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:property:: geometry_type :type: timor.Geometry.GeometryType The geometry type of the body. Ensured to be in the set of valid geometry types. .. py:property:: id :type: Tuple[Union[None, str], str] Composed ID: (module ID, body ID) .. py:attribute:: in_module :type: timor.Module.ModuleBase :value: None .. py:property:: inertia :type: pinocchio.Inertia Assuming a homogeneous material, compute the inertia tensor of self for the current parameters .. py:property:: l :type: float The length of the cylinder. .. py:property:: mass :type: float The mass needs to be dynamically calculated, depending on the geometry expansion. .. py:attribute:: mass_density :value: 1.0 .. py:attribute:: num_parameters :type: int :value: 2 .. py:property:: parameter_limits :type: numpy.array Returns a copy of the parameter limits of the body. .. py:attribute:: parameter_order :type: Dict[timor.Geometry.GeometryType, Tuple[str, Ellipsis]] .. py:property:: parameters :type: Tuple[float, Ellipsis] The parameters of the geometry, returned as a tuple to avoid external changes. .. py:method:: possible_connections_with(other) Returns a set of connectors that can connect this with other body. This method does not check whether the connector IDs of the other body overlap with the connector IDs of this body - this has to be achieved by e.g. putting both bodies in a module or in the same ModulesDB. :param other: Another body :return: A list of matching connector pairs like (this_body_connector, other_body_connector) .. py:property:: r :type: float The radius of the cylinder. .. py:method:: to_json_data() Freezes the current body with the currently set parameters and returns the according JSON .. 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:property:: visual :type: timor.Geometry.Geometry Defaults to collision if not explicitly specified .. py:class:: ParameterizableJointModule(header, bodies, parameters, joint_parameters, joints) .. autoapi-inheritance-diagram:: timor.parameterized.ParameterizableJointModule :parts: 1 :private-bases: Abstract base class for parameterizable modules that contain joints. This mainly checks that joint parameters are valid. :param joints: The joints of this module :param joint_parameters: Additional arguments for timor.Joint such as limits or gear ratio; applied to all joints within the module. .. 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__() For a parameterizable module, we can rely on the default pickling. .. py:method:: __hash__() Custom hash function for modules that should be uniquely determined by their ID. .. py:method:: __setstate__(state) For a parameterizable module, we can rely on the default pickling. .. 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:method:: _generate_connectors(ids = ('proximal', 'distal'), genders = (Gender.female, Gender.male), types = ('', ''), sizes = ((), ())) :staticmethod: Generates the connectors for this module. .. py:method:: _get_copy_args() :abstractmethod: Returns the arguments for the copy constructor. .. py:attribute:: _joint_parameters .. py:attribute:: _joints :type: timor.Joints.JointSet .. py:attribute:: _module_graph :type: networkx.DiGraph .. py:method:: _update_connector_placements() :abstractmethod: Based on the current body parameters, updates the placements of the connectors. .. py:method:: _update_joint_placement() :abstractmethod: Makes sure the joint is always placed in the middle of the module. .. 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 the module and returns the copy. .. 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:: freeze() Returns a static module representation of this module. .. 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 The module graph for a parameterizable module has to be recomputed with every resize. .. 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:property:: parameters :type: Tuple[float, Ellipsis] :abstractmethod: Returns the parameters of this module. .. py:method:: resize(parameters) :abstractmethod: Resizes the module according to the given parameters and updates the connector placements. .. py:method:: to_json_data() Freezes the parameters of this module to serialize it. .. 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:: ParameterizableModule(header, bodies, joints, parameters) .. autoapi-inheritance-diagram:: timor.parameterized.ParameterizableModule :parts: 1 :private-bases: A parameterizable module may contain bodies that are subject to change and is non-static until frozen. Parameterizable modules can be dynamically resized. The automatic calculation of dynamic properties happens on the basis of the inherent parameterizable bodies -- however, as the connector placement must also dynamically be re-computed with every resizing, only simple geometries are supported. Creates a parameterized module. :param header: The module header for the generated link module :param bodies: The bodies of this module :param joints: The joints of this module :param parameters: The extension-defining parameters of this module .. 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__() For a parameterizable module, we can rely on the default pickling. .. py:method:: __hash__() Custom hash function for modules that should be uniquely determined by their ID. .. py:method:: __setstate__(state) For a parameterizable module, we can rely on the default pickling. .. 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:method:: _generate_connectors(ids = ('proximal', 'distal'), genders = (Gender.female, Gender.male), types = ('', ''), sizes = ((), ())) :staticmethod: Generates the connectors for this module. .. py:method:: _get_copy_args() :abstractmethod: Returns the arguments for the copy constructor. .. py:attribute:: _joints :type: timor.Joints.JointSet .. py:attribute:: _module_graph :type: networkx.DiGraph .. py:method:: _update_connector_placements() :abstractmethod: Based on the current body parameters, updates the placements of the connectors. .. 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 the module and returns the copy. .. 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:: freeze() Returns a static module representation of this module. .. 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 The module graph for a parameterizable module has to be recomputed with every resize. .. 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:property:: parameters :type: Tuple[float, Ellipsis] :abstractmethod: Returns the parameters of this module. .. py:method:: resize(parameters) :abstractmethod: Resizes the module according to the given parameters and updates the connector placements. .. py:method:: to_json_data() Freezes the parameters of this module to serialize it. .. 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:: ParameterizableMultiBody(body_id, geometry_types, parameters, parameter_limits = None, mass_density = 1.0, connectors = (), geometry_placements = None, in_module = None) .. autoapi-inheritance-diagram:: timor.parameterized.ParameterizableMultiBody :parts: 1 :private-bases: A parameterizable multi body is a module body made from multiple generic geometries. Initialize a parameterizable body composed of multiple geometries that are placed relative to self's origin. A ParameterizableMultiBody can contain an arbitrary number of geometries that are allowed for a ParameterizableBody. Each one of them has a placement transformation relative to the origin of the origin. The inertia, mass and volume of the body are calculated as the sum of the corresponding values of the geometries. :param body_id: The id of the body :param geometry_types: The types of the geometries composing this body. :param parameters: The parameters of the geometries, flattened and in the order the geometries are given :param parameter_limits: The limits of the parameters, flattened and in the same order as parameters (n x 2) :param mass_density: The mass density of the body - uniform for all geometries :param geometry_placements: The placement transformations between body frame and center of the geometries. They are given in the order of geometry_types. Placements do not automatically change when geometry parameters do. .. py:method:: __copy__() Parameterizable bodies are actually quite easy to copy as geometries are calculated on-the-fly. .. py:method:: __eq__(other) Parameterizable body equality is given by the original parameters - no need to compute the geometry. .. py:attribute:: __geometry_type :type: timor.Geometry.GeometryType :value: None .. py:method:: __getstate__() For parameterized bodies, we can rely on the python builtin actually .. py:method:: __hash__() Hashing is equal to hashes of regular bodies - ID should be unique. .. py:method:: __setstate__(state) For parameterized bodies, we can rely on the python builtin actually .. py:attribute:: __slots__ :value: () .. py:method:: __str__() The string representation of a body .. 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:: _geometry_transformation :type: Tuple[timor.utilities.transformation.Transformation] .. py:attribute:: _id :type: str :value: '' .. py:attribute:: _parameter_limits :type: numpy.array :value: None .. py:attribute:: _parameters :type: List[float] .. py:attribute:: _visual :type: Optional[timor.Geometry.Geometry] :value: None .. py:method:: as_pin_body(placement = Transformation.neutral()) Extracts the body properties that describe a body in a pinocchio robot. Always places the body in the origin. :param placement: Relative placement of the body to its parent joint .. py:property:: collision :type: timor.Geometry.ComposedGeometry Returns the collision geometry of the body. .. py:attribute:: composing_geometry_types :type: Tuple[timor.Geometry.GeometryType] .. py:attribute:: connector_placements_valid :type: bool :value: False .. py:attribute:: connectors :type: timor.Bodies.ConnectorSet .. py:method:: freeze() Freeze the body, i.e. make it immutable by transforming it to an unparameterized body. .. 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:property:: geometry_placements :type: Tuple[timor.utilities.transformation.Transformation] Returns the placement transformations between body frame and geometry reference frames. .. py:attribute:: geometry_type :type: timor.Geometry.GeometryType The geometry type of the body. Ensured to be in the set of valid geometry types. .. py:attribute:: geometry_type_to_class :type: Dict[timor.Geometry.GeometryType, Type[ParameterizableBody]] .. py:method:: get_num_parameters(gt) :staticmethod: Returns the number of parameters necessary to define the given geometry type. .. py:property:: id :type: Tuple[Union[None, str], str] Composed ID: (module ID, body ID) .. py:attribute:: in_module :type: timor.Module.ModuleBase :value: None .. py:property:: inertia :type: pinocchio.Inertia The inertia is calculated as the sum of the inertia of the composing geometries. .. py:property:: mass :type: float The mass needs to be dynamically calculated, depending on the geometry expansion. .. py:attribute:: mass_density :value: 1.0 .. py:attribute:: num_geometries .. py:property:: num_parameters :type: int Returns the number of parameters necessary to define all geometries for this body. .. py:property:: parameter_limits :type: numpy.array Returns a copy of the parameter limits of the body. .. py:attribute:: parameter_order :type: Dict[timor.Geometry.GeometryType, Tuple[str, Ellipsis]] .. py:property:: parameters :type: Tuple[float, Ellipsis] The parameters of the geometry, returned as a tuple to avoid external changes. .. py:method:: possible_connections_with(other) Returns a set of connectors that can connect this with other body. This method does not check whether the connector IDs of the other body overlap with the connector IDs of this body - this has to be achieved by e.g. putting both bodies in a module or in the same ModulesDB. :param other: Another body :return: A list of matching connector pairs like (this_body_connector, other_body_connector) .. py:method:: print_parameter_info() A helper method to show the current parameters and how they are mapped to the underlying geometries. .. py:method:: to_json_data() Freezes the current body with the currently set parameters and returns the according JSON .. 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:property:: visual :type: timor.Geometry.Geometry Defaults to collision if not explicitly specified .. py:class:: ParameterizableSphereBody(body_id, parameters, parameter_limits = None, mass_density = 1.0, connectors = (), geometry_placement = Transformation.neutral(), in_module = None) .. autoapi-inheritance-diagram:: timor.parameterized.ParameterizableSphereBody :parts: 1 :private-bases: A module body composed of a sphere with a parameterizable radius Construct a parameterizable body from a geometry reference and parameters. A parameterizable body has a fixed geometry type -- depending on this type, there is a fixed number of parameters that define the expansion of the geometry in the respective direction. For example, a sphere has a single parameter that defines the radius, a cylinder has two parameters that define the radius and the length, and a box has three parameters that define the expansion in x, y, and z direction. :param body_id: The unique ID of the body :param parameters: The number of parameters depends on the geometry type. Their (positive) value defines the expansion of the geometry in the respective direction. For a sphere, this is the radius, for a cylinder, this is the radius and the length, and for a box, this is the expansion in x, y, and z direction. :param parameter_limits: The lower and upper bounds for each parameter. If None is given (default), the bounds are set to [0, inf] for all parameters. Bounds for geometric attributes cannot be negative. :param mass_density: The mass density of the body (in kg/m^3), implicitly assuming a homogeneous material. :param connectors: The connectors of the body - their placement has to be externally and dynamically updated. The connector_placements_valid attribute is used to indicate whether the position of the connectors was updated since the parameters have been changed last time. :param geometry_placement: Parametrized bodies cannot contain composed geometries, so we need to define a relative geometry placement to the origin in order to combine multiple parameterized bodies in a module. This parameter defines the relative transformation between geometry origin and body frame. :param in_module: The module this body is part of. Will be automatically assigned if the body is defined and added to a module later on. .. py:method:: __copy__() Parameterizable bodies are actually quite easy to copy as geometries are calculated on-the-fly. .. py:method:: __eq__(other) Parameterizable body equality is given by the original parameters - no need to compute the geometry. .. py:attribute:: __geometry_type :type: timor.Geometry.GeometryType .. py:method:: __getstate__() For parameterized bodies, we can rely on the python builtin actually .. py:method:: __hash__() Hashing is equal to hashes of regular bodies - ID should be unique. .. py:method:: __setstate__(state) For parameterized bodies, we can rely on the python builtin actually .. py:attribute:: __slots__ :value: () .. py:method:: __str__() The string representation of a body .. 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:: _geometry_transformation :type: timor.utilities.transformation.Transformation .. py:attribute:: _id :type: str :value: '' .. py:attribute:: _parameter_limits :type: numpy.array :value: None .. py:attribute:: _parameters :type: List[float] .. py:attribute:: _visual :type: Optional[timor.Geometry.Geometry] :value: None .. py:method:: as_pin_body(placement = Transformation.neutral()) Extracts the body properties that describe a body in a pinocchio robot. Always places the body in the origin. :param placement: Relative placement of the body to its parent joint .. py:property:: collision :type: timor.Geometry.Sphere The collision geometry of the body. .. py:attribute:: connector_placements_valid :type: bool :value: False .. py:attribute:: connectors :type: timor.Bodies.ConnectorSet .. py:method:: freeze() Freeze the body, i.e. make it immutable by transforming it to an unparameterized body. .. 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:property:: geometry_type :type: timor.Geometry.GeometryType The geometry type of the body. Ensured to be in the set of valid geometry types. .. py:property:: id :type: Tuple[Union[None, str], str] Composed ID: (module ID, body ID) .. py:attribute:: in_module :type: timor.Module.ModuleBase :value: None .. py:property:: inertia :type: pinocchio.Inertia Assuming a homogeneous material, compute the inertia tensor of self for the current parameters .. py:property:: mass :type: float The mass needs to be dynamically calculated, depending on the geometry expansion. .. py:attribute:: mass_density :value: 1.0 .. py:attribute:: num_parameters :type: int :value: 1 .. py:property:: parameter_limits :type: numpy.array Returns a copy of the parameter limits of the body. .. py:attribute:: parameter_order :type: Dict[timor.Geometry.GeometryType, Tuple[str, Ellipsis]] .. py:property:: parameters :type: Tuple[float, Ellipsis] The parameters of the geometry, returned as a tuple to avoid external changes. .. py:method:: possible_connections_with(other) Returns a set of connectors that can connect this with other body. This method does not check whether the connector IDs of the other body overlap with the connector IDs of this body - this has to be achieved by e.g. putting both bodies in a module or in the same ModulesDB. :param other: Another body :return: A list of matching connector pairs like (this_body_connector, other_body_connector) .. py:property:: r :type: float The radius of the sphere. .. py:method:: to_json_data() Freezes the current body with the currently set parameters and returns the according JSON .. 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:property:: visual :type: timor.Geometry.Geometry Defaults to collision if not explicitly specified .. py:class:: ParameterizedCylinderLink(header, length = 1.0, radius = 1.0, mass_density = 1.0, limits = None, connector_arguments = None) .. autoapi-inheritance-diagram:: timor.parameterized.ParameterizedCylinderLink :parts: 1 :private-bases: This is a module in cylinder shape with connectors at both ends that can be used to construct a robot. Creates a parameterized module with one, i-shaped link. The link has a varying length and radius. Connectors are placed at x=0, y=0 and z chosen s.t. they are aligned with the cylinder's flat surfaces. The body coordinate system is placed in the center of the cylinder. :param header: The module header for the generated link module :param length: The length of the cylinder :param radius: The radius of the cylinder :param mass_density: The mass density of the link's material (kg/m^3) -- assumed to be uniform :param limits: Optional lower and upper bounds on the link's length and radius :param connector_arguments: Mapping from keyword to 2-tuples of values for gender, size, type. .. py:attribute:: __connector_arguments :value: None .. 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__() For a parameterizable module, we can rely on the default pickling. .. py:method:: __hash__() Custom hash function for modules that should be uniquely determined by their ID. .. py:method:: __setstate__(state) For a parameterizable module, we can rely on the default pickling. .. 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:method:: _generate_connectors(ids = ('proximal', 'distal'), genders = (Gender.female, Gender.male), types = ('', ''), sizes = ((), ())) :staticmethod: Generates the connectors for this module. .. py:method:: _get_copy_args() Returns the arguments for the copy constructor. .. py:attribute:: _joints :type: timor.Joints.JointSet .. py:attribute:: _length :type: float :value: 1.0 .. py:attribute:: _module_graph :type: networkx.DiGraph .. py:attribute:: _radius :type: float :value: 1.0 .. py:method:: _update_connector_placements() Makes sure the connectors are always placed on the bottom/top and centered in the link. .. 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 the module and returns the copy. .. 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:: freeze() Returns a static module representation of this module. .. 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:: length :type: float The length of the link. .. py:attribute:: link :type: ParameterizableCylinderBody .. py:property:: mass :type: float Returns the total mass of the module. .. py:property:: module_graph :type: networkx.DiGraph The module graph for a parameterizable module has to be recomputed with every resize. .. 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:property:: parameters :type: Tuple[float, float] Returns the parameters of this module. .. py:property:: radius :type: float The radius of the link. .. py:method:: resize(parameters) The interface to change the link's length or radius and adapt the connector placements accordingly. :param parameters: A tuple of (radius, length) .. py:method:: to_json_data() Freezes the parameters of this module to serialize it. .. 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:: ParameterizedOrthogonalJoint(header, lengths = (1.0, 1.0), radius = 1.0, mass_density = 1.0, limits = ((0, float('inf')), (0, float('inf')), (0, float('inf'))), joint_type = TimorJointType.revolute, joint_parameters = None, connector_arguments = None, alpha_rot_x = np.pi / 2, convention_alpha = 'DH') .. autoapi-inheritance-diagram:: timor.parameterized.ParameterizedOrthogonalJoint :parts: 1 :private-bases: This is a module in L-shape with connectors at both ends and a joint in the 'elbow'. Creates a parameterized module with two cylinders being orthogonal to each other. The first cylinder is placed along the z-Axis. The symmetry axes of body 2 run through z=l1, where the z-Axis of the second cylinder is aligned with the y-axis of the first cylinder for q_joint=0. Both have varying length and the same, varying radius. At their connection is a joint, which can be revolute or prismatic. For q_joint=0, the surface of the second cylinder is aligned with z=0. The joint axis is the initial z-Axis. :param header: The module header for the generated module :param lengths: (l1, l2) for the two bodies in this module :param radius: The radius of the cylinders :param mass_density: The mass density of the bodies' material (kg/m^3) -- assumed to be uniform :param limits: Optional lower and upper bounds on the link's length and radius (r, l1, l2) :param joint_type: The type of joint to use :math:`\in` (revolute, prismatic) :param joint_parameters: Additional arguments for timor.Joint such as limits or gear ratio; applied to all joints within the module. :param connector_arguments: Mapping from keyword to 2-tuples of values :param alpha_rot_x: The rotation angle around the x-axis for the second cylinder. :param convention_alpha: Either DH (apply x-rotation AFTER joint rotation) or MDH (apply x-rotation BEFORE) .. py:attribute:: __connector_arguments :value: None .. 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__() For a parameterizable module, we can rely on the default pickling. .. py:method:: __hash__() Custom hash function for modules that should be uniquely determined by their ID. .. py:method:: __setstate__(state) For a parameterizable module, we can rely on the default pickling. .. 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:method:: _generate_connectors(ids = ('proximal', 'distal'), genders = (Gender.female, Gender.male), types = ('', ''), sizes = ((), ())) :staticmethod: Generates the connectors for this module. .. py:method:: _get_copy_args() Returns the arguments to use when copying this module. .. py:attribute:: _joint_parameters .. py:attribute:: _joints :type: timor.Joints.JointSet .. py:attribute:: _module_graph :type: networkx.DiGraph .. py:attribute:: _radius :type: float :value: 1.0 .. py:method:: _update_connector_placements() Makes sure the connectors are always placed on the bottom/top and centered in the link. .. py:method:: _update_joint_placement() Makes sure the joint is always placed in the middle of the module. .. py:attribute:: _x_rotation :type: float .. 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 the module and returns the copy. .. 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:attribute:: distal_link :type: ParameterizableCylinderBody .. py:method:: freeze() Returns a static module representation of this module. .. 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:attribute:: joint .. py:property:: joints :type: timor.Joints.JointSet Returns all joints contained in this module .. py:property:: l1 :type: float The length of the proximal body. .. py:property:: l2 :type: float The length of the distal body. .. py:property:: mass :type: float Returns the total mass of the module. .. py:property:: module_graph :type: networkx.DiGraph The module graph for a parameterizable module has to be recomputed with every resize. .. 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:property:: parameters :type: Tuple[float, float, float] The parameters of the module. .. py:attribute:: proximal_link :type: ParameterizableCylinderBody .. py:property:: radius :type: float The radius of the bodies. .. py:method:: resize(parameters) The interface to change both of the bodies' length and/or radius and adapt the connector and joint placements. :param parameters: A tuple of (radius, l1, l2) .. py:method:: to_json_data() Freezes the parameters of this module to serialize it. .. 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:: ParameterizedOrthogonalLink(header, lengths = (1.0, 1.0), radius = 1.0, mass_density = 1.0, limits = ((0, float('inf')), (0, float('inf')), (0, float('inf'))), connector_arguments = None, alpha_rot_x = np.pi / 2) .. autoapi-inheritance-diagram:: timor.parameterized.ParameterizedOrthogonalLink :parts: 1 :private-bases: This is a module in L-shape with connectors at both ends that can be used to construct a robot. Creates a parameterized module with one, L-shaped link. The link has a varying lengths and radius. Connectors are placed at the flat surfaces of the cylinders. The body coordinate systems share origins with the connectors -- body coordinate systems are pointing inwards though. :param header: The module header for the generated link module :param lengths: The lengths l1 and l2 of the cylinders :param radius: The radius of the cylinders :param mass_density: The mass density of the link's material (kg/m^3) -- assumed to be uniform :param limits: Optional lower and upper bounds on the link's lengths and radius (r, l1, l2) :param connector_arguments: Mapping from keyword to 2-tuples of values for gender, size, type. :param alpha_rot_x: The rotation angle around the x-axis for the second cylinder .. py:attribute:: __connector_arguments :value: None .. 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__() For a parameterizable module, we can rely on the default pickling. .. py:method:: __hash__() Custom hash function for modules that should be uniquely determined by their ID. .. py:method:: __setstate__(state) For a parameterizable module, we can rely on the default pickling. .. 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:method:: _generate_connectors(ids = ('proximal', 'distal'), genders = (Gender.female, Gender.male), types = ('', ''), sizes = ((), ())) :staticmethod: Generates the connectors for this module. .. py:method:: _get_copy_args() Returns the arguments for the copy constructor. .. py:attribute:: _joints :type: timor.Joints.JointSet .. py:attribute:: _module_graph :type: networkx.DiGraph .. py:attribute:: _radius :type: float :value: 1.0 .. py:method:: _update_connector_placements() Makes sure the connectors are always placed on the bottom/top and centered in the link. .. py:method:: _update_geometry_placements() Makes sure the two cylinders composing this link are placed correctly relative to each other. Assumes the reference frame for this module is aligned with the proximal connector. The frame for the first geometry is centered in the first cylinder, l/2 above the module reference frame. The frame for the second geometry is placed accordingly in the second cylinder. .. py:attribute:: _x_rotation :type: float .. 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 the module and returns the copy. .. 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:: freeze() Returns a static module representation of this module. .. 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:: l1 :type: float The length of the first link. .. py:property:: l1_position :type: timor.utilities.transformation.Transformation Describes the relative transformation between body origin and the geometry frame of the first geometry. .. py:property:: l2 :type: float The length of the second (perpendicular) link. .. py:property:: l2_position :type: timor.utilities.transformation.Transformation Describes the relative transformation between body origin and the geometry frame of the second geometry. .. py:attribute:: link :type: ParameterizableMultiBody .. py:property:: mass :type: float Returns the total mass of the module. .. py:property:: module_graph :type: networkx.DiGraph The module graph for a parameterizable module has to be recomputed with every resize. .. 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:property:: parameters :type: Tuple[float, float, float] Returns the parameters of this module. .. py:property:: radius :type: float The radius of the link. .. py:method:: resize(parameters) The interface to change the link's length or radius and adapt the connector placements accordingly. :param parameters: A tuple of (radius, length) .. py:method:: to_json_data() Freezes the parameters of this module to serialize it. .. 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:: ParameterizedStraightJoint(header, length = 1.0, radius = 1.0, mass_density = 1.0, limits = ((0, float('inf')), (0, float('inf'))), joint_type = TimorJointType.revolute, joint_parameters = None, connector_arguments = None) .. autoapi-inheritance-diagram:: timor.parameterized.ParameterizedStraightJoint :parts: 1 :private-bases: This is a module in cylinder shape with connectors at both ends and a joint in the middle. Creates a parameterized module with two cylinders, connected by a joint. The module has a varying length and radius. Connectors are placed at the flat surfaces of the cylinders that are not attached to the joint. :param header: The module header for the generated module :param length: The overall length of the module. Will be divided equally between the two bodies. :param radius: The radius of the cylinders :param mass_density: The mass density of the bodies' material (kg/m^3) -- assumed to be uniform :param limits: Optional lower and upper bounds on the link's length and radius :param joint_type: The type of joint to use :math:`\in` (revolute, prismatic) :param joint_parameters: Additional arguments for timor.Joint such as limits or gear ratio; applied to all joints within the module. :param connector_arguments: Mapping from keyword to 2-tuples of values .. py:attribute:: __connector_arguments :value: None .. 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__() For a parameterizable module, we can rely on the default pickling. .. py:method:: __hash__() Custom hash function for modules that should be uniquely determined by their ID. .. py:method:: __setstate__(state) For a parameterizable module, we can rely on the default pickling. .. 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:method:: _generate_connectors(ids = ('proximal', 'distal'), genders = (Gender.female, Gender.male), types = ('', ''), sizes = ((), ())) :staticmethod: Generates the connectors for this module. .. py:method:: _get_copy_args() Returns the arguments to use when copying this module. .. py:attribute:: _joint_parameters .. py:attribute:: _joints :type: timor.Joints.JointSet .. py:attribute:: _length :type: float :value: 1.0 .. py:attribute:: _module_graph :type: networkx.DiGraph .. py:attribute:: _radius :type: float :value: 1.0 .. py:method:: _update_connector_placements() Makes sure the connectors are always placed on the bottom/top and centered in the link. .. py:method:: _update_joint_placement() Makes sure the joint is always placed in the middle of the module. .. 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 the module and returns the copy. .. 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:attribute:: distal_link :type: ParameterizableCylinderBody .. py:method:: freeze() Returns a static module representation of this module. .. 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:attribute:: joint .. py:property:: joints :type: timor.Joints.JointSet Returns all joints contained in this module .. py:property:: length :type: float The length of the module (2 * individual body length). .. py:property:: mass :type: float Returns the total mass of the module. .. py:property:: module_graph :type: networkx.DiGraph The module graph for a parameterizable module has to be recomputed with every resize. .. 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:property:: parameters :type: Tuple[float, float] The parameters of the module. .. py:attribute:: proximal_link :type: ParameterizableCylinderBody .. py:property:: radius :type: float The radius of the bodies. .. py:method:: resize(parameters) The interface to change both of the bodies' length and/or radius and adapt the connector and joint placements. :param parameters: A tuple of (radius, length) .. py:method:: to_json_data() Freezes the parameters of this module to serialize it. .. 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.