timor.Joints
Classes
A joint is a bodyless axis. |
|
A set that raises an error if a duplicate joint is added |
|
Enumerates joint types available in Timor |
Module Contents
- class timor.Joints.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)

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).
- Parameters:
joint_id (str) – Unique joint identifier. Has to be unique within each module set or assembly it is in,
parent_body (timor.Bodies.BodyBase) – The body the joint is attached to
child_body (timor.Bodies.BodyBase) – The child body that is attached to the joint
in_module (ModuleBase) – The parent module this Joint belongs to
q_limits (Union[numpy.ndarray, List[float], Tuple[float, float]]) – A tuple/array of (lower_limit, upper_limit) for the joint parameter q
velocity_limit (float) – Maximum angular velocity in rad/s
acceleration_limit (float) – Maximum angular acceleration in rad/s**2
torque_limit (float) – Maximum joint torque in Nm
parent2joint (timor.utilities.transformation.TransformationLike) – The homogeneous transformation from parent body coordinate system to joint coordinate system
joint2child (timor.utilities.transformation.TransformationLike) – The homogeneous transformation from joint coordinate system to child body coordinate system
gear_ratio (float) – The gear ratio of a implicit gear in the joint, defined as w_in / w_out
motor_inertia (float) – The inertia of a motor sitting in this joint
friction_coulomb (float) – Coulomb friction parameter
friction_viscous (float) – Viscous friction parameter
joint_type (Union[str, TimorJointType])
- __eq__(other)
Equality check for joints
- __getstate__()
Returns the state of this object as a dictionary
- __hash__()
Hash of the joint - we assume the ID is unique
- __setstate__(state)
Sets the state of this object from a dictionary
- __str__()
Joint representation of the joint
- 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:
- _type: TimorJointType
- property all_connectors: timor.Bodies.ConnectorSet
All connectors in the bodies attached to this joint
- Return type:
- property child2joint: timor.utilities.transformation.Transformation
The homogeneous transformation from child body to joint coordinate system
- Return type:
- child_body: timor.Bodies.BodyBase
- classmethod from_json_data(d, body_id_to_instance, *args, **kwargs)
Maps the serialized json description to an instance of this class.
- Parameters:
d (Dict) – A dictionary with relevant meta-information
body_id_to_instance (Dict) – A mapping from body IDs to the python instance of this body
- Returns:
An instantiated joint
- 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, body_id_to_instance=None)
Maps the serialized json description to an instance of this class.
- in_module: ModuleBase = None
- joint2child: timor.utilities.transformation.Transformation
- property joint2parent: timor.utilities.transformation.Transformation
The homogeneous transformation from joint to parent body coordinate system
- Return type:
- limits: numpy.ndarray
- parent2joint: timor.utilities.transformation.Transformation
- parent_body: timor.Bodies.BodyBase
- property pin_joint_kwargs: Dict
Provides the key word arguments needed when adding a new joint to a pin robot.
- Return type:
Dict
- property pin_joint_type: Type[pinocchio.JointModel]
Returns a reference to the pinocchio joint class that matches this joints type
- Return type:
Type[pinocchio.JointModel]
- to_json_data()
- Returns:
Returns the join specification in a json-ready dictionary
- 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.
- property type: TimorJointType
Returns the type of this joint
- Return type:
- class timor.Joints.JointSet(*elements)

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.
- Parameters:
elements (Iterable)
- __contains__(item)
Custom duplicate check (unique ID)
- Parameters:
item (any)
- __eq__(other)
If there is a unique ordering to this set, try to sort the elements and compare them
- __hash__()
Hash all the contained elements
- __ne__(other)
Override the not equal operatorof a set
- _err = 'Element {} already present!'
- classmethod _sorting_key(element)
Key function for sorting elements in this set
- Parameters:
element (any)
- Return type:
any
- add(element)
Custom add to set needed s.t. uniqueness is ensured
- Return type:
None
- filter(func)
Convenience function to avoid set comparison over and over again
- intersection(*s)
Intersection should also retutrn a SingleSet
- Parameters:
s (Iterable)
- Return type:
- 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
- class timor.Joints.TimorJointType(*args, **kwds)

Enumerates joint types available in Timor
- JointModelPZ = 1
- JointModelRZ = 0
- __str__()
Ensures defined string casting behavior when storing a joint of a certain type as json
- Return type:
- continuous = 0
- fixed = 3
- prismatic = 1
- prismatic_active = 1
- prismatic_passive = 2
- revolute = 0
- revolute_active = 0
- revolute_passive = 2