Module: robotics

A library which includes support functions for robotics; the library is built on standard Denavit-Hartenberg Parameters and Homogeneous Transformations (HT) to describe transformations and coordinate systems; import this library e.g. with import exudyn.robotics as robotics

  • Author: Johannes Gerstmayr

  • Date: 2020-04-14

  • Example: New robot model uses the class Robot with class RobotLink; the old dictionary structure is defined in the example in ComputeJointHT for the definition of the ‘robot’ dictionary.

Function: _ToHT

_ToHT(H)

  • function description: an exudyn.HT from an exudyn.HT (the same object), a 4x4 matrix or None (the identity); the robotics classes store and compute with exudyn.HT (#2821)

Function: StdDH2HT

StdDH2HT(DHparameters)

  • function description: compute the homogeneous transformation HT, an exudyn.HT, from standard DHparameters=[theta, d, a, alpha]

Relevant Examples (Ex) and TestModels (TM) with weblink to github: humanRobotInteraction.py (Ex), InverseKinematicsNumericalExample.py (Ex), serialRobotFlexible.py (Ex), serialRobotInteractiveLimits.py (Ex), serialRobotKinematicTree.py (Ex), movingGroundRobotTest.py (TM), serialRobotTest.py (TM), …

Function: ModDHKK2HT

ModDHKK2HT(DHparameters)

  • function description: compute pre- and post- homogeneous transformations (exudyn.HT) from modified Denavit-Hartenberg DHparameters=[alpha, d, theta, r]; returns [HTpre, HTpost]; HTpre is transformation before axis rotation, HTpost includes axis rotation and everything hereafter; modified DH-Parameters according to Khalil and Kleinfinger, 1986

Relevant Examples (Ex) and TestModels (TM) with weblink to github: serialRobotKinematicTree.py (Ex)

Function: projectAngleToPMPi

projectAngleToPMPi(q0)

  • function description: This function projects an angle in the range \([-min_{float}, +max_{float}]\) fo the range \([-\pi, +\pi]\)

  • input:

    • q0: An angle either as scalar, list or array

  • output: qProj: The angle projected into the range \([-\pi to \pi]\)

  • author: Peter Manzl

CLASS VRobotTool (in module robotics)

class description: class to define visualization of RobotTool

Class function: init

__init__(self, graphicsData = [])

  • class function description: initialize robot tool with parameters; currently only graphicsData, which is a list of GraphicsData same as in mbs Objects

Relevant Examples (Ex) and TestModels (TM) with weblink to github: humanRobotInteraction.py (Ex), InverseKinematicsNumericalExample.py (Ex), kinematicTreeAndMBS.py (Ex), kinematicTreePendulum.py (Ex), openAIgymNLinkAdvanced.py (Ex), kinematicTreeAndMBStest.py (TM), kinematicTreeConstraintTest.py (TM), movingGroundRobotTest.py (TM), …

CLASS RobotTool (in module robotics)

class description: define tool of robot: containing graphics and HT (may add features in future)

Class function: init

__init__(self, HT = None, visualization = VRobotTool())

  • class function description: initialize robot tool

  • input:

    • HT: exudyn.HT or 4x4 matrix (list of lists / numpy array) containing homogeneous transformation to transform from last link to tool, stored as exudyn.HT; default (None) = identity

    • graphicsData: dictionary containing a list of GraphicsData, same as in exudyn Objects

Class function: HT

HT(self)

  • class function description: the homogeneous transformation, an exudyn.HT

Relevant Examples (Ex) and TestModels (TM) with weblink to github: humanRobotInteraction.py (Ex), InverseKinematicsNumericalExample.py (Ex), kinematicTreeAndMBS.py (Ex), kinematicTreePendulum.py (Ex), openAIgymNLinkAdvanced.py (Ex), homogeneousTransformationParameterTest.py (TM), kinematicTreeAndMBStest.py (TM), kinematicTreeConstraintTest.py (TM), …

CLASS VRobotBase (in module robotics)

class description: class to define visualization of RobotBase

Class function: init

__init__(self, graphicsData = [])

  • class function description: initialize robot base with parameters; currently only graphicsData, which is a list of GraphicsData same as in mbs Objects

Relevant Examples (Ex) and TestModels (TM) with weblink to github: humanRobotInteraction.py (Ex), InverseKinematicsNumericalExample.py (Ex), kinematicTreeAndMBS.py (Ex), kinematicTreePendulum.py (Ex), openAIgymNLinkAdvanced.py (Ex), kinematicTreeAndMBStest.py (TM), kinematicTreeConstraintTest.py (TM), movingGroundRobotTest.py (TM), …

CLASS RobotBase (in module robotics)

class description: define base of robot: containing graphics and HT (may add features in future)

Class function: init

__init__(self, HT = None, visualization = VRobotBase())

  • class function description: initialize robot base

  • input:

    • HT: exudyn.HT or 4x4 matrix (list of lists / numpy array) containing homogeneous transformation to transform from world coordinates to base coordinates (changes orientation and position of robot), stored as exudyn.HT; default (None) = identity

    • graphicsData: dictionary containing a list of GraphicsData, same as in exudyn Objects

Class function: HT

HT(self)

  • class function description: the homogeneous transformation, an exudyn.HT

Relevant Examples (Ex) and TestModels (TM) with weblink to github: humanRobotInteraction.py (Ex), InverseKinematicsNumericalExample.py (Ex), kinematicTreeAndMBS.py (Ex), kinematicTreePendulum.py (Ex), openAIgymNLinkAdvanced.py (Ex), homogeneousTransformationParameterTest.py (TM), kinematicTreeAndMBStest.py (TM), kinematicTreeConstraintTest.py (TM), …

CLASS Robot (in module robotics)

class description: class to define a robot

Class function: init

__init__(self, gravity = [0,0,-9.81], base = RobotBase(), tool = RobotTool(), referenceConfiguration = [])

  • class function description: initialize robot class

  • input:

    • base: definition of base using RobotBase() class

    • tool: definition of tool using RobotTool() class

    • gravity: a list or 3D numpy array defining gravity

    • referenceConfiguration: a list of scalar quantities defining the parameters for reference configuration

Class function: IsSerialRobot

IsSerialRobot(self)

  • class function description: return True, if robot is a serial robot

Class function: HasParent

HasParent(self, i)

  • class function description: True if link has parent, False if not

Class function: GetParentIndex

GetParentIndex(self, i)

  • class function description: Get index of parent link; for serial robot this is simple, but for general trees, there is a index list

Class function: GetBaseHT

GetBaseHT(self)

  • class function description: return base as homogeneous transformation

Class function: GetToolHT

GetToolHT(self)

  • class function description: return base as homogeneous transformation

Class function: LinkHT

LinkHT(self, q)

  • class function description: compute list of homogeneous transformations (exudyn.HT) for every link, using current joint coordinates q; leads to different results for standard and modified DH parameters because link coordinates are different!

Class function: JointHT

JointHT(self, q)

  • class function description: compute list of homogeneous transformations (exudyn.HT) for every joint (after rotation), using current joint coordinates q

Class function: COMHT

COMHT(self, HT)

  • class function description: compute list of homogeneous transformations HT (exudyn.HT) from base to every COM using HT list from Robot.JointHT(…)

Class function: StaticTorques

StaticTorques(self, HT)

  • class function description: compute list of joint torques for serial robot due to gravity (gravity and mass as given in robot), taking HT from Robot.JointHT()

Class function: Jacobian

Jacobian(self, HT, toolPosition = [], mode = 'all', linkIndex = None)

  • class function description: compute jacobian for translation and rotation at toolPosition using joint HT; this is using the Robot functions, but is inefficient for simulation purposes

  • input:

    • HT: list of homogeneous transformations per joint , as computed by Robot.JointHT(…)

    • toolPosition: global position at which the jacobian is evaluated (e.g., COM); if empty [], it uses the origin of the last link

    • mode: ‘all’…translation and rotation jacobian, ‘trans’…only translation part, ‘rot’: only rotation part

    • linkIndex: link index for which the jacobian is evaluated; if linkIndex==None, it uses the last link provided in HT

  • output: returns jacobian with translation and rotation parts in rows (3 or 6) according to mode, and one column per HT; in the kinematic tree the columns not related to linkIndex remain zero

Class function: CreateKinematicTree

CreateKinematicTree(self, mbs, name = '', forceUserFunction = 0)

  • class function description: Add a ObjectKinematicTree to existing mbs from the robot structure inside this robot class; Joints defined by the kinematics as well as links (and inertia) are transferred to the kinematic tree object; Current implementation only works for serial robots; Control can be realized simply by adding PDcontrol to RobotLink structures, then modifying jointPositionOffsetVector and jointVelocityOffsetVector in ObjectKinematicTree; force offsets (e.g., static or dynamic torque compensation) can be added to KinematicTree jointForceVector; more general control can be added by using KinematicTree forceUserFunction; The coordinates in KinematicTree (as well as jointPositionOffsetVector, etc.) are sorted in the order as the RobotLinks are added to the Robot class; Note that the ObjectKinematicTree is still under development and interfaces may change.

  • input:

    • mbs: the multibody system, which will be extended

    • name: object name in KinematicTree; transferred to KinematicTree, default = ‘’

    • forceUserFunction: defines the user function for computation of joint forces in KinematicTree; transferred to KinematicTree, default = 0

  • output: the function returns a dictionary containing ‘nodeGeneric’: generic ODE2 node number ,’objectKinematicTree’: the kinematic tree object, ‘baseObject’: the base object if created, otherwise None; further values will be added in future

Class function: CreateRedundantCoordinateMBS

CreateRedundantCoordinateMBS(self, mbs, baseMarker, jointSpringDamperUserFunctionList = [], jointLoadUserFunctionList = [], createJointTorqueLoads = True, rotationMarkerBase = None, rigidBodyNodeType = exudyn.NodeType.RotationEulerParameters)

  • class function description: Add items to existing mbs from the robot structure inside this robot class; robot is attached to baseMarker (can be ground object or moving/deformable body); The (serial) robot is built as rigid bodies (containing rigid body nodes), where bodies represent the links which are connected by joints; Add optional jointSpringDamperUserFunctionList for individual control of joints; otherwise use PDcontrol in RobotLink structure; additional joint torques/forces can be added via spring damper, using mbs.SetObjectParameter(…) function; See several Python examples, e.g., serialRobotTestTSD.py, in Examples or TestModels; For more efficient models, use CreateKinematicTree(…) function!

  • input:

    • mbs: the multibody system, which will be extended

    • baseMarker: a rigid body marker, at which the robot will be placed (usually ground); note that the local coordinate system of the base must be in accordance with the DH-parameters, i.e., the z-axis must be the first rotation axis. For correction of the base coordinate system, use rotationMarkerBase

    • jointSpringDamperUserFunctionList: NOT IMPLEMENTED yet: jointSpringDamperUserFunctionLista list of user functions for actuation of joints with more efficient spring-damper based connector (spring-damper directly emulates PD-controller); uses torsional spring damper for revolute joints and linear spring damper for prismatic joints; can be empty list (no spring dampers); if entry of list is 0, no user function is created, just pure spring damper; parameters are taken from RobotLink PDcontrol structure, which MUST be defined using SetPDcontrol(…) in RobotLink

    • jointLoadUserFunctionList: DEPRECATED: a list of user functions for actuation of joints according to a LoadTorqueVector userFunction, see serialRobotTest.py as an example; can be empty list

    • createJointTorqueLoads: DEPRECATED: if True, independently of jointLoadUserFunctionList, joint loads are created; the load numbers are stored in lists jointTorque0List/ jointTorque1List; the loads contain zero torques and need to be updated in every computation step, e.g., using a preStepUserFunction; unitTorque0List/ unitTorque1List contain the unit torque vector for the according body(link) which needs to be applied on both bodies attached to the joint

    • rotationMarkerBase: add a numpy 3x3 matrix for rotation of the base, in order that the robot can be attached to any rotated base marker; the rotationMarkerBase is according to the definition in GenericJoint; note, that for moving base, the static compensation does not work (base rotation must be updated)

    • rigidBodyNodeType: specify node type of rigid body node, e.g., exudyn.NodeType.RotationEulerParameters, etc.

  • output: the function returns a dictionary containing per link nodes and object (body) numbers, ‘nodeList’, ‘bodyList’, the object numbers for joints, ‘jointList’, list of load numbers for joint torques (jointTorque0List, jointTorque1List); unit torque vectors in local coordinates of the bodies to which the torques are applied (unitTorque0List, unitTorque1List); springDamperList contains the spring dampers if defined by PDcontrol of links

Class function: GetKinematicTree66

GetKinematicTree66(self)

  • class function description: export kinematicTree

Class function: GetLinkGraphicsData

GetLinkGraphicsData(self, i, p0, p1, axis0, axis1, linkVisualization)

  • class function description: create link GraphicsData (list) for link i; internally used in CreateRedundantCoordinateMBS(…); linkVisualization contains visualization dict of link

Class function: BuildFromDictionary

BuildFromDictionary(self, robotDict)

  • class function description: build robot structre from dictionary; this is a DEPRECATED function, which is used in older models; DO NOT USE

Relevant Examples (Ex) and TestModels (TM) with weblink to github: humanRobotInteraction.py (Ex), kinematicTreeAndMBS.py (Ex), kinematicTreePendulum.py (Ex), openAIgymNLinkAdvanced.py (Ex), openAIgymNLinkContinuous.py (Ex), kinematicTreeConstraintTest.py (TM), movingGroundRobotTest.py (TM), serialRobotTest.py (TM), …

CLASS InverseKinematicsNumerical() (in module robotics)

class description: This class can be used to solve the inverse kinematics problem using a multibody system by solving the static problem of a serial robot

  • author: Peter Manzl, Johannes Gerstmayr

  • notes: still under development; errors in orientations of solution may occure. proviedes mtehods to calculate inverse Kinematics

Class function: init

__init__(self, robot, jointStiffness = 1e0, useRenderer = False, flagDebug = False, useAlternativeConstraints = False)

  • class function description: initialize RigidBodyInertia with scalar mass, 3x3 inertiaTensor (w.r.t. reference point!!!) and center of mass com

  • input:

    • robot: robot class

    • jointStiffness: the stiffness used for the robot’s model joints

    • useRenderer: when solving the inverse kinematics the renderer is used to show the starting/end configuration of the robot using the graphics objects definded in the robot object

  • author: Peter Manzl

Class function: GetCurrentRobotHT

GetCurrentRobotHT(self)

  • class function description: Utility function to get current Homogeneous transformation of the robot to check inverse Kinematics solution ** output: T: homogeneous transformation (exudyn.HT) of the current TCP pose

Class function: InterpolateHTs

InterpolateHTs(self, T1, T2, rotStep = np.pi/16, minSteps = 1)

  • class function description:

  • input:

    • T1: 4x4 homogeneous transformation matrix representing the first Pose

    • T2: 4x4 homogeneous transformation matrix representing the second Pose

    • rotStep: the max. size of steps to take for the orientation

    • minSteps: minimum number of substeps to interpolate

  • output: T: a List of homogeneous transformations (exudyn.HT) for each step between

  • author: Peter Manzl

  • notes: still under development; interpolation may be changed to using logSE3

Class function: SolveSafe

SolveSafe(self, T, q0 = None)

  • class function description: This Method can be used to solve the inverse kinematics problem by solving the static problem of a serial robot using steps to interpolate between start and end position close to the function Solve. This helps the function Solve() to find the correct solutions.

  • input:

    • T: the homogeneous transformation, an exudyn.HT or a 4x4 matrix, representing the desired position and orientation of the Endeffector

    • q0: The configuration (joint angles/positions) of the robot from which the numerical methods start so calculate the solution; q0=None indicates that the stored solution (from model or previous solution) shall be used for initialization

  • output: [q, success]; q: The solution for the joint angles in which the robot’s tool center point (TCP) reaches the desired homogeneous transformation matrix T; success=False indicates that all trials for inverse kinematics failed, leading to q=None success: flag to indicate if method was successful

  • author: Peter Manzl, Johannes Gerstmayr

  • notes: still under development; errors in orientations of solution may occure. works similar to ikine_LM function of the robotics toolbox from peter corke

Class function: Solve

Solve(self, T, q0 = None)

  • class function description: This Method can be used to solve the inverse kinematics problem by solving the static problem of a serial robot using steps to interpolate between start and end position close to the function Solve. T his helps the fucntion Solve to find the correct solutions.

  • input:

    • T: the homogeneous transformation, an exudyn.HT or a 4x4 matrix, representing the desired position and orientation of the Endeffector

    • q0: The configuration (joint angles/positions) of the robot from which the numerical methods start so calculate the solution; q0=None indicates that the stored solution (from model or previous solution) shall be used for initialization

  • output: [q, success]; q: The solution for the joint angles in which the robot’s tool center point (TCP) reaches the desired homogeneous transformation matrix T; success=False indicates that all trials for inverse kinematics failed, leading to q=None

  • author: Peter Manzl, Johannes Gerstmayr

  • notes: still under development; errors in orientations of solution may occure. works similar to ikine_LM function of the robotics toolbox from peter corke

Relevant Examples (Ex) and TestModels (TM) with weblink to github: InverseKinematicsNumericalExample.py (Ex), serialRobotInverseKinematics.py (Ex)