timor.Joints

Classes

Joint

A joint is a bodyless axis.

JointSet

A set that raises an error if a duplicate joint is added

TimorJointType

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)
Inheritance diagram of timor.Joints.Joint

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:

pathlib.Path

_id: str = ''
_type: TimorJointType
acceleration_limit: float
property all_connectors: timor.Bodies.ConnectorSet

All connectors in the bodies attached to this joint

Return type:

timor.Bodies.ConnectorSet

property child2joint: timor.utilities.transformation.Transformation

The homogeneous transformation from child body to joint coordinate system

Return type:

timor.utilities.transformation.Transformation

child_body: timor.Bodies.BodyBase
friction_coulomb: float
friction_viscous: float
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:

Joint

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.

Parameters:
  • s (str) – A string 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:

Joint

gear_ratio: float
property id: Tuple[None | str, str]

Compose ID: (module ID, joint ID)

Return type:

Tuple[Union[None, str], str]

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:

timor.utilities.transformation.Transformation

limits: numpy.ndarray
motor_inertia: float
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.

to_json_string()

Return the json string representation.

Return type:

str

torque_limit: float
property type: TimorJointType

Returns the type of this joint

Return type:

TimorJointType

velocity_limit: float
class timor.Joints.JointSet(*elements)
Inheritance diagram of timor.Joints.JointSet

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

copy()

Custom copy should also return a SingleSet

Return type:

SingleSet

filter(func)

Convenience function to avoid set comparison over and over again

Parameters:

func (Callable[[any], bool]) – A filter function that takes an element of this set and evaluates to true if the element should be kept

Returns:

A new set of elements fulfilling the filter criterion

Return type:

SingleSet

intersection(*s)

Intersection should also retutrn a SingleSet

Parameters:

s (Iterable)

Return type:

SingleSet

union(*s)

Returns a SingleSet of the union of this and the input

Parameters:

s (Iterable)

Return type:

SingleSet

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)
Inheritance diagram of timor.Joints.TimorJointType

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:

str

continuous = 0
fixed = 3
prismatic = 1
prismatic_active = 1
prismatic_passive = 2
revolute = 0
revolute_active = 0
revolute_passive = 2