Code Documentation

class trip_kinematics.Transformation.Transformation(name: str, values: Dict[str, float], state_variables: Optional[List[str]] = None, parent=None)[source]

Initializes the Transformation class.

Parameters
  • name (str) – The unique name identifying the Transformation. No two Transformation objects of a :py:class`Robot` should have the same name

  • values (Dict[str, float]) – A parametric description of the transformation.

  • state_variables (List[str], optional) – This list describes which state variables are dynamically changable. This is the case if the Transformation represents a joint. Defaults to [].

Raises

ValueError – A dynamic state was declared that does not correspond to a parameter declared in values.

add_children(child: str)[source]
Adds the name of a KinematicGroup or Transformation

as a child.

Parameters

child (str) – the name of a KinematicGroup or Transformation

static get_convention(state: Dict[str, float])[source]
Returns the connvention which describes how the matrix

of a Transformation is build from its state.

Parameters

state (Dict[str, float]) – :py:attr:’state’

Raises
  • ValueError – “Invalid key.” If the dictionary kontains keys that dont correspond to a parameter of the transformation.

  • ValueError – “State can’t have euler angles and quaternions!” If the dictionary contains keys correspondig to multiple mutually exclusive conventions.

Returns

A string describing the convention

Return type

[type]

get_name()[source]

Returns the _name of the Transformation

Returns

a copy the _name attribute

Return type

str

get_state()[source]
Returns a copy of the _state

attribute of the Transformation object.

Returns

a copy of the _state

Return type

Dict[str,float]

get_transformation_matrix()[source]
Returns a homogeneous transformation matrix build

from the state and constants

Raises

RuntimeError – If the convention used in state is not supported. Should normally be catched during initialization.

Returns

A transformation matrix build using the parameters

of the Transformation state

Return type

[type]

set_state(state: Dict[str, float])[source]

Sets the state of the Transformation object.

Parameters

state (Dict[str, float]) – Dictionary with states that should be set. Does not have to be the full state.

Raises

KeyError – If a key in the argument is not valid state parameter name.

trip_kinematics.Transformation.array_find(arr, obj) int[source]
A helpher function which finds the index of an object in an array.

Instead of throwing an error when no index can be found it returns -1.

Parameters
  • arr – the array to be searched

  • obj – the object whose index is to be found.

Returns

The index of obj in the array. -1 if the object is not in the array

Return type

int

class trip_kinematics.KinematicGroup.KinematicGroup(name: str, virtual_chain: List[trip_kinematics.Transformation.Transformation], actuated_state: Dict[str, float], actuated_to_virtual: Callable, virtual_to_actuated: Callable, act_to_virt_args=None, virt_to_act_args=None, parent=None)[source]

Initializes a KinematicGroup object.

Parameters
  • name (str) – The unique name identifying the group. No two KinematicGroup objects of a :py:class`Robot` should have the same name

  • virtual_chain (List[Transformation]) – A list of Transformation objects forming a serial Kinematic chain.

  • actuated_state (List[Dict[str, float]]) – The State of the Groups actuated joints.

  • actuated_to_virtual (Callable) – Maps the actuated_state to the virtual_state of the virtual_chain.

  • virtual_to_actuated (Callable) – Maps the virtual_state of the virtual_chain to the actuated_state.

  • act_to_virt_args ([type], optional) – Arguments that can be passed to actuated_to_virtual during the initial testing of the function. Defaults to None.

  • virt_to_act_args ([type], optional) – Arguments that can be passed to virtual_to_actuated during the initial testing of the function. Defaults to None.

  • parent (Union(Transformation,KinematicGroup), optional) – The transformation or group preceding the KinematicGroup. Defaults to None.

Raises
  • ValueError – ‘Error: Actuated state is missing. You provided a mapping to actuate the group but no state to be actuated.’ if there is no actuated_state despite a mapping being passed

  • ValueError – ‘Error: Only one mapping provided. You need mappings for both ways. Consider to pass a trivial mapping.’ if either actuated_to_virtual or virtual_to_actuated was not set despite providing a actuated_state.

  • ValueError – ‘Error: Mappings missing. You provided an actuated state but no mappings. If you want a trivial mapping you don’t need to pass an actuated state. Trip will generate one for you.’ if both actuated_to_virtual and virtual_to_actuated were not set despite providing a actuated_state.

  • RuntimeError – “actuated_to_virtual does not fit virtual state” if the actuated_to_virtual function does not return a valid virtual_state dictionary.

  • RuntimeError – “virtual_to_actuated does not fit actuated state” if the virtual_to_actuated function does not return a valid actuated_state dictionary.

add_children(child: str)[source]
Adds the name of a KinematicGroup or Transformation

as a child.

Parameters

child (str) – the name of a KinematicGroup or Transformation

get_actuated_state()[source]
Returns a copy of the actuated_state

attribute of the KinematicGroup object.

Returns

a copy of the actuated_state

Return type

Dict[str,float]

get_name()[source]

Returns the _name of the KinematicGroup

Returns

the _name attribute

Return type

str

get_transformation_matrix()[source]
Calculates the full transformationmatrix from

the start of the virtual chain to its endeffector.

Returns

The homogenous transformation matrix from

the start of the virtual chain to its endeffector.

Return type

array

get_virtual_chain()[source]
Returns a copy of the _virtual_chain

attribute of a KinematicGroup object.

Returns

a copy of the _virtual_chain

Return type

Dict[str,Transformation]

get_virtual_state()[source]
Returns a copy of the virtual_state

attribute of the KinematicGroup object.

Returns

a copy of the virtual_state

Return type

Dict[str,Dict[str,float]]

static object_list_to_key_lists(object_lst)[source]

Helper function which transforms dictionary into list of keys.

Parameters

object_lst (Dict) – The dictionary to be transformed

Returns

A list of keys

Return type

list(str)

pass_arg_a_to_v(argv)[source]

Allows arguments to be passed the actuated_to_virtual mapping.

Parameters

argv ([type]) – arguments to be passed.

pass_arg_v_to_a(argv)[source]

Allows arguments to be passed the virtual_to_actuated mapping.

Parameters

argv ([type]) – arguments to be passed.

set_actuated_state(state: Dict[str, float])[source]
Sets the actuated_state of the Group and

automatically updates the corresponding virtual_state.

Parameters

state (Dict[str, float]) – A dictionary containing the members of actuated_state that should be set.

Raises
  • RuntimeError – if all Transformation objects of _virtual_chain are static.

  • ValueError – if the state to set is not part of keys of actuated_state

set_virtual_state(state: Dict[str, Dict[str, float]])[source]
Sets the virtual_state of the Group and

automatically updates the corresponding actuated_state.

Parameters

state (Dict[str,Dict[str, float]]) – A dictionary containing the members of virtual_state that should be set. The new values need to be valid state for the state of the joint.

Raises
  • RuntimeError – if all Transformation objects of _virtual_chain are static.

  • ValueError – if the state to set is not part of keys of virtual_state

class trip_kinematics.KinematicGroup.OpenKinematicGroup(name: str, virtual_chain: List[trip_kinematics.Transformation.Transformation], parent=None)[source]
A subclass of the KinematicGroup that assumes that all states

of the virtual_chain are actuated and automatically generates mappings. Typically only used internally by the :py:class`Robot` class to convert :py:class`Transformation` objects to :py:class`KinematicGroup`s.

Parameters
  • name (str) – The unique name identifying the group. No two KinematicGroup objects of a :py:class`Robot` should have the same name

  • virtual_chain (List[Transformation]) – A list of Transformation objects forming a serial Kinematic chain.

  • parent (Union(Transformation,KinematicGroup), optional) – The transformation or group preceding the KinematicGroup. Defaults to None.

class trip_kinematics.Robot.Robot(kinematic_chain: List[trip_kinematics.KinematicGroup.KinematicGroup])[source]

A class representing the kinematic model of a robot.

Parameters

kinematic_chain (List[KinematicGroup]) – A list of Kinematic Groups and Transformations which make up the robot. Transformations are automatically converted to groups

Raises
  • KeyError – “More than one robot actuator has the same name! Please give each actuator a unique name” if there are actuated states with the same names between the :py:class`KinematicGroup` objects of the :py:class`Robot`

  • KeyError – if there are joints with the same names between the :py:class`KinematicGroup` objects of the :py:class`Robot`

get_actuated_state()[source]
Returns the actuated state of the :py:class`Robot` comprised

of the actuated states of the individual :py:class`KinematicGroup`.

Returns

combined actuated state of all :py:class`KinematicGroup` objects.

Return type

Dict[str, float]

get_endeffectors()[source]
Returns a list of possible endeffectors.

These are the names of all KinematicGroup objects. Since Transformations are internally converted to Groups, this includes the names of all Transformations.

Returns

list of possible endeffectors.

Return type

list(str)

get_groups()[source]
Returns a dictionary of the py:class`KinematicGroup` managed by the :py:class`Robot`_

Since Transformations are internally converted to Groups, this also returns all Transformations.

Returns

The dictionary of py:class`KinematicGroup` objects.

Return type

Dict[str, KinematicGroup]

get_symbolic_rep(endeffector: str)[source]

This Function returnes a symbolic representation of the virtual chain.

Parameters

endeffector (str) – The name of the group whose virtual chain models the desired endeffector

Raises

KeyError – If the endeffector argument is not the name of a transformation or group

Returns

A 4x4 symbolic casadi matrix containing the transformation from base to endeffector

Return type

SX

get_virtual_state()[source]
Returns the virtual state of the :py:class`Robot` comprised

of the virtual states of the individual :py:class`KinematicGroup`.

Returns

combined virtual state of all

:py:class`KinematicGroup` objects.

Return type

Dict[str,Dict[str, float]]

pass_group_arg_a_to_v(argv_dict)[source]
Passes optional actuated_to_virtual mapping arguments

to :py:class`KinematicGroup` objects of the robot.

Parameters

argv_dict (Dict) – A dictionary containing the mapping arguments keyed with the :py:class`KinematicGroup` names.

Raises

KeyError – If no group with the name given in the argument is part of the robot.

pass_group_arg_v_to_a(argv_dict: Dict)[source]
Passes optional virtual_to_actuated mapping arguments

to :py:class`KinematicGroup` objects of the robot.

Parameters

argv_dict (Dict) – A dictionary containing the mapping arguments keyed with the :py:class`KinematicGroup` names.

Raises

KeyError – If no group with the name given in the argument is part of the robot.

set_actuated_state(state: Dict[str, float])[source]

Sets the virtual state of multiple actuated joints of the robot.

Parameters

state (Dict[str, float]) – A dictionary containing the members of __actuated_state that should be set.

set_virtual_state(state: Dict[str, Dict[str, float]])[source]

Sets the virtual state of multiple virtual joints of the robot.

Parameters

state (Dict[str,Dict[str, float]]) –

A dictionary containing the members of

__virtual_state that should be set.

The new values need to be valid state for the state of the joint.

trip_kinematics.Robot.forward_kinematics(robot: trip_kinematics.Robot.Robot, endeffector)[source]

Calculates a robots transformation from base to endeffector using its current state

Parameters

robot (Robot) – The robot for which the forward kinematics should be computed

Returns

The Transformation from base to endeffector

Return type

numpy.array