timor.Joints ============ .. py:module:: timor.Joints Classes ------- .. autoapisummary:: timor.Joints.Joint timor.Joints.JointSet timor.Joints.TimorJointType Module Contents --------------- .. py:class:: Joint(joint_id, joint_type, parent_body, child_body, in_module = None, q_limits = (-np.inf, np.inf), torque_limit = np.inf, velocity_limit = np.inf, acceleration_limit = np.inf, parent2joint = Transformation.neutral(), joint2child = Transformation.neutral(), gear_ratio = 1.0, motor_inertia = 0.0, friction_coulomb = 0.0, friction_viscous = 0.0) .. autoapi-inheritance-diagram:: timor.Joints.Joint :parts: 1 :private-bases: A joint is a bodyless axis. Masses, inertias etc. are contained in the parent and child bodies (except for the simplified motor inertia). What is called a "joint" in everyday language (the hardware part you attach to a robot) would, in this definition, be a chain of parent_body -> joint -> child body. Holds all important joint meta-information. Not intended for calculations (kinematics / dynamics). :param joint_id: Unique joint identifier. Has to be unique within each module set or assembly it is in, :param parent_body: The body the joint is attached to :param child_body: The child body that is attached to the joint :param in_module: The parent module this Joint belongs to :param q_limits: A tuple/array of (lower_limit, upper_limit) for the joint parameter q :param velocity_limit: Maximum angular velocity in rad/s :param acceleration_limit: Maximum angular acceleration in rad/s**2 :param torque_limit: Maximum joint torque in Nm :param parent2joint: The homogeneous transformation from parent body coordinate system to joint coordinate system :param joint2child: The homogeneous transformation from joint coordinate system to child body coordinate system :param gear_ratio: The gear ratio of a implicit gear in the joint, defined as w_in / w_out :param motor_inertia: The inertia of a motor sitting in this joint :param friction_coulomb: Coulomb friction parameter :param friction_viscous: Viscous friction parameter .. py:method:: __eq__(other) Equality check for joints .. py:method:: __getstate__() Returns the state of this object as a dictionary .. py:method:: __hash__() Hash of the joint - we assume the ID is unique .. py:method:: __setstate__(state) Sets the state of this object from a dictionary .. py:method:: __str__() Joint representation of the joint .. 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:: _id :type: str :value: '' .. py:attribute:: _type :type: TimorJointType .. py:attribute:: acceleration_limit :type: float .. py:property:: all_connectors :type: timor.Bodies.ConnectorSet All connectors in the bodies attached to this joint .. py:property:: child2joint :type: timor.utilities.transformation.Transformation The homogeneous transformation from child body to joint coordinate system .. py:attribute:: child_body :type: timor.Bodies.BodyBase .. py:attribute:: friction_coulomb :type: float .. py:attribute:: friction_viscous :type: float .. py:method:: from_json_data(d, body_id_to_instance, *args, **kwargs) :classmethod: Maps the serialized json description to an instance of this class. :param d: A dictionary with relevant meta-information :param body_id_to_instance: A mapping from body IDs to the python instance of this body :return: An instantiated joint .. 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, body_id_to_instance = None) :classmethod: Maps the serialized json description to an instance of this class. :param s: A string with relevant meta-information :param body_id_to_instance: A mapping from body IDs to the python instance of this body :return: An instantiated joint .. py:attribute:: gear_ratio :type: float .. py:property:: id :type: Tuple[Union[None, str], str] Compose ID: (module ID, joint ID) .. py:attribute:: in_module :type: ModuleBase :value: None .. py:attribute:: joint2child :type: timor.utilities.transformation.Transformation .. py:property:: joint2parent :type: timor.utilities.transformation.Transformation The homogeneous transformation from joint to parent body coordinate system .. py:attribute:: limits :type: numpy.ndarray .. py:attribute:: motor_inertia :type: float .. py:attribute:: parent2joint :type: timor.utilities.transformation.Transformation .. py:attribute:: parent_body :type: timor.Bodies.BodyBase .. py:property:: pin_joint_kwargs :type: Dict Provides the key word arguments needed when adding a new joint to a pin robot. .. py:property:: pin_joint_type :type: Type[pinocchio.JointModel] Returns a reference to the pinocchio joint class that matches this joints type .. py:method:: to_json_data() :return: Returns the join specification in a json-ready dictionary .. py:method:: to_json_file(save_at, *args, **kwargs) Writes the instance to a json file. :param save_at: File location or folder to write the class to. .. py:method:: to_json_string() Return the json string representation. .. py:attribute:: torque_limit :type: float .. py:property:: type :type: TimorJointType Returns the type of this joint .. py:attribute:: velocity_limit :type: float .. py:class:: JointSet(*elements) .. autoapi-inheritance-diagram:: timor.Joints.JointSet :parts: 1 :private-bases: A set that raises an error if a duplicate joint is added Custom init function. Might be slow, but provides safety that every element in the input argument is checked using the tested update and add methods. For sophisticated element checking, consider overriding the __contains__ method in sub-classes. .. py:method:: __contains__(item) Custom duplicate check (unique ID) .. py:method:: __eq__(other) If there is a unique ordering to this set, try to sort the elements and compare them .. py:method:: __hash__() Hash all the contained elements .. py:method:: __ne__(other) Override the not equal operatorof a set .. py:attribute:: _err :value: 'Element {} already present!' .. py:method:: _sorting_key(element) :classmethod: Key function for sorting elements in this set .. py:method:: add(element) Custom add to set needed s.t. uniqueness is ensured .. py:method:: copy() Custom copy should also return a SingleSet .. py:method:: filter(func) Convenience function to avoid set comparison over and over again :param func: A filter function that takes an element of this set and evaluates to true if the element should be kept :return: A new set of elements fulfilling the filter criterion .. py:method:: intersection(*s) Intersection should also retutrn a SingleSet .. py:method:: union(*s) Returns a SingleSet of the union of this and the input .. py:method:: update(*s) Update method that does not change this instance if the input iterable contains duplicates .. py:class:: TimorJointType(*args, **kwds) .. autoapi-inheritance-diagram:: timor.Joints.TimorJointType :parts: 1 :private-bases: Enumerates joint types available in Timor .. py:attribute:: JointModelPZ :value: 1 .. py:attribute:: JointModelRZ :value: 0 .. py:method:: __str__() Ensures defined string casting behavior when storing a joint of a certain type as json .. py:attribute:: continuous :value: 0 .. py:attribute:: fixed :value: 3 .. py:attribute:: prismatic :value: 1 .. py:attribute:: prismatic_active :value: 1 .. py:attribute:: prismatic_passive :value: 2 .. py:attribute:: revolute :value: 0 .. py:attribute:: revolute_active :value: 0 .. py:attribute:: revolute_passive :value: 2